CATEGORY: Knuth: Blunder (Thinking the right thing but doing it wrong) REFERENCE: https://www.tug.org/TUGboat/tb10-4/tb26knut.pdf EXPLANATION: Even though '--m' is syntactically correct, neither Ruby nor Python support prefix (or postfix) increment/decrement operators. Thus, '--m' is parsed as '-(-m)', resulting in a value that is identical to 'm', just like the expression '------------------m' would do. CONSEQUENCES: The probability numerator is never decremented, so candidate elements will be selected with the wrong (too high) probability. BUGFIX: Decrement 'm' like this: m -= 1 REMARKS: Sometimes, familiar language features from one language are syntactically correct in another, but behave completely differently. For a case where a Python feature caused a bug in C++ code, refer to http://www.approxion.com/?p=596 While unit tests would have certainly revealed this bug, the debugging process would have required unnecessary effort. Performing static code verification before executing unit tests would have saved the effort. Here is the output from Pylint, a popular code checker for Python: genknuth.py|7| Statement seems to have no effect genknuth.py|7| Use of the non-existent -- operator