5 kyu
[Code Golf] Array Normalisation Puzzle
Description:
Task
Given an array containing bits, can you find out the mysterious normalisation method and output the normalised array?
Input
array
- array containing bits
- a bit can have two possible values:
0
or1
0 ≤ array length ≤ 100
Output
- return the normalised array
- different input arrays can have the same normalised array
- the first two elements of the input array decide the faith of the all bits in the normalised array
- normalisation is a mysterious process which you have to figure out
Code Golf Requirement
- the code length must not exceed
55
characters
Tests
- this is a puzzle, more test cases can be found in the sample tests
[0, 1] -> [1, 0]
[1, 0, 1] -> [0, 1, 0]
[0, 0, 1, 1, 0] -> [1, 1, 0, 1, 0]
[1, 0, 0, 1, 0, 0, 1, 0, 0] -> [0, 1, 0, 0, 0, 1, 0, 1, 0]
- random tests load:
- 50 random tests with 0 ≤ array length ≤ 3
- 50 random tests with 4 ≤ array length ≤ 7
- 50 random tests with 8 ≤ array length ≤ 15
- 50 random tests with 16 ≤ array length ≤ 49
- 100 random tests with 50 ≤ array length ≤ 100
Hints (click to expand)
So you need some hints, eh? Ah well, here you go ..
- bits love to toggle
- patterns love to recur in very small prime sizes
- the first two elements of the input array each start a pattern; one has priority over the other
Puzzles
Algorithms
Arrays
Restricted
Mathematics
Similar Kata:
Stats:
Created | Jan 22, 2023 |
Published | Jan 22, 2023 |
Warriors Trained | 292 |
Total Skips | 140 |
Total Code Submissions | 86 |
Total Times Completed | 9 |
JavaScript Completions | 9 |
Total Stars | 9 |
% of votes with a positive feedback rating | 100% of 5 |
Total "Very Satisfied" Votes | 5 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 5 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 5 kyu |