Skip to content

Commit 97a529f

Browse files
committed
4 6kyu,1 7 kyu
1 parent 1fc77f8 commit 97a529f

8 files changed

+66
-0
lines changed

[6 kyu]Dubstep.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import re
2+
def song_decoder(song):
3+
print(song)
4+
return ' '.join([word for word in re.findall(r'[A-Z]*',song.replace('WUB',' ')) if len(word) != 0])
5+
6+
print(song_decoder('WUBAWUBCCWUBDD'))

[6 kyu]Unique In Order.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def unique_in_order(iterable):
2+
res = []
3+
for c in iterable:
4+
if len(res) == 0 or res[-1] != c:
5+
res.append(c)
6+
return res

[6 kyu]Word a9n.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import re
2+
def abbreviate(s):
3+
def abbr(s):
4+
return s[0] + str(len(s)-2) + s[-1]
5+
return re.sub(r'\w{4,}',lambda m: abbr(m.group(0)),s)
6+
7+
print(abbreviate('sits. is; cat; doggy. double-barreled.'))

[6 kyu]title case.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def title_case(title, minor_words = ''):
2+
if len(title) == 0:
3+
return ''
4+
res = [title.title().split()[0]]
5+
for word in title.title().split()[1:]:
6+
if word.lower() in [w.lower() for w in minor_words.split()]:
7+
res.append(word.lower())
8+
else:
9+
res.append(word)
10+
return ' '.join(res)
11+
12+
print(title_case('a clash of KINGS', 'a an the of'))
13+
print(title_case('', ''))

[7 kyu]Ninja vs Samurai Strike.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Warrior:
2+
def __init__(self,name):
3+
self.name = name
4+
self.health = 100
5+
self.visible = True
6+
7+
def strike(self,enemy,swings):
8+
#health cannot go below zero
9+
enemy.health = max([0,enemy.health-(swings*10)]) if enemy.visible else enemy.health
10+
11+
def hide(self):
12+
self.visible = not(self.visible)
13+
14+
ninja = Warrior('Ninja')
15+
samurai = Warrior('Samurai')
16+
ninja.hide()
17+
samurai.strike(ninja, 3)
18+
print(ninja.health)
19+
# ninja.health should == 70

[beta]Are Those Vampire Numbers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def is_vampirenumber(multiplicand1, multiplicand2):
2+
if multiplicand1 == None or multiplicand2 == None:
3+
return False
4+
return sorted(str(multiplicand1 * multiplicand2)) == sorted(str(multiplicand1)+str(multiplicand2))
5+

__pycache__/test.cpython-34.pyc

393 Bytes
Binary file not shown.

test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def substract7(n):
2+
res = [n]
3+
while n > 0:
4+
x = input('press cotinues')
5+
n -= 7
6+
print(n)
7+
8+
print(substract7(200))
9+
10+
b = 3

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