Skip to content

Instantly share code, notes, and snippets.

@copyninja
Created March 28, 2014 05:40
Show Gist options
  • Save copyninja/9826095 to your computer and use it in GitHub Desktop.
Save copyninja/9826095 to your computer and use it in GitHub Desktop.
Code jam Affrical qualification round
import collections
def process(line, case):
words = line.split(' ')
n = len(words)
output = "Case #" + str(case) + ": "
if n == 1:
return output + words[0]
for i in range(n):
output += words[n -1-i] + " "
return output
def process2(line, case):
words = line.split(' ')
output = "Case #" + str(case) + ":"
words.reverse()
return output + " ".join(words)
def process3(line, case):
dq = collections.deque(line.split(' '))
dq.reverse()
return "Case #" + str(case) + ": " + " ".join((list(reversed(dq))))
def main():
with open("B-large-practice.in", "r") as fd:
n = fd.readline().strip('\n')
for i in range(int(n)):
print(process(fd.readline().strip('\n'), i + 1))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment