Dropquest is an online challenge, organized by dropbox. The rewards are GBs of free lifetime space in dropbox.
It's written in Python. I am getting pretty fluent after taking CS373: Programming A Robotic Car, a free online course by Udacity.
digitized_numbers = lambda n: ( map(int, x) for x in map(list, map(str,range(pow(10,n-1),pow(10,n))))) '''digitized_numbers(5) returns all the 5 digit numbers (23546, 23547 etc.) in the form [...[2,3,5,4,6],[2,3,5,4,7]...]''' print next( d for d in digitized_numbers(5) #d[0], d[1] etc. are the digits. if d[0] * d[1] == 24 #1: 1st * 2nd = 24 if d[3] == d[1] /2 #2: 4th = 2nd / 2 if d[4] + d[3] == d[0] + d[2] #3: 5th + 4th = 1st + 3rd if sum(d) == 26 #4 if len(set(d)) is not len(d) #5 ) ''' Instructions: 1: The product of the first two digits is 24. 2: The fourth digit is half of the second digit. 3: The sum of the last two digits is equal to the sum of the first and third digits. 4: The sum of all the digits is 26. 5: Not all the digits are unique. '''
No comments:
Post a Comment