From 0e5da5a08105ac626778f40f9e65001106e13696 Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Thu, 11 Apr 2024 03:42:33 +0530 Subject: [PATCH 1/5] hello World #1 --- practice/hello-world/hello_world.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/practice/hello-world/hello_world.py b/practice/hello-world/hello_world.py index adaa6c2..d695ea1 100644 --- a/practice/hello-world/hello_world.py +++ b/practice/hello-world/hello_world.py @@ -1,2 +1,2 @@ def hello(): - return 'Goodbye, Mars!' + return 'Hello, World!' From 95931877024fdd8519820db0b0e83f9b8c16a9e0 Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Thu, 11 Apr 2024 23:48:39 +0530 Subject: [PATCH 2/5] Revert "hello World #1" This reverts commit 0e5da5a08105ac626778f40f9e65001106e13696. --- practice/hello-world/hello_world.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/practice/hello-world/hello_world.py b/practice/hello-world/hello_world.py index d695ea1..adaa6c2 100644 --- a/practice/hello-world/hello_world.py +++ b/practice/hello-world/hello_world.py @@ -1,2 +1,2 @@ def hello(): - return 'Hello, World!' + return 'Goodbye, Mars!' From dd37a3d358be469b5a4d5b692df12b2425e09f2c Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Fri, 12 Apr 2024 12:24:05 +0530 Subject: [PATCH 3/5] secret-handshake --- .../__pycache__/secret_handshake.cpython-39.pyc | Bin 0 -> 484 bytes ...et_handshake_test.cpython-39-pytest-6.2.4.pyc | Bin 0 -> 2791 bytes practice/secret-handshake/secret_handshake.py | 9 ++++++++- 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 practice/secret-handshake/__pycache__/secret_handshake.cpython-39.pyc create mode 100644 practice/secret-handshake/__pycache__/secret_handshake_test.cpython-39-pytest-6.2.4.pyc diff --git a/practice/secret-handshake/__pycache__/secret_handshake.cpython-39.pyc b/practice/secret-handshake/__pycache__/secret_handshake.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..259e5334144ca3201b5a183c538647f8f4d73d26 GIT binary patch literal 484 zcmYjMJx>Bb5S_U@;4~le7p^6wN+p{(wkQ;1b8>ef3r9_W>-}P0Ro?)2g2%tXNTOsG>2a$ z_BOk^U>I=kD^76$Q)|ozeP`5{ei{!4q!sei$jc4leHj3hcjy@F=AkJFngvtT@B?H0rioVGVX1*hSqnOpVn9Z6{w^@rhpqs4C zI-pyu%X*+4)@N&=+iaa}fbOsdY!h^sZLx=-d+ZT=47$&@0o9J$I^m(<`7a3QJb2At za+!w)tX~%V#_c$SzkCehFY-6Z4Q9LrU?bzbiQ52EHI9ATh2kmeB1&IhnW`H|$wmIt zACn*!$nDBdmgMo-6%lQyUjKUZ!|?Z$y~B+0;YeoTkpIa=7|CQf7D1RtAs z@1}vy8fXrH_s3JUjvo}4re~R;ULWz|s>HbbY6;2xx$*ZQ?YY-ImQ7A$zIPe}0%60l zqJ;v976Ls^?dVmDu~d&O(7GGYTf+UW7VZ+md*Jq5_j)~yGs*X+*+lH|DVO!opJ?cM zIK|-4;{q)x|c`QS=5pIzQ)B z21(iaMTNy-t*@*;Up={pu+ps~jmXT2OmHG(=GL=v=UAmP-=Q*(;`oN!ZS&I#t)mra z-CEX6xWKC>Kt_-&Kg^{K56Zx*gvc5m;oaxBs~HDCZJbFN!QER%%hyN^vO3)SmeKq7 z@>wmtW!CrLfi#eZ2CgZr5I$d4P7Ww6;q&brpYLn=l(DpImIYq3pt{rV(CzNoz6g5mLCO*xdN7=cuEC`~dpfy1S$M=3rfiXPF01q3E} zv5w*aicJ)liUe{Jk5J%UFSb$OMP13qIx}NZ77Y-1Qu=x07*1pEXFIkYGw3SkbP~mR zluFe*7*FY}woAuTJjngx%>$SAzTg)k%DHOKnpCT7>wt0Lzd|{aG|I8!Z%F;xxqaN| hSCevHLg!%sZz%-2jDd1~EOzMy2A#x{eQNgX{{Y@oq{jdN literal 0 HcmV?d00001 diff --git a/practice/secret-handshake/secret_handshake.py b/practice/secret-handshake/secret_handshake.py index e3691e1..3bc6fd8 100644 --- a/practice/secret-handshake/secret_handshake.py +++ b/practice/secret-handshake/secret_handshake.py @@ -1,2 +1,9 @@ def commands(binary_str): - pass + actions = ['wink', 'double blink', 'close your eyes', 'jump'] + handshake = [] + for i in range(4): + if binary_str[::-1][i:i+1] == '1': + handshake.append(actions[i]) + if binary_str[0] == '1': + handshake.reverse() + return handshake From 4541e2535e6b9a8de80ec1cc92b049b48072c88f Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Mon, 22 Apr 2024 02:56:25 +0530 Subject: [PATCH 4/5] removed cache files --- .../__pycache__/secret_handshake.cpython-39.pyc | Bin 484 -> 0 bytes ...et_handshake_test.cpython-39-pytest-6.2.4.pyc | Bin 2791 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 practice/secret-handshake/__pycache__/secret_handshake.cpython-39.pyc delete mode 100644 practice/secret-handshake/__pycache__/secret_handshake_test.cpython-39-pytest-6.2.4.pyc diff --git a/practice/secret-handshake/__pycache__/secret_handshake.cpython-39.pyc b/practice/secret-handshake/__pycache__/secret_handshake.cpython-39.pyc deleted file mode 100644 index 259e5334144ca3201b5a183c538647f8f4d73d26..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 484 zcmYjMJx>Bb5S_U@;4~le7p^6wN+p{(wkQ;1b8>ef3r9_W>-}P0Ro?)2g2%tXNTOsG>2a$ z_BOk^U>I=kD^76$Q)|ozeP`5{ei{!4q!sei$jc4leHj3hcjy@F=AkJFngvtT@B?H0rioVGVX1*hSqnOpVn9Z6{w^@rhpqs4C zI-pyu%X*+4)@N&=+iaa}fbOsdY!h^sZLx=-d+ZT=47$&@0o9J$I^m(<`7a3QJb2At za+!w)tX~%V#_c$SzkCehFY-6Z4Q9LrU?bzbiQ52EHI9ATh2kmeB1&IhnW`H|$wmIt zACn*!$nDBdmgMo-6%lQyUjKUZ!|?Z$y~B+0;YeoTkpIa=7|CQf7D1RtAs z@1}vy8fXrH_s3JUjvo}4re~R;ULWz|s>HbbY6;2xx$*ZQ?YY-ImQ7A$zIPe}0%60l zqJ;v976Ls^?dVmDu~d&O(7GGYTf+UW7VZ+md*Jq5_j)~yGs*X+*+lH|DVO!opJ?cM zIK|-4;{q)x|c`QS=5pIzQ)B z21(iaMTNy-t*@*;Up={pu+ps~jmXT2OmHG(=GL=v=UAmP-=Q*(;`oN!ZS&I#t)mra z-CEX6xWKC>Kt_-&Kg^{K56Zx*gvc5m;oaxBs~HDCZJbFN!QER%%hyN^vO3)SmeKq7 z@>wmtW!CrLfi#eZ2CgZr5I$d4P7Ww6;q&brpYLn=l(DpImIYq3pt{rV(CzNoz6g5mLCO*xdN7=cuEC`~dpfy1S$M=3rfiXPF01q3E} zv5w*aicJ)liUe{Jk5J%UFSb$OMP13qIx}NZ77Y-1Qu=x07*1pEXFIkYGw3SkbP~mR zluFe*7*FY}woAuTJjngx%>$SAzTg)k%DHOKnpCT7>wt0Lzd|{aG|I8!Z%F;xxqaN| hSCevHLg!%sZz%-2jDd1~EOzMy2A#x{eQNgX{{Y@oq{jdN From 547f82eea55cdea6b8dc089e2a34c2292535737b Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Mon, 22 Apr 2024 14:37:21 +0530 Subject: [PATCH 5/5] improved the code --- practice/secret-handshake/secret_handshake.py | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/practice/secret-handshake/secret_handshake.py b/practice/secret-handshake/secret_handshake.py index 3bc6fd8..870d121 100644 --- a/practice/secret-handshake/secret_handshake.py +++ b/practice/secret-handshake/secret_handshake.py @@ -1,9 +1,39 @@ def commands(binary_str): + """ + Decodes a binary string into a secret handshake. + + The binary string represents a sequence of actions, where each bit corresponds + to an action from the list ['wink', 'double blink', 'close your eyes', 'jump']. + If the first bit of the binary string is 1, the sequence of actions is reversed. + + Args: + binary_str (str): The binary string to decode. It should contain up to 5 characters. + + Returns: + list: The decoded sequence of actions. + + Raises: + ValueError: If the binary string contains characters other than '0' and '1', + or if it is longer than 5 characters. + + Examples: + >>> commands('101') + ['close your eyes', 'wink'] + """ + if any(c not in '01' for c in binary_str) or len(binary_str) > 5: + raise ValueError('Invalid binary string') + actions = ['wink', 'double blink', 'close your eyes', 'jump'] handshake = [] + + # Iterate over the bits in the binary string, in reverse order for i in range(4): + # If the bit is '1', append the corresponding action to the handshake if binary_str[::-1][i:i+1] == '1': handshake.append(actions[i]) + + # If the first bit of the binary string is '1', reverse the handshake if binary_str[0] == '1': handshake.reverse() - return handshake + + return handshake \ No newline at end of file