#include <stdio.h> #include <stdint.h> uint16_t spread_bits(uint8_t val) { // Your logic here uint16_t result = 0x00; if (val == 0) return 0; int x = 7; while(1) { //scan every bit if(val & (1 << x)) { //only even numbers should have input result |= (1 << x*2); } if (x <= 0) { return result; break; } x--; } } int main() { uint8_t val; scanf("%hhu", &val); uint16_t result = spread_bits(val); printf("%u", result); return 0; }
Test Cases
Test Results
Input
202
Expected Output
20548