Last active
April 12, 2016 13:44
-
-
Save bryceandress/3ba7f20d66ec38baa4fd7413c0f10df2 to your computer and use it in GitHub Desktop.
schensted.dat problem for sctf 2016
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
#!/usr/bin/env python | |
#Open file and read file | |
f = open('schensted.dat') | |
numbers = f.read() | |
checked = 0 | |
unchecked = 1 | |
current = str(numbers[0]) | |
longest = "" | |
#Loop until we reach the second last character (last is \n") | |
while unchecked < (len(numbers)-1): | |
#Check if unchecked is greater than the current number | |
if int(numbers[checked]) <= int(numbers[unchecked]): | |
#if it is append the current number to our string and increase vars | |
current = str(current) + str(numbers[checked]) | |
current = str(current) | |
unchecked = unchecked + 1 | |
checked = checked + 1 | |
else: | |
current = str(current) + str(numbers[checked]) | |
#If it is not reset current and if current is greater than longest set longest | |
if len(str(current)) > len(str(longest)): | |
longest = current | |
unchecked = unchecked + 1 | |
checked = checked + 1 | |
current = "" | |
print(longest) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment