Skip to content

Instantly share code, notes, and snippets.

@senthil1216
Created November 25, 2015 00:07
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 senthil1216/f1c6771273e9e2e60fc1 to your computer and use it in GitHub Desktop.
Save senthil1216/f1c6771273e9e2e60fc1 to your computer and use it in GitHub Desktop.
#https://www.hackerrank.com/contests/zenhacks/challenges/pairing
N = int(input())
bags = {}
for i in range(N):
_in = input()
sh = _in.split(' ')
tup = (str(sh[0]), sh[1], str(sh[2]))
if tup not in bags:
bags[tup]= []
pairs = bags[tup]
pairs.append(sh[3])
bags[tup] = pairs
arrange = 0
for v in bags.values():
p = {}
for e in v:
cnt = 0
if e in p:
cnt = p[e]
p[e] = cnt + 1
if 'L' not in p:
p['L'] = 0
if 'R' not in p:
p['R'] = 0
arrange += min(p['L'], p['R'])
print(arrange)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment