Skip to content

Commit c1969ef

Browse files
committed
Upload Lesson 12.
1 parent 649645e commit c1969ef

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

12-Gcd_cckao.pdf

488 KB
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# you can write to stdout for debugging purposes, e.g.
2+
# print("this is a debug message")
3+
4+
def solution(N, M):
5+
# write your code in Python 3.6
6+
7+
# key:
8+
# meet in the circle = number of chocolates that you will eat
9+
# number of chocolates = N / gcd(N, M)
10+
num_chocolates = N // gcd(N,M)
11+
12+
return num_chocolates
13+
14+
# find gcd (greatest common divisor)
15+
def gcd(a, b):
16+
if a % b == 0:
17+
return b
18+
else:
19+
return gcd(b, a%b)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# you can write to stdout for debugging purposes, e.g.
2+
# print("this is a debug message")
3+
4+
def solution(N, M):
5+
# write your code in Python 3.6
6+
7+
my_dictionary = {}
8+
9+
current_value = 0
10+
11+
while current_value not in my_dictionary:
12+
my_dictionary[current_value] = 1
13+
current_value = (current_value + M) % N
14+
# print(my_dictionary)
15+
16+
return len(my_dictionary)

0 commit comments

Comments
 (0)