natescode blog

nate's code, blog, projects etc...

Two Crystal Balls Problem

This is a famous software engineering interview question from Google. I thought I’d provide my explanation that is borderline pedantic. Let’s solve this problem as naively as possible then again with nothing more than highschool maths. The Problem There are a few different versions of this question. Sometimes it is crystal balls, or eggs or something else. There is a 100 story building. We have two magic glass orbs. The orbs will only break at or above floor X.

‘This’ That and Dispatch

There are numerous blogs and videos about Javascript’s this keyword. In my opinion, virtually all of them fall short and fail to even mention dispatch or binding. As always, I encourage polyglot programming. So I’ll be showing examples is Javascript, C#, Go and Rust. Back to the basics First, let us cover some really basic but critical Javascript. function greet(name) { console.log(`hello, ${name}`); } function greet() { console.log(`hello, stranger`); } greet("natescode"); Which function is called?