|
|
|
@ -3,8 +3,8 @@
|
|
|
|
|
### Instructions |
|
|
|
|
|
|
|
|
|
Write a function named `BinaryAddition(int,int)` that takes two integers and returns the sum of the two in binary in an array of `int`. |
|
|
|
|
- If the sum is negative return `nil` value. |
|
|
|
|
- convert the argument to binary then add the two binary numbers together |
|
|
|
|
- If one of the integers is negative return `nil` |
|
|
|
|
- Convert the argument to binary then add the two binary numbers together |
|
|
|
|
|
|
|
|
|
### Expected function |
|
|
|
|
```go |
|
|
|
@ -29,7 +29,7 @@ func main(){
|
|
|
|
|
fmt.Println(BinaryAddition(1, 3)) |
|
|
|
|
fmt.Println(BinaryAddition(2, 1)) |
|
|
|
|
fmt.Println(BinaryAddition(2, 2)) |
|
|
|
|
fmt.Println(BinaryAddition(2, 3)) |
|
|
|
|
fmt.Println(BinaryAddition(1, 16)) |
|
|
|
|
} |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
@ -43,4 +43,5 @@ $ go run .
|
|
|
|
|
[0 1 1] |
|
|
|
|
[1 0 0] |
|
|
|
|
[1 0 1] |
|
|
|
|
[1 0 0 0 0] |
|
|
|
|
``` |
|
|
|
|