6 kyu

Santa's Missing Gift List

361 of 626omegahm

Description:

Santa has misplaced his list of gift to all the children, he has however a condensed version lying around.

In this condensed verison, instead of a list of gifts for each child, each one has an integer.

He also have a list of gifts corresponding to each integer. His list is as follows:

GIFTS = {
    1 => 'Toy Soldier',
    2 => 'Wooden Train',
    4 => 'Hoop',
    8 => 'Chess Board',
   16 => 'Horse',
   32 => 'Teddy',
   64 => 'Lego',
  128 => 'Football',
  256 => 'Doll',
  512 => "Rubik's Cube"
}
GIFTS = {
  1: 'Toy Soldier',
  2: 'Wooden Train',
  4: 'Hoop',
  8: 'Chess Board',
  16: 'Horse',
  32: 'Teddy',
  64: 'Lego',
  128: 'Football',
  256: 'Doll',
  512: "Rubik's Cube"
}

This list is made available to you, as GIFTS.

The integer for each child is such that the child should get the highest toy lower than or equal to that integer, and then, if there's more left, also get the highest toy lower than the rest and so on. Know that Santa never gives the same gift twice.

For example, by Timmy's name is 160. This means that Timmy should get both a football and a teddy, because 128 + 32 = 160.

You should help Santa by decoding his own list and recreate the missing list for him. Santa's elf wants the list sorted alphabetically by the toys, so you should help them as well and list the toys in a sorted order.

Binary
Algorithms

More By Author:

Check out these other kata created by omegahm

Stats:

CreatedDec 7, 2015
PublishedDec 7, 2015
Warriors Trained1107
Total Skips33
Total Code Submissions2039
Total Times Completed626
Ruby Completions87
Python Completions361
JavaScript Completions203
Total Stars32
% of votes with a positive feedback rating96% of 191
Total "Very Satisfied" Votes177
Total "Somewhat Satisfied" Votes12
Total "Not Satisfied" Votes2
Total Rank Assessments12
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • omegahm Avatar
  • St3f4n Avatar
  • user5036852 Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad