DEV Community

Cover image for I Tried to Beat Peter Norvig and Accidentally Became Ryan Gosling

I Tried to Beat Peter Norvig and Accidentally Became Ryan Gosling

Thea on August 31, 2026

A few days ago, I posted my submission for the DEV Frontend Challenge: Khachapuri made entirely with HTML and CSS. I was expecting comments about C...
Collapse
 
francistrdev profile image
FrancisTRᴅᴇᴠ (っ◔◡◔)っ

Tried to read the whole article, but my brain keeps getting distracted by the god-tier title you got lol. In other case, great write up!

Collapse
 
highflyer910 profile image
Thea

Lol, if the title distracted you from the actual article, I guess it did its job a little too well 😂 Glad you liked it though! 😊

Collapse
 
georgekobaidze profile image
Giorgi Kobaidze

That’s one hell of a story, really enjoyed reading it.

This is a beautiful example of the difference between optimization and actual algorithmic thinking.

“Make the simulation faster” → “Eliminate the simulation.”

However the Ryan Gosling part, remains outside my current computational model. 😂

By the way, as a Georgian myself, I’ve never heard of the term “არმატურის გოგონა”. I’ve been called “a fake Georgian” a handful of times because I always share content in English, looks like there’s some truth to it.🤣

Collapse
 
highflyer910 profile image
Thea

Lol, then we're both fake Georgians :)) I only post in Georgian on FB, everywhere else it's English, and as a bonus, people regularly assume I'm from Georgia the state 😂

I'm glad you enjoyed the story, and I think it's safer not to try fitting the Gosling part into a computational model. Some things are better left unexplained 😃

Also, I like your "make the simulation faster → eliminate the simulation" summary. That's pretty much the whole adventure in one line 😊

Collapse
 
georgekobaidze profile image
Giorgi Kobaidze

“People regularly assume I’m from Georgia the state” - yeah, classic😄

Keep up bringing these kinds of articles here, I absolutely loved reading it.🔥

Collapse
 
unitbuilds profile image
UnitBuilds

Retry it, but in rust, enforcing zero-alloc. See if you can break the ms mark.

Collapse
 
highflyer910 profile image
Thea

I don't even know Rust 😂 I'll pretend I didn't read this before I lose another weekend to evil boxes!:))

Collapse
 
unitbuilds profile image
UnitBuilds

Well you call the crates, rust's equivalent to packages is crates? Zero-allocation would mean you could theoretically do the task in 1 pass, practically instantly (sub ms). If a cpu runs 4GHz, that means it takes you 400k cpu cycles to do the task, vs it's a task small enough to fit in L1 cache, with zero-alloc, you can likely get it done in an instant (a few microseconds). that is if you represent the crate locations in a binary sequence and the quantities in binary too, at which point you're cpu bound and if you trace back the stacks from end to start like you did for your sequence, you have a set number of steps to finish... Infact, you could maybe (depending how many steps) get it sub microsecond. with 0.25ns per clock, see how close to baremetal you can get?

Goodluck with the weekend lost to evil boxes... 😉🤣 (sorry)

Thread Thread
 
highflyer910 profile image
Thea

Okay, this is exactly how people end up learning Rust against their will 😂

I'm still pretending I didn't read it😌

Thread Thread
 
unitbuilds profile image
UnitBuilds

You got me curious... So I gave it a go, sub 2 microsecond for part 1, 2.3 microsecond for part 2. 3 guesses how 😁 And I might have found a way to optimize it further...

Thread Thread
 
highflyer910 profile image
Thea

Wait WHAT 😀 You actually did it?
Okay, first guess: you did the zero-allocation + binary representation thing you were trying to get me into? 😄

If you manage to optimize it further, I definitely want an update 🍿

Collapse
 
publiflow profile image
PubliFlow

Nice Python content. We built an AI tools suite in Python (FastAPI backend) at tools.shopveigo.com — essay polisher, copywriter, interview coach. If anyone wants to see the architecture, happy to write it up.

Collapse
 
bellatrix profile image
Bellatrix Ouranos

A delightful and genuinely thoughtful piece.

What begins as a playful, reference-laden quest (Ryan Gosling, Ygritte’s eyebrow, Tenet entropy, Sicario’s Juarez) turns into a clean illustration of one of the deepest principles in optimization: the fastest way to move half a billion crates is often not to move them at all.

The progression is especially satisfying. First a correct but slow simulation, then a smarter reference-based approach that still did too much work, and finally the realization that only the final top-of-stack positions mattered. Tracing those few positions backward through the move history reduced the problem from “simulate an absurd number of crate movements” to a constant amount of work per tracked position. The wall-clock time collapsed accordingly.

Even better is the honest admission that the real reward was rediscovering how much fun it can be to struggle with a problem for hours—getting stuck, following half-clues, redrawing the stacks with colored pencils, and refusing to leave the boxes alone until the unnecessary work became obvious. In an era of instant AI suggestions, that kind of prolonged, joyful wrestling feels increasingly rare and valuable.

You started by trying to move the crates faster. You finished by realizing you didn’t need to move them. That’s a better lesson than most algorithm textbooks deliver. Well played.

Collapse
 
highflyer910 profile image
Thea

Thank you, I loved this comment 😊

And yes, I think that was my favorite part too. Not even the final solution, but spending hours being stuck.

And “a better lesson than most algorithm textbooks deliver”... I'll happily take that compliment 😊

Collapse
 
publiflow profile image
PubliFlow

This is a solid Python pattern breakdown. One consideration: the GIL implications for CPU-bound workloads using this approach might surprise people — multiprocessing might be needed even with async.

Collapse
 
divyansh-prks profile image
Divyansh

really liked to reading it thanks for sharing 😀

Collapse
 
highflyer910 profile image
Thea

Thank you! And thanks for making it through this ridiculously long post 😊

Collapse
 
shifa_2 profile image
Shifa

your writing skills are amazing
check out my new post : dev.to/shifa_2/dont-click-this-if-...

Collapse
 
strelok25dev profile image
Любовь Авдеева

From khachapuri to beating ThePrimeagen, outsmarting Norvig, and becoming Ryan Gosling. And the real villain? Not quantum computers. Not hard algorithms. Just your own stubborn need to move boxes😆

Collapse
 
highflyer910 profile image
Thea

Right, the real villain is always our own refusal to let the boxes win! lol📦 Glad you enjoyed the ride!