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

59

u/timeshifter_ May 08 '15

It'd be piss-easy to solve with brute force JS. Just create every possible valid string combination of those 9 digits with + and -, and eval() them for whichever ones come out to be 100.

11

u/Backfiah May 08 '15

That's 9! runs though.

50

u/anttirt May 08 '15

between the numbers 1, 2, ..., 9 (in this order)

The original problem is only on the order of 38 steps brute-forced.

2

u/AcidDrinker May 08 '15 edited Dec 14 '15

Here's a simple solution in C : {{ LINK REMOVED }}

→ More replies (2)