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 or 1
  • 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

Stats:

CreatedJan 22, 2023
PublishedJan 22, 2023
Warriors Trained292
Total Skips140
Total Code Submissions86
Total Times Completed9
JavaScript Completions9
Total Stars9
% of votes with a positive feedback rating100% of 5
Total "Very Satisfied" Votes5
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes0
Total Rank Assessments5
Average Assessed Rank
5 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
5 kyu
Ad
Contributors
  • dfhwze Avatar
  • K01egA Avatar
Ad