3 ms·
My father was working on a math puzzle, and he asked me if I had any insight into it. I said that it would take me days or weeks of remembering/relearning to ha
by dsr_ 6y ago
My father was working on a math puzzle, and he asked me if I had any insight into it. I said that it would take me days or weeks of remembering/relearning to have any hope of solving it cleverly -- but the search space for the answers was only factorial(10) possibilities, so I could write a program to brute force it.
I did. 30 minutes of code writing (of which about 20 was spent making sure I didn't miss something) and then less than 3 seconds of computing time later, I had the answer for him. Nothing clever at all -- just trying all the possibilities and seeing if that set fit.
- pfdietz 6y agoSMT solvers are also fun for that sort of thing.
- eru 6y agoInteger linear programming solvers, too.
- eru 6y agoThat's sometimes fun. But I also had lots of fun solving eg the first few Project Euler challenges with some math and pen and paper. (And sometimes a desktop calculator.) Eg https://projecteuler.net/problem=2 https://projecteuler.net/problem=2 "By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms." has a nice (almost) closed form solution that you only need a few integer multiplications and additions to evaluate.