Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

itertools.combinations()

https://www.hackerrank.com/challenges/itertools-combinations

Problem

itertools.combinations(iterable[, r])

This tool returns the r length subsequences of elements from the input iterable.

Combinations are emitted in lexicographic sorted order. So, if the input iterable is sorted, the combination tuples will be produced in sorted order.

Task

You are given a string S.

Your task is to print all possible combinations of size k of the string in lexicographic sorted order.

Input Format

A single line containing the string S and integer value k separated by a space.

Output Format

Print the combinations of the string S on separate lines.

Sample Input 0

HACK 2

Sample Output 0

A
C
H
K
AC
AH
AK
CH
CK
HK

My Solution