Skip to content

Commit 8abed30

Browse files
authored
Merge branch 'TheAlgorithms:master' into master
2 parents 93f50dd + f721e59 commit 8abed30

28 files changed

Lines changed: 462 additions & 30 deletions

DIRECTORY.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,6 @@
128128
* [Vigenere Cipher](ciphers/vigenere_cipher.py)
129129
* [Xor Cipher](ciphers/xor_cipher.py)
130130

131-
## Compression
132-
* [Burrows Wheeler](compression/burrows_wheeler.py)
133-
* [Huffman](compression/huffman.py)
134-
* [Lempel Ziv](compression/lempel_ziv.py)
135-
* [Lempel Ziv Decompress](compression/lempel_ziv_decompress.py)
136-
* [Lz77](compression/lz77.py)
137-
* [Peak Signal To Noise Ratio](compression/peak_signal_to_noise_ratio.py)
138-
* [Run Length Encoding](compression/run_length_encoding.py)
139-
140131
## Computer Vision
141132
* [Cnn Classification](computer_vision/cnn_classification.py)
142133
* [Flip Augmentation](computer_vision/flip_augmentation.py)
@@ -181,6 +172,15 @@
181172
* [Volume Conversions](conversions/volume_conversions.py)
182173
* [Weight Conversion](conversions/weight_conversion.py)
183174

175+
## Data Compression
176+
* [Burrows Wheeler](data_compression/burrows_wheeler.py)
177+
* [Huffman](data_compression/huffman.py)
178+
* [Lempel Ziv](data_compression/lempel_ziv.py)
179+
* [Lempel Ziv Decompress](data_compression/lempel_ziv_decompress.py)
180+
* [Lz77](data_compression/lz77.py)
181+
* [Peak Signal To Noise Ratio](data_compression/peak_signal_to_noise_ratio.py)
182+
* [Run Length Encoding](data_compression/run_length_encoding.py)
183+
184184
## Data Structures
185185
* Arrays
186186
* [Equilibrium Index In Array](data_structures/arrays/equilibrium_index_in_array.py)
@@ -884,6 +884,7 @@
884884
* [Centripetal Force](physics/centripetal_force.py)
885885
* [Coulombs Law](physics/coulombs_law.py)
886886
* [Doppler Frequency](physics/doppler_frequency.py)
887+
* [Escape Velocity](physics/escape_velocity.py)
887888
* [Grahams Law](physics/grahams_law.py)
888889
* [Horizontal Projectile Motion](physics/horizontal_projectile_motion.py)
889890
* [Hubble Parameter](physics/hubble_parameter.py)
@@ -1122,6 +1123,8 @@
11221123
* [Sol1](project_euler/problem_092/sol1.py)
11231124
* Problem 094
11241125
* [Sol1](project_euler/problem_094/sol1.py)
1126+
* Problem 095
1127+
* [Sol1](project_euler/problem_095/sol1.py)
11251128
* Problem 097
11261129
* [Sol1](project_euler/problem_097/sol1.py)
11271130
* Problem 099
@@ -1202,6 +1205,8 @@
12021205
* [Sol1](project_euler/problem_234/sol1.py)
12031206
* Problem 301
12041207
* [Sol1](project_euler/problem_301/sol1.py)
1208+
* Problem 345
1209+
* [Sol1](project_euler/problem_345/sol1.py)
12051210
* Problem 493
12061211
* [Sol1](project_euler/problem_493/sol1.py)
12071212
* Problem 551

boolean_algebra/and_gate.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
2-
An AND Gate is a logic gate in boolean algebra which results to 1 (True) if both the
3-
inputs are 1, and 0 (False) otherwise.
2+
An AND Gate is a logic gate in boolean algebra which results to 1 (True) if all the
3+
inputs are 1 (True), and 0 (False) otherwise.
44
5-
Following is the truth table of an AND Gate:
5+
Following is the truth table of a Two Input AND Gate:
66
------------------------------
77
| Input 1 | Input 2 | Output |
88
------------------------------
@@ -12,7 +12,7 @@
1212
| 1 | 1 | 1 |
1313
------------------------------
1414
15-
Refer - https://www.geeksforgeeks.org/logic-gates-in-python/
15+
Refer - https://www.geeksforgeeks.org/logic-gates/
1616
"""
1717

1818

@@ -32,6 +32,18 @@ def and_gate(input_1: int, input_2: int) -> int:
3232
return int(input_1 and input_2)
3333

3434

35+
def n_input_and_gate(inputs: list[int]) -> int:
36+
"""
37+
Calculate AND of a list of input values
38+
39+
>>> n_input_and_gate([1, 0, 1, 1, 0])
40+
0
41+
>>> n_input_and_gate([1, 1, 1, 1, 1])
42+
1
43+
"""
44+
return int(all(inputs))
45+
46+
3547
if __name__ == "__main__":
3648
import doctest
3749

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)