Unable to execute. One example of a counter is 0/100 and 4/96. Both of these amounts to 100 and xor to 100.
Therefore, given the sum of 100 and the result of xor out of 100, you cannot know which of the possibilities generated these two numbers.
For what it's worth, this program only checks capabilities with the number 0..255 :
#include <stdio.h> static void output (unsigned int a, unsigned int b) { printf ("%u:%u=%u %u\n", a+b, a^b, a, b); } int main (void) { unsigned int limit = 256; unsigned int a, b; output (0, 0); for (b = 1; b != limit; b++) output (0, b); for (a = 1; a != limit; a++) for (b = 1; b != limit; b++) output (a, b); return 0; }
Then you can take this conclusion and massage it to give you all the repetitive possibilities:
testprog | sed 's/=.*$//' | sort | uniq -c | grep -v ' 1 '
which gives:
7 100:100 2 100:16 4 100:18 2 100:2 4 100:20 4 100:24 8 100:26 2 100:4 2 100:64 4 100:66 4 100:68 4 100:80 8 100:82 8 100:84 8 100:88 16 100:90
etc.
Even in this reduced set, there are quite a few combinations that generate the same amount / xor, the worst of which is the large number of possibilities that generate the amount / xor 255/255, some of which are:
255:255=0 255 255:255=1 254 255:255=2 253 255:255=3 252 255:255=4 251 255:255=5 250 255:255=6 249 255:255=7 248 255:255=8 247 255:255=9 246 255:255=10 245 255:255=11 244 255:255=12 243 255:255=13 242 255:255=14 241 255:255=15 240 255:255=16 239 255:255=17 238 255:255=18 237
source share