fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <algorithm>
  4.  
  5. void convert(const char * in, char * out, char b[8]){
  6. while (*in){
  7. *out = 0;
  8. for (int i = 0; i < 8; i++) if (*in & (1 << b[i])) *out |= (1 << i);
  9. in++;
  10. out++;
  11. }
  12. }
  13.  
  14. char input[] = "Hello, world!";
  15. char pattern[] = "world";
  16. char output[sizeof(input)] = {0};
  17. char bits[8] = {0,1,2,3,4,5,6,7};
  18. int n = 0;
  19.  
  20. int main(){
  21. do{
  22. n++;
  23. convert(input, output, bits);
  24. if (strstr(output, pattern)) printf("%d\t%s\t%d%d%d%d%d%d%d%d\n",n,output,bits[0],bits[1],bits[2],bits[3],bits[4],bits[5],bits[6],bits[7]);
  25. } while(std::next_permutation(bits, bits+8));
  26. printf("%d\n",n);
  27. }
Success #stdin #stdout 0.01s 15232KB
stdin
Standard input is empty
stdout
1	Hello, world!	01234567
3	(elloL@worldA	01234657
40320