Back
Close

Doubles Trick

Statement

 Goal

To make the powers of 2 you start with 1 and keep multiplying by 2 (1, 2, 4, 8, 16...). The trick is that if you have all of these numbers, you can make every whole number just by adding some of them together!

For example: if you have the numbers 1, 2, 4, and 8, you can make all the numbers all the way to 15 (8+4+2+1) by putting some of these numbers together. For example, you can make 11 with 1, 2, and 8.

Output the powers of 2, space seperated and in ascending order, used to make number

Example:
If number is 25, output "1 8 16".
Input
Line 1: An integer number for the number you need to target.
Output
space separated list of doubles that add to number
Constraints
1 ≤ number ≤ 1024
Example
Input
25
Output
1 8 16

Game modes
FastestShortestReverse

Test cases
Example Test
Input
25
Output
1 8 16

Validator 1 Validator
Input
13
Output
1 4 8

Double Test
Input
4
Output
4

Validator 2 Validator
Input
8
Output
8

Small, but lots needed. Test
Input
7
Output
1 2 4

Validator 3 Validator
Input
15
Output
1 2 4 8

Big, but little needed Test
Input
513
Output
1 512

Validator 4 Validator
Input
260
Output
4 256

Solution language

Solution

Stub generator input
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants