Skip to content

Commit 79c3a17

Browse files
committed
finish {'4kyu':1,'5kyu':1,'6kyu':1,'7kyu':2,'beta':1}
1 parent 2d52193 commit 79c3a17

7 files changed

+78
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
def same_structure_as(original,other):
2+
if type(original) in ('str','int') and type(other) in ('str','int'):
3+
if ''.join(map(str,original)) == ''.join(map(str,other)):
4+
return True
5+
if ''.join(map(str,original)) == ''.join(map(str,other))[::-1]:
6+
return True
7+
else:
8+
return False
9+
10+
if type(original) != type(other):
11+
return False
12+
13+
if len(original) != len(other):
14+
return False
15+
for ori,oth in zip(original,other):
16+
if type(ori) != type(oth):
17+
return False
18+
elif type(ori) == type(oth) and isinstance(ori,list):
19+
if not same_structure_as(ori,oth) or len(ori) != len(oth):
20+
return False
21+
return True
22+
23+
24+
print(same_structure_as([1,[1,1]],[2,[2,2],[2,3]]))
25+
print(same_structure_as([1,'[',']'], ['[',']',1]))

[4 kyu]Permutations.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import itertools
2+
def permutations(string):
3+
return sorted([''.join(p) for p in set(itertools.permutations(string,len(string)))])
4+
5+
print(permutations('aabb'))

[5 kyu]Pascal's Triangle #2.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from math import factorial
2+
def pascal(p):
3+
def cFormula(n,m):
4+
return int(factorial(n) / (factorial(n-m) * factorial(m))) if n != 0 else 1
5+
return [[cFormula(i,j) for j in range(i+1) ] for i in range(p)]
6+
print(pascal(5))
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def pattern(n):
2+
res = []
3+
spaces = (2 * n) - 1
4+
for i in range(1,n+1):
5+
term = list(range(1,i+1)) + list(range(i-1,0,-1))
6+
term = [t%10 for t in term]
7+
term = [' '] * int(((spaces - len(term))/2)) + term + [' '] * int(((spaces - len(term))/2))
8+
term = ''.join(map(str,term))
9+
res.append(term)
10+
res += res[-2::-1]
11+
return '\n'.join(res)
12+
13+
14+
print(pattern(27))

[7 kyu]makeBackronym.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#preloaded variable: "dictionary"
2+
3+
def make_backronym(acronym):
4+
return ' '.join([dictionary[c.upper()] for c in acronym])

[7 kyu]reverseIt.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def reverse_it(data):
2+
if isinstance(data,bool):
3+
return data
4+
elif isinstance(data,int):
5+
return int(str(data)[::-1])
6+
elif isinstance(data,str):
7+
return data[::-1]
8+
elif isinstance(data,float):
9+
return float(str(data)[::-1])
10+
11+
else:
12+
return data
13+
14+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def pattern(n):
2+
res = []
3+
spaces = (2 * n) - 1
4+
for i in range(1,n+1):
5+
term = list(range(1,i+1)) + list(range(i-1,0,-1))
6+
term = [t%10 for t in term]
7+
term = [' '] * int(((spaces - len(term))/2)) + term + [' '] * int(((spaces - len(term))/2))
8+
term = ''.join(map(str,term))
9+
res.append(term)
10+
return '\n'.join(res)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy