Last active
April 29, 2016 00:39
-
-
Save mekuls/95ac203fdaf18e2062f7cdb8a89ea0ac to your computer and use it in GitHub Desktop.
A bit of tinkering...
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
# This is the Original Code. | |
# list(map(lambda x: chr(int(x***2)), [8.54, 10.5, 10.72, 10.6, 10.25, 10.68, 10.04, 10, 7.07, 6.93, 7, 7.35)) | |
# Our first iteration was this: | |
# list(map(lambda x: chr(int(x**2)), [8.54, 10.5, 10.72, 10.6, 10.25, 10.68, 10.04, 10, 7.07, 6.93, 7, 7.35])) | |
# which produced -> ['H', 'n', 'r', 'p', 'i', 'r', 'd', 'd', '1', '0', '1', '6'] | |
# It almost looks like it ends with '2016' so we try rounding before casting | |
# Here's the last 4 items out of the x**2 part: | |
# [49.9849, 48.024899999999995, 49, 54.022499999999994] | |
# If we round off everything, we'll have [50, 48, 49, 54] which is '2016' after casting. | |
# list(map(lambda x: chr(int(round(x**2))), [8.54, 10.5, 10.72, 10.6, 10.25, 10.68, 10.04, 10, 7.07, 6.93, 7, 7.35])) | |
# -> ['I', 'n', 's', 'p', 'i', 'r', 'e', 'd', '2', '0', '1', '6'] | |
# List cast is not necessary | |
the_message = map(lambda x: chr(int(round(x**2))), (8.54, 10.5, 10.72, 10.6, 10.25, 10.68, 10.04, 10, 7.07, 6.93, 7, 7.35)) | |
print ("Message: {}".format("".join(the_message))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment