fork download
  1. unsigned step(unsigned state, unsigned mask, unsigned pos)
  2. {
  3. unsigned bit1=(mask>>8)&1, bit2=(mask>>7)&1, bit3=(mask>>6)&1,
  4. bit4=(mask>>5)&1, bit5=(mask>>4)&1, bit6=(mask>>3)&1,
  5. bit7=(mask>>2)&1, bit8=(mask>>1)&1, bit9=(mask>>0)&1;
  6. switch (pos)
  7. {
  8. case 1:
  9. state^=bit5<<15;
  10. state^=bit6<<14;
  11. state^=bit8<<11;
  12. state^=bit9<<10;
  13. break;
  14. case 2:
  15. state^=bit4<<15;
  16. state^=bit5<<14;
  17. state^=bit6<<13;
  18. state^=bit7<<11;
  19. state^=bit8<<10;
  20. state^=bit9<<9;
  21. break;
  22. case 3:
  23. state^=bit4<<14;
  24. state^=bit5<<13;
  25. state^=bit6<<12;
  26. state^=bit7<<10;
  27. state^=bit8<<9;
  28. state^=bit9<<8;
  29. break;
  30. case 4:
  31. state^=bit4<<13;
  32. state^=bit5<<12;
  33. state^=bit7<<9;
  34. state^=bit8<<8;
  35. break;
  36. case 5:
  37. state^=bit2<<15;
  38. state^=bit3<<14;
  39. state^=bit5<<11;
  40. state^=bit6<<10;
  41. state^=bit8<<7;
  42. state^=bit9<<6;
  43. break;
  44. case 6:
  45. state^=bit1<<15;
  46. state^=bit2<<14;
  47. state^=bit3<<13;
  48. state^=bit4<<11;
  49. state^=bit5<<10;
  50. state^=bit6<<9;
  51. state^=bit7<<7;
  52. state^=bit8<<6;
  53. state^=bit9<<5;
  54. break;
  55. case 7:
  56. state^=bit1<<14;
  57. state^=bit2<<13;
  58. state^=bit3<<12;
  59. state^=bit4<<10;
  60. state^=bit5<<9;
  61. state^=bit6<<8;
  62. state^=bit7<<6;
  63. state^=bit8<<5;
  64. state^=bit9<<4;
  65. break;
  66. case 8:
  67. state^=bit1<<13;
  68. state^=bit2<<12;
  69. state^=bit4<<9;
  70. state^=bit5<<8;
  71. state^=bit7<<5;
  72. state^=bit8<<4;
  73. break;
  74. case 9:
  75. state^=bit2<<11;
  76. state^=bit3<<10;
  77. state^=bit5<<7;
  78. state^=bit6<<6;
  79. state^=bit8<<3;
  80. state^=bit9<<2;
  81. break;
  82. case 10:
  83. state^=bit1<<11;
  84. state^=bit2<<10;
  85. state^=bit3<<9;
  86. state^=bit4<<7;
  87. state^=bit5<<6;
  88. state^=bit6<<5;
  89. state^=bit7<<3;
  90. state^=bit8<<2;
  91. state^=bit9<<1;
  92. break;
  93. case 11:
  94. state^=bit1<<10;
  95. state^=bit2<<9;
  96. state^=bit3<<8;
  97. state^=bit4<<6;
  98. state^=bit5<<5;
  99. state^=bit6<<4;
  100. state^=bit7<<2;
  101. state^=bit8<<1;
  102. state^=bit9<<0;
  103. break;
  104. case 12:
  105. state^=bit1<<9;
  106. state^=bit2<<8;
  107. state^=bit4<<5;
  108. state^=bit5<<4;
  109. state^=bit7<<1;
  110. state^=bit8<<0;
  111. break;
  112. case 13:
  113. state^=bit2<<7;
  114. state^=bit3<<6;
  115. state^=bit5<<3;
  116. state^=bit6<<2;
  117. break;
  118. case 14:
  119. state^=bit1<<7;
  120. state^=bit2<<6;
  121. state^=bit3<<5;
  122. state^=bit4<<3;
  123. state^=bit5<<2;
  124. state^=bit6<<1;
  125. break;
  126. case 15:
  127. state^=bit1<<6;
  128. state^=bit2<<5;
  129. state^=bit3<<4;
  130. state^=bit4<<2;
  131. state^=bit5<<1;
  132. state^=bit6<<0;
  133. break;
  134. case 16:
  135. state^=bit1<<5;
  136. state^=bit2<<4;
  137. state^=bit4<<1;
  138. state^=bit5<<0;
  139. break;
  140. }
  141. return state;
  142. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty