All sentences (so far) require six comparisons per input string, which is optional. Numbers come in as strings, so use string comparisons.
Start with @Armen Tsirunyan's idea:
Pre-calculate all target numbers, in this case 223456, 133456, 124456, 123556, 123466, 123457.
But instead of single comparisons, do this in a line:
string arg = "223456 133456 124456 123556 123466 123457";
Then read the input (either from a file or into memory). Pseudocode:
foreach (string s in theBigListOfNumbers) if (arg.indexOf(s) == -1) print s;
This is just one comparison for each line of input, without dictionaries, maps, iterators, etc.
Edited to add:
On processors with the x86 instruction set (and not just on the Intel brand), finding a substring like this is very fast. For example, finding a character inside a string is just one machine instruction.
I have to ask others to weigh on alternative architectures.
egrunin
source share