Last active
August 29, 2015 14:16
-
-
Save cshjin/484f393487b2aedcd761 to your computer and use it in GitHub Desktop.
Code Jam practice - Qualification Round Africa 2010
This file contains hidden or 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
N = int(raw_input()) | |
with open('outfile.txt', 'w') as outfile: | |
for test in range(N): | |
words = raw_input().strip().split(" ") | |
outfile.write("Case #{}: ".format(test + 1) + " ".join(words[::-1]) + "\n") |
This file contains hidden or 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
N = int(raw_input()) | |
with open('outfile.txt', 'w') as outfile: | |
for i in range(N): | |
target = int(raw_input()) | |
size = int(raw_input()) | |
lst = map(int, raw_input().split(" ")) | |
for j in lst: | |
index1 = lst.index(j) + 1 | |
if target - j in lst[index1:]: | |
index2 = lst[index1:].index(target - j) + index1 + 1 | |
# print "Case #{}:".format(i), index1, index2 | |
outfile.write("Case #{}: {} {}".format(i + 1, index1, index2) + "\n") | |
break |
This file contains hidden or 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
N = int(raw_input()) | |
match = {1: [], 2: ["a", "b", "c"], 3: ["d", "e", "f"], | |
4: ["g", "h", "i"], 5: ["j", "k", "l"], 6: ["m", "n", "o"], | |
7: ["p", "q", "r", "s"], 8: ["t", "u", "v"], 9: ["w", "x", "y", "z"], | |
0: [" "]} | |
with open('outfile.txt', 'w') as outfile: | |
for test in range(N): | |
string = raw_input() | |
res = "" | |
for c in string: | |
for x in match: | |
if c in match[x]: | |
if not res.endswith(str(x)): | |
res += str(x) * (match[x].index(c) + 1) | |
else: | |
res += " " | |
res += str(x) * (match[x].index(c) + 1) | |
outfile.write("Case #{}: ".format(test + 1) + res + "\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment