sudofox's journal

Austin Burk's journal, where I share little snippets of my writing, code, and dreams.

Hatena Intern 2023 challenge solution

I solved the remote internship puzzle.

 

I took a simple brute-force approach.

async function main() {
  let result;
  for(let i = 0; i < 10000; i++) {
    let code = i.toString().padStart(4, "0");
    try {
      result = await unlock(code);
      console.log(`Found code: ${code}`);
      return result;
    } catch (error) {
      // continue...
    }
  }
  throw new Error("No valid code found");
}

main().catch(e => console.error(e));

The solution was...

8107

(If I lived in Japan, I would apply.)