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
150
SOLUTION MEGATHREAD-🎄- 2022 Day 1 Solutions -🎄-(self.adventofcode)
submitted 3 years, 1 month ago* (edited 3 weeks after) by daggerdragon to /r/adventofcode (134.8k)
1574 commentsredditother-discussionssubreddit-indexmessage modsop-focus

To steal a song from [Olaf](https://static.wikia.nocookie.net/disney/images/5/53/Profile_-_Olaf.jpeg...

... view full text

since 3 years, 1 month ago
11 of 11

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
[–]timvisee6 points3 years, 1 month ago

Rust Quick and simple.

Part 1 0.027ms (27 μs)

Part 2 0.031ms (31 μs)

day01 total: 0.058 ms (58 μs)

permalinkhide replies (4)author-focusas-ofpreserve
[–]miquels2 points3 years, 1 month ago

I found out that trim().split("\n") is a few μs faster than lines() on my machine ... you might be able to get that a few μs faster :)

permalinkparentcontextauthor-focusas-ofpreserve
[–]1b51a8e59cd66a32961f2 points3 years, 1 month ago

Beautiful.

permalinkparentcontextauthor-focusas-ofpreserve
[–]LondonerJP1 point3 years, 1 month ago* (edited 44 minutes after)

Maybe I have the dumb, but running this I get an error:

thread ‘main’ panicked at ‘called ‘Result::unwrap()’ on an ‘Err’ value: ParseIntError { kind: Empty}

Doesn’t seem to like the first unwrap, do you have any idea why?

Edit: it doesn't like split("\n\n"), the inputs are directly off the site with no apparent leading or trailing whitespace, using split_whitespace() no longer errors but obviously the result is incorrect.

permalinkparentcontexthide replies (1)author-focusas-ofpreserve
[–]spunkyenigma2 points3 years, 1 month ago

Did you copy and paste the input on a Windows machine? It’ll add a carriage return if you’re not careful

permalinkparentcontexthide replies (1)author-focusas-ofpreserve
[–]LondonerJP1 point3 years, 1 month ago

I did although \r\n\n also doesn't work and \r\n (obviously) gives the false result I also get with split_whitespace.

First time playing with rust in any real way.

permalinkparentcontexthide replies (1)author-focusas-ofpreserve
[–]spunkyenigma2 points3 years, 1 month ago

/r/n/r/n

This isn’t a Rust thing, just a *nix vs. Windows thing

Oops, slashes are the wrong direction but I don’t want to find it on my phone 😁

permalinkparentcontexthide replies (1)author-focusas-ofpreserve
[–]LondonerJP1 point3 years, 1 month ago

Yeah, cheers mate.

Time to go back to scraping the input, or just using a nix os.

permalinkparentcontexthide replies (1)author-focusas-ofpreserve
[–]spunkyenigma1 point3 years, 1 month ago

Try save as in the browser instead of cut/paste

permalinkparentcontextauthor-focusas-ofpreserve
[–][deleted]1 point3 years, 1 month ago
[deleted] by user
(check your username's removed content. why?)
parenthide replies (1)as-of
[–]timvisee1 point3 years, 1 month ago

Please see https://github.com/timvisee/advent-of-code-2022#timings

It's the best time out of 100 runs, without binary loading overhead from the kernel. Not very scientific.

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