Skip to content

Commit 2e791cd

Browse files
committed
p30
1 parent 8d68126 commit 2e791cd

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

29-run-length.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
def RunLength(strV):
1+
def RunLength(str):
22
mark = 0
33
result = ""
4-
for i in range(1,len(strV)):
5-
if strV[i-1] != strV[i]:
6-
result += str(i-mark)+strV[mark]
4+
for i in range(1,len(str)+1):
5+
if i==len(str) or str[i-1] != str[i]:
6+
result += "%d%s" %(i-mark,str[mark])
77
mark = i
88
return result
99

1010

1111
# keep this function call here
1212
# to see how to enter arguments in Python scroll down
13-
print RunLength(raw_input())
14-
15-
16-
13+
print RunLength(raw_input())

30-prime-move.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
def is_Prime(n):
2+
for i in xrange(3, int(n ** 0.5)+1, 2):
3+
if n % i == 0:
4+
return False
5+
return True
6+
7+
def PrimeMover(num):
8+
count = 1
9+
i = 1
10+
while count < num:
11+
i += 2
12+
if is_Prime(i):
13+
count += 1
14+
return i
15+
16+
17+
# keep this function call here
18+
# to see how to enter arguments in Python scroll down
19+
print PrimeMover(raw_input())

0 commit comments

Comments
 (0)