NEW: dynamic Programming ready for prime time
NEW: WORKS
TODO: fix the printing method