Skip to content

Commit 445346d

Browse files
committed
added coursera examples
1 parent a3e5c10 commit 445346d

File tree

6 files changed

+66
-2
lines changed

6 files changed

+66
-2
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Problem Description
2+
# Task. Given an integer ??, find the ??th Fibonacci number ????.
3+
# Input Format. The input consists of a single integer ??.
4+
# Constraints. 0 = ?? = 45.
5+
# Output Format. Output ????.
6+
# Time Limits.
7+
# language C C++ Java Python C# Haskell JavaScript Ruby Scala
8+
# time (sec) 1 1 1.5 5 1.5 2 5 5 3
9+
# Memory Limit. 512MB.
10+
11+
12+
13+
14+
15+
n = int(raw_input())
16+
17+
def fibo(n):
18+
if n<=1:
19+
return n
20+
else:
21+
previous = 0
22+
current = 1
23+
for _ in range(n-1):
24+
previous, current = current, previous+current
25+
return current
26+
27+
28+
29+
print fibo(n)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
def fibo(n):
3+
if n<=1:
4+
return n
5+
else:
6+
return fibo(n-1)+fibo(n-2)
7+
print fibo(20)

Algorithm/Warmup/plus-minus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/python
22

33
import sys
4-
4+
print r
55

66
n = float(raw_input().strip())
77
arr = map(float,raw_input().strip().split(' '))

Algorithm/Warmup/timeconv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
import sys
44

55

6-
time = raw_input().strip("':'")
6+
time = raw_input().strip()
77
print time
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
noofgames = (int(raw_input()))
2+
score = map(int,raw_input().split())
3+
highscore=score[0]
4+
lowestscore = score[0]
5+
highct = 0
6+
lowct = 0
7+
for sc in score:
8+
if sc>highscore:
9+
highscore = sc
10+
highct += 1
11+
if sc<lowestscore:
12+
lowestscore = sc
13+
lowct += 1
14+
print highct, lowct
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
q = int(raw_input().strip())
2+
for a0 in xrange(q):
3+
s=raw_input().strip()
4+
# if s.startswith('0'):
5+
# print "No"
6+
# print s.find('1')
7+
# print s.rfind(s,a0,a0-1)
8+
# posof1 = s.find('1')
9+
digits = [str(x) for x in str(s)]
10+
print digits
11+
for digit in len(digits):
12+
if digits[digit]-digits[digit-1] == 1:
13+
print "yes"
14+

0 commit comments

Comments
 (0)