#include <stdio.h> #include <stdint.h> uint8_t compress_bits(uint16_t val) { // Your logic here uint8_t ans = 0; for (int i=0; i<15; i++){ if (i%2 ==0){ int bit = (val >> i)&1; ans |= (bit << (i/2)); } } return ans; } int main() { uint16_t val; scanf("%hu", &val); uint8_t result = compress_bits(val); printf("%u", result); return 0; }
Test Cases
Test Results
Input
20548
Expected Output
202