about | help | code help+videos | done | prefs |
Write a method that accepts an array of binary digits 'digits' (each element in the array will either be a 0 or a 1). Return an array representing the one's complement of the binary number represented by the array. Note that index 0 represents the LEAST significant digit, and the highest index represents the MOST significant digit, so as the index increases the significance level of the digit in that location increases. Return the result as a new array which will always have the same length as the input array. Because of the order of significance, the array {0,0,0,1,0,1} represents the binary number 101000. These numbers will represent SIGNED binary numbers using the one's complement method of encoding. Look at the test data for examples. test2021_01_15_APP1SLHL_onesComp([0, 0, 0, 1, 0, 1, 0]) → [1, 1, 1, 0, 1, 0, 1] test2021_01_15_APP1SLHL_onesComp([1, 0, 0, 0]) → [0, 1, 1, 1] test2021_01_15_APP1SLHL_onesComp([0, 1, 0, 0, 1]) → [1, 0, 1, 1, 0] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 240
Copyright Nick Parlante 2017 - privacy