Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0e96d96

Browse filesBrowse files
itertools
1 parent ee840d2 commit 0e96d96
Copy full SHA for 0e96d96

File tree

Expand file treeCollapse file tree

6 files changed

+153
-46
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+153
-46
lines changed

‎.idea/workspace.xml

Copy file name to clipboardExpand all lines: .idea/workspace.xml
+111-46Lines changed: 111 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎itertools/combinations.py

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#from __future__ import print_function
2+
from itertools import combinations
3+
data = raw_input().split()
4+
word = data[0]
5+
word = sorted(word)
6+
parameter = int(data[1])
7+
#print word
8+
#print parameter
9+
for i in range(1, parameter+1):
10+
l = map("".join, list(combinations(word, i)))
11+
for item in sorted(l):
12+
print item

‎itertools/combinationsWithRep.py

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#from __future__ import print_function
2+
from itertools import combinations_with_replacement
3+
data = raw_input().split()
4+
word = data[0]
5+
word = sorted(word)
6+
parameter = int(data[1])
7+
#print word
8+
#print parameter
9+
l = map("".join, list(combinations_with_replacement(word, parameter)))
10+
for item in sorted(l):
11+
print item

‎itertools/itertoolsProduct.py

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
str1 = str()
2+
from itertools import product
3+
lstA = map(int, raw_input().split())
4+
lstB = map(int, raw_input().split())
5+
print ' '.join(map(str,list(product(lstA, lstB))))

‎itertools/permutations.py

Copy file name to clipboard
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#from __future__ import print_function
2+
from itertools import permutations
3+
data = raw_input().split()
4+
word = data[0]
5+
parameter = int(data[1])
6+
print word
7+
print parameter
8+
b = list(permutations(word, parameter))
9+
for item in sorted(b):
10+
print("".join(item))

‎itertools/stringCompress.py

Copy file name to clipboard
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from itertools import groupby
2+
s = raw_input()
3+
for key, group in groupby(s):
4+
print (len(list(group)), int(key))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.