#include <stdio.h> #include <stdint.h> uint8_t compress_bits(uint16_t val) { // Your logic here int n=0; uint8_t res=0; uint8_t tmp=0; uint8_t i=0; while (n<16){ tmp=val&1; if (n%2==0){ res|=tmp<<i; i++; } val>>=1; n++; } return res; } 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