Last active
July 7, 2018 09:22
-
-
Save jan25/9479dd2d5d64168ab14fa2851c23bc4b to your computer and use it in GitHub Desktop.
spaces fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nums = [ "569815571556", "4938532894754", "1234567", "472844278465445" ] | |
def get_lotter_nums_rec_helper(curr_num, curr_n, rem_str): | |
if curr_num > 0 and curr_num < 60: | |
lottery_nums = get_lottery_nums_rec(curr_n - 1, rem_str) | |
if lottery_nums: | |
return [curr_num] + lottery_nums | |
def get_lottery_nums_rec(n, s): | |
if n == 0 and s == '': return [' '] | |
if n == 0 or s == '' or 2 * n < len(s): return | |
lottery_nums = get_lotter_nums_rec_helper(int(s[:1]), n, s[1:]) | |
lottery_nums = lottery_nums or get_lotter_nums_rec_helper(int(s[:2]), n, s[2:]) | |
return lottery_nums | |
def get_lottery_nums(s): | |
return get_lottery_nums_rec(7, s) | |
for num in nums: | |
lottery_nums = get_lottery_nums(num) | |
if lottery_nums: | |
print (num, '->', (*lottery_nums)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment