r/adventofcode • • Dec 04 '16

SOLUTION MEGATHREAD --- 2016 Day 4 Solutions ---

--- Day 4: Security Through Obscurity ---

Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).


CONSTRUCTING ADDITIONAL PYLONS IS MANDATORY [?]

This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.

edit: Leaderboard capped, thread unlocked!

16 Upvotes

168 comments sorted by

View all comments

Show parent comment

1

u/miran1 Dec 04 '16

names.sort(key=lambda x: (x[0], -ord(x[1])), reverse=True)

Wouldn't it be easier without ord and reversing?

names.sort(key=lambda x: (-x[0], x[1]))

And then you can see that you can simplify even more if you change the line above that:

names = list(set([(-names.count(n), n) for n in names]))
names.sort()    

1

u/taliriktug Dec 04 '16

Yep, you are right, thanks. Sometimes I type horrible code in a hurry. Will fix it asap.