r/programming • • May 08 '15

Five programming problems every Software Engineer should be able to solve in less than 1 hour

https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour
2.5k Upvotes

2.1k comments sorted by

View all comments

Show parent comments

28

u/WeAreAllApes May 08 '15 edited May 08 '15

It takes a few minutes if you approach it this way.

Edit:updated to point to the working version... also note that it runs in a split second because 6561 iterations is not that much for a computer these days.

8

u/[deleted] May 08 '15

c = Math.floor(c / 3);

I feel like I should intuitively know why this works, but it still feels like magic.

0

u/[deleted] May 08 '15

[deleted]

2

u/[deleted] May 08 '15

I think it's basically like chewing through a base 3 number with the character values "", "+" and "-"; where with base 10, you would divide by 10 to hop digits for modular division instead. Or something.

→ More replies (2)