Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2c8de55

Browse files
update
1 parent 7967ee6 commit 2c8de55

File tree

3 files changed

+105
-0
lines changed

3 files changed

+105
-0
lines changed

‎algorithms/18_migratory-birds.py‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/python3
2+
3+
import math
4+
import os
5+
import random
6+
import re
7+
import sys
8+
9+
#
10+
# Complete the 'migratoryBirds' function below.
11+
#
12+
# The function is expected to return an INTEGER.
13+
# The function accepts INTEGER_ARRAY arr as parameter.
14+
#
15+
16+
def migratoryBirds(arr):
17+
# Write your code here
18+
ls = [0,0,0,0,0,0]
19+
for i in range(len(arr)):
20+
ls[arr[i]] +=1
21+
return ls.index(max(ls))
22+
23+
if __name__ == '__main__':
24+
fptr = open(os.environ['OUTPUT_PATH'], 'w')
25+
26+
arr_count = int(input().strip())
27+
28+
arr = list(map(int, input().rstrip().split()))
29+
30+
result = migratoryBirds(arr)
31+
32+
fptr.write(str(result) + '\n')
33+
34+
fptr.close()
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/python3
2+
3+
import math
4+
import os
5+
import random
6+
import re
7+
import sys
8+
9+
#
10+
# Complete the 'dayOfProgrammer' function below.
11+
#
12+
# The function is expected to return a STRING.
13+
# The function accepts INTEGER year as parameter.
14+
#
15+
16+
def dayOfProgrammer(year):
17+
# Write your code here
18+
if (year==1918):
19+
return "26.09.1918"
20+
elif ((year <= 1917) & (year %4==0)) or ((year > 1918) & ((year % 400==0) or ((year %4==0) & (year%100!=0)))):
21+
return "12.09.%s"%year
22+
else:
23+
return '13.09.%s'%year
24+
if __name__ == '__main__':
25+
fptr = open(os.environ['OUTPUT_PATH'], 'w')
26+
27+
year = int(input().strip())
28+
29+
result = dayOfProgrammer(year)
30+
31+
fptr.write(result + '\n')
32+
33+
fptr.close()

‎algorithms/20_bon-appetit.py‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/python3
2+
3+
import math
4+
import os
5+
import random
6+
import re
7+
import sys
8+
9+
#
10+
# Complete the 'bonAppetit' function below.
11+
#
12+
# The function accepts following parameters:
13+
# 1. INTEGER_ARRAY bill
14+
# 2. INTEGER k
15+
# 3. INTEGER b
16+
#
17+
18+
def bonAppetit(bill, k, b):
19+
# Write your code here
20+
diff = sum(bill) - bill[k]
21+
diff = diff//2
22+
if diff == b:
23+
print("Bon Appetit")
24+
else:
25+
print(b-diff)
26+
27+
if __name__ == '__main__':
28+
first_multiple_input = input().rstrip().split()
29+
30+
n = int(first_multiple_input[0])
31+
32+
k = int(first_multiple_input[1])
33+
34+
bill = list(map(int, input().rstrip().split()))
35+
36+
b = int(input().strip())
37+
38+
bonAppetit(bill, k, b)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /