![]() If what you're really after is a better algorithm, then that's a different problem.ĭon't use std::endl if ' n' will do Using std::endl emits a n and flushes the stream. Don't optimize blindly First, we should keep in mind what Donald Knuth has said about optimization: 'The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times premature optimization is the root of all evil (or at least most of it) in programming.' Your particular program probably spends 99% of its time doing I/O, so the performance differences among possible alternatives is probably best approximated as zero. It has no intelligence and does not, in any sense, know anything about the cube it purports to solve.Ī better solver might keep a model of the scrambled cube to track its state. ![]() Rethink your object design Right now, the Solver object simply holds two dozen static strings. Don't abuse using namespace std Putting using namespace std at the top of every program is that you'd do well to avoid. Here are some things that may help you improve your code.
0 Comments
Leave a Reply. |