LOADING: An error occurred. Update Chrome, try Firefox, or visit this post for more details.

⚠️Reddit changed how removals work, which breaks Reveddit's website. Install the extension to track removed content:Add to chromeAdd to firefoxWhat changed?
✖︎
about reveddit
⚙F.A.Q.add-ons
r/
status
copy sharelink
[+] show filters
53
SOLUTION MEGATHREAD-🎄- 2019 Day 4 Solutions -🎄-(self.adventofcode)
submitted 6 years, 1 month ago* (edited 7 minutes after) by daggerdragon to /r/adventofcode (134.8k)
741 commentsredditother-discussionssubreddit-indexmessage modsop-focus

--- Day 4: Secure Container ---


Post your solution using /u/topaz2078's [paste](https://top...

... view full text

since 6 years, 1 month ago
3 of 3

Tip Reveddit Real-Time can notify you when your content is removed.

your account history
(check your username's removed content. why?)
Tip Check if your account has any removed comments.
view my removed comments
you are viewing a single comment's thread.
view all comments
[–]Cloudan297 points6 years, 1 month ago

Python, 1042/3178

Well after looking at this forever because of how many times I got part 2 wrong, I noticed two things

a) If you simply sort digit-wise and compare and they're not the same, that eliminates it

b) If it wasn't eliminated in a), that means that you just need to count the occurrences of the digits to see if it's still legit

Although this isn't my actual code, it's just the super short version with a comment for part 1/2, here we are:

inp = open("inputs/day04.txt")
low, high = [int(num) for num in inp.read().split("-")]

ans = 0
for i in range(low, high):
    password = [int(j) for j in str(i)]
    if password != sorted(password):
        continue

    for digit in password:
        # password.count(digit) == 2 for part 2
        if password.count(digit) >= 2:
            ans += 1
            break

print (ans)

It's super clean and really easy to see what exactly is going on, though it took me a while to figure it out, I'm happy with it. Very clever puzzle.

permalinkhide replies (1)author-focusas-ofpreserve
[–][deleted]3 points6 years, 1 month ago* (edited 6 minutes after)
[deleted] by user
(check your username's removed content. why?)
parenthide replies (1)as-of
[–]Cloudan291 point6 years, 1 month ago

That's really clever, didn't think of that. If I'm not mistaken though, that wouldn't work for part 2. If you had say 222345, you'd still get a hit even though it shouldn't.

permalinkparentcontextauthor-focusas-ofpreserve
r/revedditremoved.substack.com
🚨 NEWS 🚨
✖︎

Important: Reddit Changed How Removals Work

A recent Reddit update makes mod-removed content disappear from profile pages, which breaks Reveddit's website.

Install the browser extension to receive removal alerts.

Add to chromeAdd to firefox

What changed?

r/revedditremoved.substack.com