Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # source: https://code.google.com/codejam/contest/3224486/dashboard#s=p0
- # finished in a bit under 25 minutes
- import sys
- def main():
- filename = sys.argv[1]
- with open(filename) as f:
- num_inputs = int(f.readline())
- for i in range(num_inputs):
- score = 0
- problems = []
- moods = f.readline()
- for j in range(len(moods)):
- # the assumption is that you'll only request problems that're the same mood that the grader is in
- # reason being that you can receive a maximum of 10 points and a minimum of 5,
- # whereas for the other mood it'll be a max of 5 and a min of 0
- if len(problems) == 0:
- problems.append(moods[j])
- elif len(problems) >= len(moods) - j:
- if problems[-1] == moods[j]:
- score += 10
- else:
- score += 5
- problems.pop()
- elif problems[-1] == moods[j]:
- score += 10
- problems.pop()
- else:
- problems.append(moods[j])
- print('Case #', i+1, ': ', score, sep='')
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment