#include <stdio.h> #include <stdint.h> uint8_t is_circular_match(uint16_t reg, uint16_t target) { // Your code here uint16_t reg1; uint8_t n=0; if (reg==target){ return 1; } n=1; while (n<16) { uint16_t extract = 0; for (int i=15;i>15-n;i--){ extract|= ((((reg>>i) & 1)<<(i-(16-n))); } reg1 = (uint16_t)((reg<<n) | extract); if (reg1==target) return 1; n+=1; } return 0; } int main() { uint16_t reg, target; scanf("%hu %hu", ®, &target); printf("%hhu", is_circular_match(reg, target)); return 0; }
Test Cases
Test Results
Input
45056 11
Expected Output
1