#include <stdio.h> #include <stdint.h> uint8_t set_bits(uint16_t reg){ int count = 0; int i = 31; while(i >= 0){ uint8_t temp = ((reg >> i) & 1); if(temp == 1){ count++; } i--; } return count; } uint8_t is_circular_match(uint16_t reg, uint16_t target) { // wrong solution if(set_bits(reg) == set_bits(target)){ return 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