Created
March 28, 2014 05:40
-
-
Save copyninja/9826095 to your computer and use it in GitHub Desktop.
Code jam Affrical qualification round
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
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