Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
My solution for the Problem A of the qualification of 2017's edition of Google Code Jam: Oversized Pancake Flipper Raw
#! /usr/bin/env python
import sys
def solve(line):
prev = "0"
for i, digit in enumerate(line):
if digit < prev:
left_part = str(int(line[:i])-1)
right_part = "9" * (len(line) - i)
return left_part + right_part
prev = digit
if __name__ == "__main__":
with file(sys.argv[1]) as f:
cases = int(f.readline())
for i in range(cases):
line = f.readline().strip()
print("Case #%d: %s" % (i+1, solve(line)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment