Skip to content

Commit d13411b

Browse files
committed
adding binary algo
1 parent a31173d commit d13411b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from typing import List, Union, Collection, Mapping, Optional
2+
from abc import ABC, abstractmethod
3+
4+
class Solution:
5+
def addBinary(self, a: str, b: str) -> str:
6+
return bin(int(a,2) + int(b,2))[2:]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import unittest
2+
from src.my_project.interviews.top_150_questions_round_12\
3+
.add_binary import Solution
4+
5+
6+
class AddBinaryTestCase(unittest.TestCase):
7+
8+
def test_add_binary(self):
9+
solution = Solution()
10+
output = solution.addBinary(a="11", b="1")
11+
target = "100"
12+
self.assertEqual(output, target)

0 commit comments

Comments
 (0)