From 7fb6327b704f23119267bc7730ec7af5b3e35c1d Mon Sep 17 00:00:00 2001 From: luciferx48 Date: Thu, 13 Oct 2022 14:51:41 +0530 Subject: [PATCH 1/7] even_or_not file added --- bit_manipulation/even_or_not.py | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 bit_manipulation/even_or_not.py diff --git a/bit_manipulation/even_or_not.py b/bit_manipulation/even_or_not.py new file mode 100644 index 000000000000..2b8796e1714b --- /dev/null +++ b/bit_manipulation/even_or_not.py @@ -0,0 +1,40 @@ +def is_even(number: int) -> bool: + """ + return true if the input integer is even + Explanation: Lets take a look at the following deicmal to binary conversions + 2 => 10 + 14 => 1110 + 100 => 1100100 + 3 => 11 + 13 => 1101 + 101 => 1100101 + from the above examples we can observe that + for all the odd integers there is always 1 set bit at the end + also, 1 in binary can be represented as 001, 00001, or 0000001 + so for any odd integer n => n&1 is always equlas 1 else the integer is even + + >>> is_even(1) + False + >>> is_even(4) + True + >>> is_even(9) + False + >>> is_even(15) + False + >>> is_even(40) + True + >>> is_even(100) + True + >>> is_even(101) + False + """ + if number & 1 == 0: + return True + else: + return False + + +if __name__ == "__main__": + import doctest + + doctest.testmod() From ab206a02741258f369649ebe549c645565497246 Mon Sep 17 00:00:00 2001 From: luciferx48 Date: Thu, 13 Oct 2022 16:11:50 +0530 Subject: [PATCH 2/7] Updated DIRECTORY.md --- DIRECTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index 25272af4a708..8291005bbc03 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -45,6 +45,7 @@ * [Gray Code Sequence](bit_manipulation/gray_code_sequence.py) * [Reverse Bits](bit_manipulation/reverse_bits.py) * [Single Bit Manipulation Operations](bit_manipulation/single_bit_manipulation_operations.py) + * [Identify Even Integer](bit_manipulation/even_or_not.py) ## Blockchain * [Chinese Remainder Theorem](blockchain/chinese_remainder_theorem.py) From 20b5a991bc5d7a3653812a5d1c1a35fd84f8fb71 Mon Sep 17 00:00:00 2001 From: luciferx48 Date: Thu, 13 Oct 2022 16:30:46 +0530 Subject: [PATCH 3/7] modified DIRECTORY.md --- DIRECTORY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index 8291005bbc03..4ecbcc676719 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -43,9 +43,9 @@ * [Count 1S Brian Kernighan Method](bit_manipulation/count_1s_brian_kernighan_method.py) * [Count Number Of One Bits](bit_manipulation/count_number_of_one_bits.py) * [Gray Code Sequence](bit_manipulation/gray_code_sequence.py) + * [Identify Even Integer](bit_manipulation/even_or_not.py) * [Reverse Bits](bit_manipulation/reverse_bits.py) * [Single Bit Manipulation Operations](bit_manipulation/single_bit_manipulation_operations.py) - * [Identify Even Integer](bit_manipulation/even_or_not.py) ## Blockchain * [Chinese Remainder Theorem](blockchain/chinese_remainder_theorem.py) From dc1cb60f3685e4bfed17cb920acdd76945108402 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 23 Oct 2022 14:44:08 +0200 Subject: [PATCH 4/7] Update bit_manipulation/even_or_not.py --- bit_manipulation/even_or_not.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bit_manipulation/even_or_not.py b/bit_manipulation/even_or_not.py index 2b8796e1714b..b7b0841a1427 100644 --- a/bit_manipulation/even_or_not.py +++ b/bit_manipulation/even_or_not.py @@ -28,10 +28,7 @@ def is_even(number: int) -> bool: >>> is_even(101) False """ - if number & 1 == 0: - return True - else: - return False + return number & 1 == 0 if __name__ == "__main__": From 1e12407447d13a92824264007e7b1539bf6984a6 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Sun, 23 Oct 2022 12:44:25 +0000 Subject: [PATCH 5/7] updating DIRECTORY.md --- DIRECTORY.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index 0c23676ca496..376264853ed6 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -42,8 +42,8 @@ * [Binary Xor Operator](bit_manipulation/binary_xor_operator.py) * [Count 1S Brian Kernighan Method](bit_manipulation/count_1s_brian_kernighan_method.py) * [Count Number Of One Bits](bit_manipulation/count_number_of_one_bits.py) + * [Even Or Not](bit_manipulation/even_or_not.py) * [Gray Code Sequence](bit_manipulation/gray_code_sequence.py) - * [Identify Even Integer](bit_manipulation/even_or_not.py) * [Reverse Bits](bit_manipulation/reverse_bits.py) * [Single Bit Manipulation Operations](bit_manipulation/single_bit_manipulation_operations.py) @@ -53,6 +53,7 @@ * [Modular Division](blockchain/modular_division.py) ## Boolean Algebra + * [Norgate](boolean_algebra/norgate.py) * [Quine Mc Cluskey](boolean_algebra/quine_mc_cluskey.py) ## Cellular Automata @@ -449,6 +450,7 @@ * [Random Forest Classifier](machine_learning/random_forest_classifier.py) * [Random Forest Regressor](machine_learning/random_forest_regressor.py) * [Scoring Functions](machine_learning/scoring_functions.py) + * [Self Organizing Map](machine_learning/self_organizing_map.py) * [Sequential Minimum Optimization](machine_learning/sequential_minimum_optimization.py) * [Similarity Search](machine_learning/similarity_search.py) * [Support Vector Machines](machine_learning/support_vector_machines.py) @@ -587,9 +589,11 @@ * [Two Sum](maths/two_sum.py) * [Ugly Numbers](maths/ugly_numbers.py) * [Volume](maths/volume.py) + * [Weird Number](maths/weird_number.py) * [Zellers Congruence](maths/zellers_congruence.py) ## Matrix + * [Binary Search Matrix](matrix/binary_search_matrix.py) * [Count Islands In Matrix](matrix/count_islands_in_matrix.py) * [Inverse Of Matrix](matrix/inverse_of_matrix.py) * [Matrix Class](matrix/matrix_class.py) @@ -855,8 +859,6 @@ * [Sol1](project_euler/problem_101/sol1.py) * Problem 102 * [Sol1](project_euler/problem_102/sol1.py) - * Problem 104 - * [Sol](project_euler/problem_104/sol.py) * Problem 107 * [Sol1](project_euler/problem_107/sol1.py) * Problem 109 @@ -1011,6 +1013,7 @@ * [Alternative String Arrange](strings/alternative_string_arrange.py) * [Anagrams](strings/anagrams.py) * [Autocomplete Using Trie](strings/autocomplete_using_trie.py) + * [Barcode Validator](strings/barcode_validator.py) * [Boyer Moore Search](strings/boyer_moore_search.py) * [Can String Be Rearranged As Palindrome](strings/can_string_be_rearranged_as_palindrome.py) * [Capitalize](strings/capitalize.py) @@ -1040,6 +1043,7 @@ * [Reverse Letters](strings/reverse_letters.py) * [Reverse Long Words](strings/reverse_long_words.py) * [Reverse Words](strings/reverse_words.py) + * [Snake Case To Camel Pascal Case](strings/snake_case_to_camel_pascal_case.py) * [Split](strings/split.py) * [Upper](strings/upper.py) * [Wave](strings/wave.py) @@ -1074,6 +1078,7 @@ * [Instagram Pic](web_programming/instagram_pic.py) * [Instagram Video](web_programming/instagram_video.py) * [Nasa Data](web_programming/nasa_data.py) + * [Open Google Results](web_programming/open_google_results.py) * [Random Anime Character](web_programming/random_anime_character.py) * [Recaptcha Verification](web_programming/recaptcha_verification.py) * [Reddit](web_programming/reddit.py) From 03e34d5aa6fd4b19db2e36320b6af7a17e5f8cef Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 23 Oct 2022 14:45:22 +0200 Subject: [PATCH 6/7] Rename even_or_not.py to is_even.py --- bit_manipulation/{even_or_not.py => is_even.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bit_manipulation/{even_or_not.py => is_even.py} (100%) diff --git a/bit_manipulation/even_or_not.py b/bit_manipulation/is_even.py similarity index 100% rename from bit_manipulation/even_or_not.py rename to bit_manipulation/is_even.py From 484581d585b24362d071bdc0a2abe3dc2d139395 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Sun, 23 Oct 2022 12:45:38 +0000 Subject: [PATCH 7/7] updating DIRECTORY.md --- DIRECTORY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index 376264853ed6..3c601e05d145 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -42,8 +42,8 @@ * [Binary Xor Operator](bit_manipulation/binary_xor_operator.py) * [Count 1S Brian Kernighan Method](bit_manipulation/count_1s_brian_kernighan_method.py) * [Count Number Of One Bits](bit_manipulation/count_number_of_one_bits.py) - * [Even Or Not](bit_manipulation/even_or_not.py) * [Gray Code Sequence](bit_manipulation/gray_code_sequence.py) + * [Is Even](bit_manipulation/is_even.py) * [Reverse Bits](bit_manipulation/reverse_bits.py) * [Single Bit Manipulation Operations](bit_manipulation/single_bit_manipulation_operations.py)