Instantly share code, notes, and snippets.

# wblakecaldwell/google_io_puzzle.py Last active Aug 29, 2015

Google I/O secret invite code finder

### vinubalaji commented Apr 23, 2014

 some links go to random websites. So I am guessing there is something wrong with the logic somewhere. I wonder how some links works!

### sachins commented Apr 23, 2014

 Can you do a verification of goo.gl URL you are generating similar to what "func verifyGoogl(uri *url.URL)" does at https://gist.github.com/fastest963/10978299? That would eliminate the 404 and 403 easily.

### yanick76 commented Apr 23, 2014

 You have bug in calculate_shortened_url. I don't have any experience with python, but my first try in python is here (feel free to beautify my code): ```def calculate_shortened_url(i_color_code, o_color_code, secret_code): s = str(unichr(int("0x" + i_color_code[0:2], 16))) s += str(unichr(int("0x" + i_color_code[2:4], 16))) s += str(unichr(int("0x" + i_color_code[4:6], 16))) s += str(unichr(int("0x" + o_color_code[0:2], 16))) s += str(unichr(int("0x" + o_color_code[2:4], 16))) s += str(unichr(int("0x" + o_color_code[4:6], 16))) # |secret_code| is 6 character string consisting of the integers #0-5. Reorder |s| by taking its index at the values of |secret_code|. # For example, if |secret_code| is '543210', then we're reversing |s|. output = '' pos = 0 while len(output) < len(s): for i in range(0, len(s)): if pos == int(secret_code[i]): output += s[i] pos += 1 return output```