diff --git a/README.md b/README.md index 491c87f..ce2e45c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/level3/bomb-baby/solution.py b/level3/bomb-baby/solution.py new file mode 100644 index 0000000..83c80e4 --- /dev/null +++ b/level3/bomb-baby/solution.py @@ -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 '' diff --git a/recruitme.txt b/recruitme.txt new file mode 100644 index 0000000..cca8bd7 --- /dev/null +++ b/recruitme.txt @@ -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.