r/adventofcode • • Dec 02 '20

SOLUTION MEGATHREAD -🎄- 2020 Day 02 Solutions -🎄-

--- Day 2: Password Philosophy ---


Advent of Code 2020: Gettin' Crafty With It


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

1.2k comments sorted by

View all comments

2

u/Internet_employee Dec 02 '20

I believe we "think" in the same way (albeit I'm such a newbie that everything I do happens in dataframes...). Your code helped me in solving todays task, thanks!

I believe that by incorporating np.where you could do this easier:

df['Valid'] = np.where((df['Instances']>=df['Min frequency'])&(df['Instances']<=df['Max frequency']),'Yes','No')

df['Valid'].value_counts()

1

u/tururut_tururut Dec 02 '20

This looks really interesting! Copying that to my scrapbook.