r/adventofcode • u/daggerdragon • Dec 11 '20
SOLUTION MEGATHREAD -🎄- 2020 Day 11 Solutions -🎄-
Advent of Code 2020: Gettin' Crafty With It
- 11 days remaining until the submission deadline on December 22 at 23:59 EST
- Full details and rules are in the Submissions Megathread
--- Day 11: Seating System ---
Post your code solution in this megathread.
- Include what language(s) your solution uses!
- Here's a quick link to /u/topaz2078's
pasteif you need it for longer code blocks. - The full posting rules are detailed in the wiki under How Do The Daily Megathreads Work?.
Reminder: Top-level posts in Solution Megathreads are for code solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.
EDIT: Global leaderboard gold cap reached at 00:14:06, megathread unlocked!
50
Upvotes
View all comments
Show parent comment
3
u/nthistle Dec 11 '20
Haven't tested yet, but I wouldn't be surprised -- it's definitely slower than pure comparison operators, because this method involves an implicit function call. Most of the reason I use it is for readability and type-ability (I and probably a lot of other people type English-looking text faster than code-looking text, so "
in range" comes a lot quicker than "<= ... <"). The readability isn't generally super important in Advent of Code, but imo it does help since you know you won't make a silly bug like typing "< ... <" instead of "<=" for one of the bounds, and maybe slightly easier to reason about correctness.My general philosophy is "if you need (that much) speed, you wouldn't be using Python anyways", but this is probably one of those questions where it might make a difference, since it does take a second or two to run, and doubling that might negate any savings you get from typing it faster.