Skip to content

Commit 9ff6882

Browse files
committed
finish 2 6kyu 1 5kyu
1 parent 3931568 commit 9ff6882

3 files changed

+53
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
def last_digit(n1, n2):
2+
res = {
3+
1 : [1],
4+
2 : [2,4,8,6],
5+
3 : [3,9,7,1],
6+
4 : [4,6],
7+
5 : [5],
8+
6 : [6],
9+
7 : [7,9,3,1],
10+
8 : [8,4,2,6],
11+
9 : [9,1],
12+
0 : [0]
13+
}
14+
n1 %= 10
15+
if n2 == 0:
16+
return 1
17+
elif n1 in (1,5,6,0):
18+
return n1
19+
else:
20+
return res[n1][n2%len(res[n1]) - 1]
21+
22+
for i in range(0,5):
23+
print(last_digit(34,i))

[6 kyu] Playing with passphrases.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def play_pass(s, n):
2+
res = ''
3+
for c in map(ord,s):
4+
if c in range(65,91):
5+
res += chr((((c-65) + n) % 26) + 65)
6+
elif c in range(97,123):
7+
res += chr((((c-97) + n) % 26) + 97)
8+
elif c in range(48,58):
9+
res += str (abs(9 - int(chr(c))))
10+
else:
11+
res += str(chr(c))
12+
res = ''.join([res[i].upper() if i % 2 == 0 else res[i].lower() for i in range(len(res))])
13+
return res[::-1]

[6 kyu]Complete The Pattern #12.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def pattern(n):
2+
if n <= 0:
3+
return ''
4+
if n == 1:
5+
return '1'
6+
res = []
7+
pattern = [' '] * ( 2 * n -1)
8+
for i in range(1,n):
9+
temp = pattern[:]
10+
temp[i-1] = temp[-i] = str(i%10)
11+
res.append(''.join(temp))
12+
pattern[n-1] = str(n%10)
13+
res.append(''.join(pattern))
14+
res += res[n-2::-1]
15+
return '\n'.join(res)
16+
17+
print(pattern(1))

0 commit comments

Comments
 (0)