Skip to content

Instantly share code, notes, and snippets.

@neizod
Forked from Python1Liners/LICENSE.txt
Created February 21, 2012 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neizod/1879124 to your computer and use it in GitHub Desktop.
Save neizod/1879124 to your computer and use it in GitHub Desktop.
Store Credit
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())))
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.
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.
{
"name": "store_credit",
"description": "find pair of item that use up all credit.",
"keywords": [
"math",
"pairing",
"codejam"
]
}
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