Image by Divina Epiphania on Shutterstock

Go Brain Teaser

A Hefty Bonus

Miki Tebeka
The Pragmatic Programmers
3 min readSep 14, 2021

--

📚 Connect with us. Want to hear what’s new at The Pragmatic Bookshelf? Sign up for our newsletter. You’ll be the first to know about author speaking engagements, books in beta, new books in print, and promo codes that give you discounts of up to 40%.

Scrooge McDuck is feeling funny — it’s the holiday season, and he wants you to pay a bonus to all employees (not including yourself, of course). You’ll need to use your Go programming skills to update the payroll system.

Here’s the code you come up with:

You run the code and are surprised to see the following output:

What, no bonus? Why Go? Why!? It’s the holidays and you want to go home.

--

--