fork download
  1. #include <stdint.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. // A helper function, which is performed very very rare.
  6. void SaveCode (const uint8_t length, const uint64_t code);
  7.  
  8.  
  9. int main (int argc, char * argv [])
  10. {
  11. const uint32_t sideLobeLimit= 1;
  12. const uint32_t length = 13;
  13.  
  14. const uint64_t mask = (1ull << length) - 1ull;
  15. uint64_t code = 1ull << (length - 1ull);
  16. do {
  17. uint32_t shift = 1;
  18. do {
  19. if (abs ( (__builtin_popcountll ( (code & (mask >> shift) ) ^ (code >> shift) ) << 1) - length + shift) > sideLobeLimit) {
  20. goto NEXT_CODE;
  21. }
  22. }
  23. while (++shift < length);
  24. SaveCode (length, code);
  25. NEXT_CODE:;
  26. }
  27. while (++code <= (1ull << length) - 1ull);
  28.  
  29. return EXIT_SUCCESS;
  30. }
  31.  
  32.  
  33. void SaveCode (const uint8_t length, const uint64_t code)
  34. {
  35. uint8_t i = 0;
  36. for (i = 0; i < length; ++i) {
  37. (code >> i) & 0x01 ? printf ("+") : printf ("-");
  38. }
  39. printf ("\n");
  40. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
+++++--++-+-+
+-+-++--+++++