6 kyu

Exponential-Golomb Decoder

32 of 434obnounce

Description:

Task: Decoding

The task of this kata is to take an exponential-Golomb encoded binary string and return the array of decoded integers it represents.

Encoding

An exponential-Golomb code is a way of representing an integer using bit patterns. To encode any non-negative integer x using the exponential-Golomb code:

  1. Write down x + 1 in binary, without leading zeroes.
  2. Count ( all ) the bits written, subtract one, and add that many zeroes to the front of the bit string.

Example

The value for 3 would be:

3 → 100 ( 3 + 1 in binary ) → 00100 ( 100 with two 0s preceding it )

The value for 22 would be:

22 → 10111 → 000010111

As such, a sequence of nonnegative integers can be represented as sequence of exponential-Golomb codes:

[3, 22, 0, 4, 12] → 00100 000010111 1 00101 0001101

Therefore, for this case, your function should take "001000000101111001010001101" and return [3, 22, 0, 4, 12].

Algorithms

Stats:

CreatedFeb 19, 2020
PublishedFeb 19, 2020
Warriors Trained1127
Total Skips45
Total Code Submissions1038
Total Times Completed434
Swift Completions32
JavaScript Completions135
Python Completions207
Haskell Completions21
Elixir Completions7
Java Completions38
TypeScript Completions31
Total Stars26
% of votes with a positive feedback rating95% of 119
Total "Very Satisfied" Votes110
Total "Somewhat Satisfied" Votes7
Total "Not Satisfied" Votes2
Total Rank Assessments12
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • obnounce Avatar
  • JohanWiltink Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • Schulzkafer Avatar
  • MobulaKuhlii Avatar
  • Reargem Avatar
Ad