finish Level3/bomb baby #3
@ -5,3 +5,11 @@
|
||||
* Completed in: 2 days, 19 hrs, 36 mins, 16 secs.
|
||||
* Reference
|
||||
* L26.6 Absorption Probabilities, MIT OpenCourseWare, https://www.youtube.com/watch?v=vEsUsaK1HBk
|
||||
|
||||
### the-grandest-staircase-of-them-all
|
||||
* Completed in: 16 hrs, 38 mins, 52 secs.
|
||||
* DP
|
||||
|
||||
### bomb-baby
|
||||
* Completed in: 1 hr, 46 mins, 55 secs.
|
||||
* GCD
|
||||
|
||||
23
level3/bomb-baby/solution.py
Normal file
23
level3/bomb-baby/solution.py
Normal file
@ -0,0 +1,23 @@
|
||||
def solution(x, y):
|
||||
return gcd(int(x), int(y))
|
||||
|
||||
def gcd(x, y):
|
||||
count = 0
|
||||
while y != 0:
|
||||
t = x % y
|
||||
count += x//y
|
||||
x, y = y, t
|
||||
if x != 1:
|
||||
return 'impossible'
|
||||
return str(count-1)
|
||||
|
||||
tests=[
|
||||
[['4', '7'], '4'],
|
||||
[['2', '1'], '1'],
|
||||
[['2', '4'], 'impossible'],
|
||||
]
|
||||
|
||||
for test in tests:
|
||||
result = solution(*test[0])
|
||||
print(test[0][0], test[0][1], result == test[1], result, test[1])
|
||||
print ''
|
||||
8
recruitme.txt
Normal file
8
recruitme.txt
Normal file
@ -0,0 +1,8 @@
|
||||
Checking your permissions...
|
||||
Share solutions with a Google Recruiter?
|
||||
If you opt in, Google Staffing may reach out to you regarding career opportunities, events, and programs. We will use your information in accordance with our Applicant and Candidate Privacy Policy.
|
||||
Applicant and Candidate Privacy Policy.
|
||||
[#1] [Yes [N]o [A]sk me later:]
|
||||
[Y]es [N]o [A]sk me later: A
|
||||
Response: contact postponed.
|
||||
To share your progress at any time, use the recruitme command.
|
||||
Loading…
x
Reference in New Issue
Block a user