#include <stdio.h> #include <stdint.h> uint8_t compress_bits(uint16_t val) { uint8_t final_val; for(int i=0;i<8;i++){ final_val |= ((val&0x01)<<(i)); val = val>>2; } return final_val; } 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