it\'s Friday afternoon, let\'s have a fun puzzle/algorithm problem to solve.
One of my favorite Nintendo DS games is Picross DS. The game is quite simple, it involves so
Here is what I found:
All NP Complete problems have the same feel. It's always easy to solve the next 80% of remaining cases. For example, nanograms decompose into a single lines. One can write a routine, solve_one_line(old_state, line_definition, new_state)
to update what is known about a single line, then keep iterating over rows and columns. Then it fails on a few cases, so you write something to solve 80% of those cases. Then you add random numbers and solve every case you have ever found, but it is possible to construct an optimally bad one.
Other games following this pattern are MineSweeper and Soduku.
Thinking in Parallel is hard. For example, you might figure out that the solve_one_line
routine above will not affect another row if running on a row or another column if running on a column.
Now you get:
all_until_completion(rows):
solve_one_line(...)
all_until_completion(cols):
solve_one_line(...)
This gets you up to running 20 cores (on a 20x20) without data locking or anything. Then you think about running on a graphics card with each cell a processor. Then you notice how much time has passed.
One time I felt old was looking at modern computer science textbook where O(n) notation was replaced with O(n, p) notation because no one would care to evaluate an algorithm for a single processor. The 8 queens solution is a great, fast recursive algorithm with fast-fail, efficient memory use, and only runs on one processor.
Problems are good excuses to play. Grinding out more of the same gets boring. Look through a list of technologies with which you might want more experience: behavior-driven testing; dependency injection; pure functional programming; neural nets; genetic algorithms; fast, sloppy and out of control; GPGPU; OCR; example-driven learning; crowdsourcing; etc. Pick one and try to use it somehow to solve the problem. Sometimes the goal is not to solve the problem but to wander through unknown territory.
Contribute something.* This can be a simple as a write-up. Better might be a repository of hundreds of nanograms so others can play. [Let me know if a repository exists, otherwise I will make one]. Start contributing as soon as you have something you find kind of neat. Heed the Klingon words: Perhaps today is a good day to die; I say we ship it.
So write bizarre, parallel solutions to NP problems and share them. And have a great day!