Login Register


CCC Junior 2016 [challenges] filter_list
Author
Message
RE: CCC Junior 2016 [challenges] #3
(03-06-2016, 04:01 PM)m0dem Wrote: j1 - Tournament Selection
Code:
score = 0 for i in range(0, 6): a = raw_input() if a == "W": score += 1 groups = { 1: [5, 6], 2: [3, 4], 3: [1, 2], } if score in groups[1]: print(1) elif score in groups[2]: print(2) elif score in groups[3]: print(3) else: print(-1)

NOTE: I know I could've made it a lot shorter, but I just wanted it to be organized.

EDIT: Here is the short, ugly code.
Code:
s = 0 for i in range(0, 6): a = raw_input() if a == "W": s += 1 if s in [5, 6]: print(1) elif s in [3, 4]: print(2) elif s in [1, 2]: print(3) else: print(-1)

you can make your short answer shorter by removing extra space. It's also possible to oneline this using tuples and indexing
Code:
print(-1,3,3,2,2,1,1)[[raw_input() for i in xrange(6)].count('W')]
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

[+] 1 user Likes Inori's post
Reply





Messages In This Thread
CCC Junior 2016 [challenges] - by Inori - 02-20-2016, 05:53 AM
RE: CCC Junior 2016 [challenges] - by m0dem - 03-06-2016, 04:01 PM
RE: CCC Junior 2016 [challenges] - by Inori - 03-06-2016, 06:07 PM
RE: CCC Junior 2016 [challenges] - by m0dem - 03-07-2016, 03:47 AM



Users browsing this thread: