Oh hey! It's a problem related to my current job! Let's try to brute force some passwords like real l337 h4xx0rz.
Day 4 - The Problem
Man, the forces of the Holidays have a consistent problem with security. Every year we have to do some basic offensive security work... Santa's forgotten password, most of the obstacles in our assault on Easter Bunny Corp., cracking High Entropy Passwords, sneaking past lazy guards, or some other bad practice.
Part 1 seems complicated at first, but looking at the whole possibility set might shake some things loose.
Part 2 was mainly difficult for me due to the wording. However, once I figured out that there needs to be at least one number that appears exactly twice, then it was all downhill pedaling.
I was beginning to worry that this was going to be a tougher year with a steep ramp-up!
Ongoing Meta
Dev.to List of Leaderboards
-
120635-5c140b9a
- provided by Linda Thompson
If you were part of Ryan Palo's leaderboard last year, you're still a member of that!
If you want me to add your leaderboard code to this page, reply to one of these posts and/or send me a DM containing your code and any theming or notes you’d like me to add. (You can find your private leaderboard code on your "Private Leaderboard" page.)
I'll edit in any leaderboards that people want to post, along with any description for the kinds of people you want to have on it. (My leaderboard is being used as my office's leaderboard.) And if I get something wrong, please call me out or message me and I’ll fix it ASAP.
There's no limit to the number of leaderboards you can join, so there's no problem belonging to a "Beginner" and a language specific one if you want.
Neat Statistics
I'm planning on adding some statistics, but other than "what languages did we see yesterday" does anyone have any ideas?
Languages Seen On Day 03
- Python x 3
- Clojure x 2
- C++
- Haskell
- Javascript
- Kotlin
- PHP
- Scala
- Swift
Latest comments (41)
Solution in Clojure:
Day 4
A javascript walkthrough:
Here's my Ruby attempt for part 1
I was trying to avoid iterating through every number but it seems a little complex
here is my python solution (basically a one-liner):
part1:
part2:
a bit shorter:
I wrote my solution in Zig this time. Funny experiment. Code is a bit ugly and for sure suboptimal, as it usually happens when you try out a language for the first time:
My solutions in Elixir. I'm just posting the final solution for part two since that essentially contains the solution for part one as well. A very nice day to use the power of pattern-matching!
My motto for today is: it's not stupid if it works. I didn't feel like fighting with Rust over "whose characters belong to whom" and "you can't borrow that" and "don't add strings together". Don't judge me.
It's not as good as I wanted it to be, am pretty sure it was possible to solve in a nicer way with regex. But had to do it quickly between meetings so 🤷♀️ Am satisfied though
Part 2 solution
not a fan of my
has_exactly_two_adjacent
method but, hey, it works ¯\_(ツ)_/¯my part 1's
has_two_adjacent
method was a lot nicer:This time I went to bed early and woke up at 4am to do the problem. Oddly, I think that will work better for me! And I found this problem much easier than Day 3.
I had the same issue with the wording of Part Two, so thank you for the interpretive hint.
I have a tendency to write very low-level implementations (without including libs)...partly because I'm not all that familiar with what's available in the Python ecosystem, and partly because I kind of like controlling the nitty gritty!
My solution in JavaScript, with some regex magic.
For the second part, replace
hasGroupOfTwo
withhasGroupOfOnlyTwo
inisCandidate
.Check out my solutions at github.com/MaxArt2501/advent-of-co...
Brute force Python solution:
For me, this was 100x easier than day 3.
Haskell solution
The first part was pretty easy and in the second part I was trying to construct a perfect regex initially so that didn't work out. One thing that stumped me a bit was that in rust
string.split("")
throws a""
at the beginning and the end.I haven't completed Day 3 yet, gonna do that later. I figured out the logic for Day 3 but there's some problem with the implementation.
I've uploaded all my Advent of Code 2019 solutions in rust on a github repo : github.com/coolshaurya/advent_of_c...
Day 3 solution using Rust
Some comments may only be visible to logged-in visitors. Sign in to view all comments.