According to this Code Jam problem, I try to made it in one line.
-
-
Save neizod/1879124 to your computer and use it in GitHub Desktop.
Store Credit
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
credit = '\n'.join('Case #{}: {} {}'.format(test+1, *[i[0]+1 for c in (lambda x, y: (x,))(int(input()), int(input())) for i, l in (lambda x: zip(enumerate(e for e in x), [x for e in x]))([int(v) for v in input().split()]) for j in enumerate(l) if i[1] + j[1] == c and i[0] != j[0]]) for test in range(int(input()))) |
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
credit = '\n'.join( | |
'Case #{}: {} {}'.format( | |
test+1, | |
*[i[0]+1 for c in (lambda x, y: (x,))(int(input()), int(input())) # init credit | |
for i, l in (lambda x: zip( | |
enumerate(e for e in x), # 1st item | |
[x for e in x]))([int(v) for v in input().split()]) | |
for j in enumerate(l) # 2nd item | |
if i[1] + j[1] == c and i[0] != j[0]]) # check if 1st + 2nd | |
for test in range(int(input()))) # use all the credit. |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2012 Nattawut Phetmak <http://about.me/neizod> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. |
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
{ | |
"name": "store_credit", | |
"description": "find pair of item that use up all credit.", | |
"keywords": [ | |
"math", | |
"pairing", | |
"codejam" | |
] | |
} |
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
credit = '\n'.join('Case #{}: {} {}'.format(test+1, *[i[0]+1 for c in (lambda x, y: (x,))(int(input()), int(input())) for i, l in (lambda x: zip(enumerate(e for e in x), [x for e in x]))([int(v) for v in input().split()]) for j in enumerate(l) if i[1] + j[1] == c and i[0] != j[0]]) for test in range(int(input()))) | |
# stdin: | |
# 3 | |
# 100 | |
# 3 | |
# 5 75 25 | |
# 200 | |
# 7 | |
# 150 24 79 50 88 345 3 | |
# 8 | |
# 8 | |
# 2 1 9 4 4 56 90 3 | |
expected = '''Case #1: 2 3 | |
Case #2: 1 4 | |
Case #3: 4 5''' | |
print(expected) | |
print(credit) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment