Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions boolean_algebra/buffer_gate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
A Buffer Gate is a logic gate in boolean algebra which outputs the same value
as its input. It is used for signal isolation, increasing drive strength, or
introducing propagation delay in digital circuits.

In digital electronics, buffers are essential for:
- Isolating different circuit sections
- Increasing current drive capability
- Preventing signal degradation
- Creating intentional delays in timing circuits

Following is the truth table of a Buffer Gate:
----------------------
| Input | Output |
----------------------
| 0 | 0 |
| 1 | 1 |
----------------------

Refer - https://en.wikipedia.org/wiki/Digital_buffer
"""


def buffer_gate(input_1: int) -> int:
"""
Calculate output of a buffer gate

>>> buffer_gate(0)
0
>>> buffer_gate(1)
1
"""
return int(bool(input_1))


if __name__ == "__main__":
import doctest

doctest.testmod()
31 changes: 25 additions & 6 deletions electronics/wheatstone_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,32 @@ def wheatstone_solver(
resistance_1: float, resistance_2: float, resistance_3: float
) -> float:
"""
This function can calculate the unknown resistance in an wheatstone network,
given that the three other resistances in the network are known.
The formula to calculate the same is:
Calculate the unknown resistance (Rx) in a Wheatstone bridge circuit.

---------------
|Rx=(R2/R1)*R3|
---------------
A Wheatstone bridge is an electrical circuit used to precisely measure
an unknown resistance. This function calculates Rx when the three other
resistances in the bridge are known.

Circuit Diagram:

R1 R2
+--/\/\/--+--/\/\/--+
| | |
Vin Vg Vout
| | |
+--/\/\/--+--/\/\/--+
R3 Rx

This solver uses the balanced bridge formula:
Rx = (R2/R1) × R3

Args:
resistance_1 (R1): First known resistance
resistance_2 (R2): Second known resistance
resistance_3 (R3): Third known resistance

Returns:
float: The calculated unknown resistance (Rx)

Usage examples:
>>> wheatstone_solver(resistance_1=2, resistance_2=4, resistance_3=5)
Expand Down