id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > test2021_01_15_APP1SLHL_binaryAdd
prev  |  next  |  chance

Write a method that accepts arrays of binary digits 'digitA' and 'digitB' (each array will have the same length and each element will either be a 0 or a 1). Return an array representing the binary sum of the digits from the two arrays. 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 a length one greater than the length of the input arrays. Because of the order of significance, the array {0,0,0,1,0,1} represents the binary number 101000. These numbers will represent UNSIGNED binary numbers. Look at the test data for examples.


test2021_01_15_APP1SLHL_binaryAdd([1], [0]) → [1, 0]
test2021_01_15_APP1SLHL_binaryAdd([1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0]) → [0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0]
test2021_01_15_APP1SLHL_binaryAdd([1, 1, 1, 1], [1, 1, 1, 1]) → [0, 1, 1, 1, 1]

...Save, Compile, Run (ctrl-enter)

public int[] test2021_01_15_APP1SLHL_binaryAdd(int[] digitsA, int[] digitsB) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 210

Copyright Nick Parlante 2017 - privacy