-
-
Save LizardLeliel/10561500 to your computer and use it in GitHub Desktop.
Dalhousie problem letter E
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 was Dalhousie University's 2014 programming competition problem letter E. | |
#We were suposed to have input as a text file, which were suposed to be mock examples of twitter posts. We had to output any | |
#line that contained a line that contained an expression like "3-4". | |
#This was meant to be done with Regular Expressions, but I have had no knowledge in those, so I had to do something unique and creative. | |
#I also did something I have never done before in programming - error trapping. Although very basic one and probably not the | |
#intended use for them, I have used them to solve my problem, with only having read what the try and except keywords did. | |
#My solution to go through every letter of every line, put each letter to a new string if it wasn't a number, and if it was a number, | |
#turn it into a string stating its type, then evaluating if "<type 'int'>-<type 'int'>" was in the new line. | |
def decide(string): | |
q = list(string) | |
for each, point in enumerate(q): | |
try: | |
q[each] = str(type(int(point))) | |
except: | |
q[each] = point | |
m = "".join(q) | |
if "<type 'int'>-<type 'int'>" in m: print(string) | |
for each in range(int(raw_input())): | |
decide(str(raw_input())) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment