Created
November 25, 2015 00:07
-
-
Save senthil1216/f1c6771273e9e2e60fc1 to your computer and use it in GitHub Desktop.
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
#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