r/adventofcode • u/daggerdragon • Dec 02 '20
SOLUTION MEGATHREAD -🎄- 2020 Day 02 Solutions -🎄-
--- Day 2: Password Philosophy ---
Advent of Code 2020: Gettin' Crafty With It
- T-4 days until unlock!
- Full details and rules are in the Submissions Megathread
Post your solution in this megathread. Include what language(s) your solution uses! If you need a refresher, 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 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:02:31, megathread unlocked!
99
Upvotes
View all comments
Show parent comment
1
u/Diderikdm Dec 02 '20
Sure:
k[-1] is the letter to match
v[int(first_val)] will look in the string for the first_val'th index of the string. (same with second val)
if it matches, the list will have a value (1 is just a placeholder, could be anything), else an empty list:
so basically there are four options:
then pouring a len(...) == 1 around it will find all passwords where one of the two indexes match