RE: CCC Junior 2016 [challenges] 03-06-2016, 06:07 PM
#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.
don't have much in the first place, who feel the new currents and ride them the farthest.















![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)