Skip to content

Commit

Permalink
Solution to 67
Browse files Browse the repository at this point in the history
  • Loading branch information
QueensleyC committed Dec 12, 2024
1 parent a29782d commit 5e01a5d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/unresolved/67.add-binary.jl → src/problems/67.add-binary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,17 @@
## @lc code=start
using LeetCode

function add_binary(a::String, b::String)

num1 = parse(Int64, a; base=2)
num2 = parse(Int64, b; base=2)

sum = num1 + num2

return string(sum, base=2)

end


## add your code here:
## @lc code=end
16 changes: 16 additions & 0 deletions test/problems/67.add-binary.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Test
@testset "67.add-binary.jl" begin

@test add_binary("0", "0") == "0"
@test add_binary("1", "1") == "10"
@test add_binary("1010", "1011") == "10101"
@test add_binary("110", "11") == "1001"
@test add_binary("1111", "1111") == "11110"
@test add_binary("0", "101") == "101"
@test add_binary("100000", "1") == "100001"
@test add_binary("111111", "1") == "1000000"
@test add_binary("101010", "110110") == "1100000"
@test add_binary("1000000000", "1000000000") == "10000000000"


end

0 comments on commit 5e01a5d

Please sign in to comment.