I hope this fine morning finds you well, saars.
The word of the day is collections.Counter
The rdrama leaderboard invite code is 632268-30587026
I created the ping group: !AOC, I'm sure it will be useful offseason too.
Charts! https://github.com/jeroenheijmans/advent-of-code-charts
Jump in the discussion.
No email address required.
Every time I have to use loops I feel like shit, because that is where you get performance bottlenecks. But then I realized I don't have to submit any actual code and just did what came most natural. I am not comfortable with Python and have to relearn shit every time I use it.
The scoring on this seems a little sleep-phobic, not gonna lie. This solution is a little ungabunga, I think I could have avoided one loop if I knew how to python better.
Jump in the discussion.
No email address required.
Read other people's code and learn from it. Python is a remarkably nice language, pretty much every time you feel like shit for writing verbose code, that's a red flag telling you that there's a way to write it five times shorter and more to the point.
Jump in the discussion.
No email address required.
More options
Context
If you really care,
could be
or
but in principle they're all for loops. Whatever obscure performance benefits one syntax might offer isn't worth worrying about. Readability is king in python.
Jump in the discussion.
No email address required.
More options
Context
dict
hasget
andsetdefault
methods that deal with nonexistent keys in a streamlined fashion. Socolumn2Dict[i] = column2Dict.get(i, 0) + 1
would work. Even better, usecollections.Counter
which does all that for you, see my code in a comment here.Jump in the discussion.
No email address required.
More options
Context
Then dont do it
Jump in the discussion.
No email address required.
I'm like this but for every language I use. I assumed this was just part of the Process?
Jump in the discussion.
No email address required.
Oh ok I thought you had some hangup on python specifically
Jump in the discussion.
No email address required.
I'm not the person in the picture.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context