Skip to content

Commit 718b4c4

Browse files
authored
Merge branch 'master' into fix/exponential-search-recursion
2 parents fb49f8a + 81091d6 commit 718b4c4

22 files changed

Lines changed: 2556 additions & 129 deletions

‎DIRECTORY.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,17 @@
146146
* [Baconian Cipher](ciphers/baconian_cipher.py)
147147
* [Base16](ciphers/base16.py)
148148
* [Base32](ciphers/base32.py)
149+
* [Base58](ciphers/base58.py)
149150
* [Base64 Cipher](ciphers/base64_cipher.py)
150151
* [Base85](ciphers/base85.py)
151152
* [Beaufort Cipher](ciphers/beaufort_cipher.py)
152153
* [Bifid](ciphers/bifid.py)
153154
* [Brute Force Caesar Cipher](ciphers/brute_force_caesar_cipher.py)
154155
* [Caesar Cipher](ciphers/caesar_cipher.py)
156+
* [Columnar Transposition](ciphers/columnar_transposition.py)
155157
* [Cryptomath Module](ciphers/cryptomath_module.py)
156158
* [Decrypt Caesar With Chi Squared](ciphers/decrypt_caesar_with_chi_squared.py)
159+
* [Des Ecb](ciphers/des_ecb.py)
157160
* [Deterministic Miller Rabin](ciphers/deterministic_miller_rabin.py)
158161
* [Diffie](ciphers/diffie.py)
159162
* [Diffie Hellman](ciphers/diffie_hellman.py)
@@ -181,6 +184,7 @@
181184
* [Shuffled Shift Cipher](ciphers/shuffled_shift_cipher.py)
182185
* [Simple Keyword Cypher](ciphers/simple_keyword_cypher.py)
183186
* [Simple Substitution Cipher](ciphers/simple_substitution_cipher.py)
187+
* [Skytale Cipher](ciphers/skytale_cipher.py)
184188
* [Transposition Cipher](ciphers/transposition_cipher.py)
185189
* [Transposition Cipher Encrypt Decrypt File](ciphers/transposition_cipher_encrypt_decrypt_file.py)
186190
* [Trifid Cipher](ciphers/trifid_cipher.py)
@@ -205,6 +209,7 @@
205209

206210
## [Conversions](conversions)
207211
* [Astronomical Length Scale Conversion](conversions/astronomical_length_scale_conversion.py)
212+
* [Base64 To Binary](conversions/base64_to_binary.py)
208213
* [Binary To Decimal](conversions/binary_to_decimal.py)
209214
* [Binary To Excess3](conversions/binary_to_excess3.py)
210215
* [Binary To Gray](conversions/binary_to_gray.py)
@@ -220,6 +225,7 @@
220225
* [Energy Conversions](conversions/energy_conversions.py)
221226
* [Excel Title To Column](conversions/excel_title_to_column.py)
222227
* [Hex To Bin](conversions/hex_to_bin.py)
228+
* [Hex To Rgb](conversions/hex_to_rgb.py)
223229
* [Hexadecimal To Decimal](conversions/hexadecimal_to_decimal.py)
224230
* [Int To Negative Binary Base](conversions/int_to_negative_binary_base.py)
225231
* [Ipv4 Conversion](conversions/ipv4_conversion.py)
@@ -510,6 +516,7 @@
510516
* [Ic 555 Timer](electronics/ic_555_timer.py)
511517
* [Ind Reactance](electronics/ind_reactance.py)
512518
* [Ohms Law](electronics/ohms_law.py)
519+
* [Power Factor Correction](electronics/power_factor_correction.py)
513520
* [Real And Reactive Power](electronics/real_and_reactive_power.py)
514521
* [Resistor Color Code](electronics/resistor_color_code.py)
515522
* [Resistor Equivalence](electronics/resistor_equivalence.py)
@@ -527,6 +534,7 @@
527534
* [Exponential Moving Average](financial/exponential_moving_average.py)
528535
* [Interest](financial/interest.py)
529536
* [Kelly Criterion](financial/kelly_criterion.py)
537+
* [Macaulay Duration](financial/macaulay_duration.py)
530538
* [Present Value](financial/present_value.py)
531539
* [Price Plus Tax](financial/price_plus_tax.py)
532540
* [Sharpe Ratio](financial/sharpe_ratio.py)
@@ -741,6 +749,7 @@
741749
* [Q Learning](machine_learning/q_learning.py)
742750
* [Random Forest Classifier](machine_learning/random_forest_classifier.py)
743751
* [Random Forest Regressor](machine_learning/random_forest_regressor.py)
752+
* [Ridge Regression](machine_learning/ridge_regression.py)
744753
* [Rmsprop](machine_learning/rmsprop.py)
745754
* [Scoring Functions](machine_learning/scoring_functions.py)
746755
* [Self Organizing Map](machine_learning/self_organizing_map.py)
@@ -1009,6 +1018,7 @@
10091018
* [Scaled Exponential Linear Unit](neural_network/activation_functions/scaled_exponential_linear_unit.py)
10101019
* [Soboleva Modified Hyperbolic Tangent](neural_network/activation_functions/soboleva_modified_hyperbolic_tangent.py)
10111020
* [Softplus](neural_network/activation_functions/softplus.py)
1021+
* [Softsign](neural_network/activation_functions/softsign.py)
10121022
* [Squareplus](neural_network/activation_functions/squareplus.py)
10131023
* [Swish](neural_network/activation_functions/swish.py)
10141024
* [Back Propagation Neural Network](neural_network/back_propagation_neural_network.py)
@@ -1161,6 +1171,7 @@
11611171
* [Sol2](project_euler/problem_012/sol2.py)
11621172
* Problem 013
11631173
* [Sol1](project_euler/problem_013/sol1.py)
1174+
* [Sol2](project_euler/problem_013/sol2.py)
11641175
* Problem 014
11651176
* [Sol1](project_euler/problem_014/sol1.py)
11661177
* [Sol2](project_euler/problem_014/sol2.py)
@@ -1264,6 +1275,8 @@
12641275
* [Sol1](project_euler/problem_058/sol1.py)
12651276
* Problem 059
12661277
* [Sol1](project_euler/problem_059/sol1.py)
1278+
* Problem 060
1279+
* [Sol1](project_euler/problem_060/sol1.py)
12671280
* Problem 062
12681281
* [Sol1](project_euler/problem_062/sol1.py)
12691282
* Problem 063
@@ -1339,6 +1352,8 @@
13391352
* [Sol1](project_euler/problem_107/sol1.py)
13401353
* Problem 109
13411354
* [Sol1](project_euler/problem_109/sol1.py)
1355+
* Problem 111
1356+
* [Sol1](project_euler/problem_111/sol1.py)
13421357
* Problem 112
13431358
* [Sol1](project_euler/problem_112/sol1.py)
13441359
* Problem 113
@@ -1361,6 +1376,8 @@
13611376
* [Sol1](project_euler/problem_122/sol1.py)
13621377
* Problem 123
13631378
* [Sol1](project_euler/problem_123/sol1.py)
1379+
* Problem 124
1380+
* [Sol1](project_euler/problem_124/sol1.py)
13641381
* Problem 125
13651382
* [Sol1](project_euler/problem_125/sol1.py)
13661383
* Problem 129
@@ -1371,6 +1388,12 @@
13711388
* [Sol1](project_euler/problem_135/sol1.py)
13721389
* Problem 136
13731390
* [Sol1](project_euler/problem_136/sol1.py)
1391+
* Problem 137
1392+
* [Sol1](project_euler/problem_137/sol1.py)
1393+
* Problem 138
1394+
* [Sol1](project_euler/problem_138/sol1.py)
1395+
* Problem 142
1396+
* [Sol1](project_euler/problem_142/sol1.py)
13741397
* Problem 144
13751398
* [Sol1](project_euler/problem_144/sol1.py)
13761399
* Problem 145

‎blockchain/README.md‎

Lines changed: 137 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,160 @@
1-
# Blockchain
1+
# Blockchain Technology
2+
3+
<p align="center">
4+
<img src="https://images.unsplash.com/photo-1639322537228-f710d846310a?q=80&w=3132&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" width="700">
5+
</p>
26

37
A Blockchain is a type of **distributed ledger** technology (DLT) that consists of a growing list of records, called **blocks**, that are securely linked together using **cryptography**.
48

59
Let's break down the terminologies in the above definition. We find below terminologies,
610

7-
* Digital Ledger Technology (DLT)
8-
* Blocks
9-
* Cryptography
11+
- Digital Ledger Technology (DLT)
12+
- Blocks
13+
- Cryptography
14+
15+
## Distributed Ledger Technology (DLT)
16+
17+
First of all, a **ledger** is a book or collection of accounts that keeps track of account transactions. Usually, ledgers are **centralised**, meaning that they're controlled by a sole influence.
18+
These ledgers are physical records maintained by banks, governments, and other establishments to track financial transactions, ownership records, and any other essential information.
19+
However, this approach only serves as a hotbed for inefficiency and over-reliance on a sole entity.
20+
21+
This is where Distributed Ledger Technology comes in. DLT represents a massive shift from centralised data management.
22+
23+
Instead of one single entity managing data, the ledger, which in this case is **digital**, is shared among multiple **nodes**(computers) in a network. Each node is responsible for maintaining an **identical** copy of the main ledger, and all these nodes must consent before any new information is added to the main ledger.
24+
25+
*Key Characteristics of DLT:*
26+
27+
- Decentralisation: No single point of control, management or failure
28+
- Transparency: All network participants can see transactions, although personal details may be encrypted
29+
- Immutability: Once data is recorded and confirmed, it becomes extremely hard to change
30+
- Consensus Mechanisms: Network participants must agree on the credibility of new transactions
31+
32+
*To further conceptualise Distributed Ledger Technology, imagine the scenario below:*
1033

11-
## Digital Ledger Technology
34+
- Four roommates live in an apartment together.
35+
- They all contribute towards groceries, utilities, and rent.
36+
- In the spirit of accountability, they use a **shared Google Sheet** where every expense is tracked.
37+
- Everyone can **see**, **add**, and **validate** expenses, but **no one can delete past expense entries** — they're only allowed to append new rows with reasons for any corrections.
1238

13-
Blockchain is also called distributed ledger technology. It is simply the opposite of a centralized database. Firstly, what is a **ledger**? A ledger is a book or collection of accounts that records account transactions.
39+
This is exactly how a Distributed Ledger works.
1440

15-
*Why is Blockchain addressed as a digital ledger if it can record more than account transactions? What other transaction details and information can it hold?*
41+
| Google Sheet Feature | DLT Concept Equivalent |
42+
|---------------------------------------------------|---------------------------------------------------|
43+
| Everyone has access to the same document | **Distributed ledger** — everyone has a synchronised copy |
44+
| Changes are visible to all in real time | **Transparency and consensus** |
45+
| No one can erase old entries; only new ones can be added with explanations | **Immutability** of records |
46+
| Each entry includes a timestamp and who added it | **Timestamped transactions** and **identity** (like digital signatures) |
47+
| Everyone can verify what’s been entered | **Decentralised verification** |
48+
| Any disputes are resolved by checking the shared record | **Consensus mechanism** (though manual here) |
1649

17-
Digital Ledger Technology is just a ledger that is shared among multiple nodes. This way there exists no need for a central authority to hold the info. Okay, how is it differentiated from a central database and what are their benefits?
50+
## Centralised vs. Distributed Management
1851

19-
Suppose that there is an organization that has 4 branches whose data are stored in a centralized database. So even if one branch needs any data from the ledger it needs approval from the database in charge. And if one hacks the central database he gets to tamper and control all the data.
52+
**Centralised approach:** Here, an organisation with 4 branches stores all its data in one central database. This database is managed by the Chief Administrator at the headquarters. Each branch needs approval from the Chief Administrator to view and access information.
53+
If a bad actor gains access to the central database, they can unduly alter all the data, and if the central database fails, all the branches lose their access to vital data.
2054

21-
Now let's assume every branch has a copy of the ledger and then once anything is added to the ledger by any branch it is gonna automatically reflect in all other ledgers available in other branches. This is done using a peer-to-peer network.
55+
**Distributed approach:** In this case, each organisational branch maintains a complete **carbon copy** of the original ledger. For one branch to add information, all branches must reach a consensus.
56+
When one branch adds information, it's broadcast to the entire network and systematically synchronised across all other ledgers through a peer-to-peer network after verification.
2257

23-
This means that even if information is tampered with in one branch we can find out. If one branch is hacked we can be alerted, so we can safeguard other branches. Now, assume these branches as computers or nodes and the ledger is a transaction record or digital receipt.
24-
If one ledger is hacked in a node we can detect since there will be a mismatch in comparison with other node information. So this is the concept of Digital Ledger Technology.
58+
In summary, a distributed approach offers:
2559

26-
*Is it required for all nodes to have access to all information in other nodes? Wouldn't this require enormous storage space in each node?*
60+
- Fault tolerance: If information is altered in one branch, other branches can detect the change through consensus algorithms
61+
- Security: If one branch is compromised, other branches remain secure and can identify the bad actor
62+
- Availability: No single point of failure — if one computer goes down, the network is still highly functional
63+
- Verification: Any member of the network can independently verify the integrity of the complete transaction history
2764

2865
## Blocks
2966

30-
In short, a block is nothing but a collection of records with a labelled header. These are connected cryptographically. Once a new block is added to a chain, the previous block is connected, more precisely said as locked, and hence will remain unaltered. We can understand this concept once we get a clear understanding of the working mechanism of blockchain.
67+
A **block** is a cluster of transactions grouped together with metadata in a structured manner.
68+
Imagine a block as a page in a digital ledger. This page consists of multiple transaction entries, including important information about when and how that page was created.
69+
Cryptography is the practice and study of secure communication techniques amid adversarial behavior. More broadly, cryptography is the creation and analysis of protocols that prevent third parties or the general public from accessing private messages.
70+
71+
*Structure of a Block:*
72+
73+
1. Block Header:
74+
75+
- Previous Block Hash: A unique fingerprint of the previous block, creating the *chain*
76+
- Merkle Root: A cryptographic summary of all transactions in the block
77+
- Timestamp: The time the block was created
78+
- Nonce: A number used in the Proof-of-Work (PoW) mining process
79+
- Difficulty Target: The complexity level required to mine this block
80+
81+
2. Block Body:
82+
83+
- Transaction Data: The actual transaction records (transfers, smart contract executions, etc.)
84+
- Transaction Count: Number of transactions confirmed in the block
85+
86+
## The Chain Formation
87+
88+
Blocks are connected cryptographically using hash functions, in order to create an **immutable** chain:
89+
90+
1. Genesis Block: The first block in the chain, which is hardcoded into the blockchain protocol
91+
2. Subsequent Blocks: Each new block contains the hash function of the preceding block
92+
3. Chain Integrity: If someone tries to modify a previous block, its hash function changes, breaking the chain and notifying the entire network
93+
94+
With cryptographic linking, once a block is added to the chain and verified by the network, modifying any preceding block is computationally impractical. The deeper a block is in the chain (the more blocks built on top of it), the more secure it becomes.
3195

3296
## Cryptography
3397

34-
Cryptography is the practice and study of secure communication techniques amid adversarial behavior. More broadly, cryptography is the creation and analysis of protocols that prevent third parties or the general public from accessing private messages.
98+
Cryptography is the practice and study of secure communication strategies that safeguard information from unwanted access. In the context of blockchain, cryptography is the backbone of security, privacy, and trust, in a decentralised network where participants don't know, or even trust each other.
99+
100+
*Key Cryptographic Concepts in Blockchain:*
101+
102+
1. Hash Functions:
103+
104+
- Generate fixed-size output (hash) from variable-size input
105+
- The SHA-256 function is typically used in Bitcoin
106+
- Properties: Deterministic (giving input to a hash function will always produce the same output), avalanche effect, irreversible
107+
- Used for: Block linking, transaction verification, mining puzzles
108+
109+
2. Digital Signatures:
110+
111+
- Prove ownership and authorise transactions without revealing private keys
112+
- Based on public-key cryptography (asymmetric encryption)
113+
- Each user has a pair: private key (secret) and public key (shareable)
114+
- Process: Sign with private key and verify with public key
115+
116+
3. Merkle Trees:
117+
118+
- Binary tree structure that effectively outlines all transactions in a block
119+
- Enables quick verification of transaction inclusion without having to download the entire block
120+
- Provides evidence for altered transaction data
121+
122+
*Cryptographic Security in Practice:*
123+
124+
1. Transaction Security:
125+
When person A wants to send **cryptocurrency** to person B:
126+
127+
- Person A creates a transaction using person B's **public address**
128+
- Person A signs the transaction with their **private key**
129+
- Network nodes verify the signature using person A's **public key**
130+
- Once verified, the transaction is added to a block
131+
132+
2. Block Integrity:
133+
134+
- Each block contains the hash of the previous block
135+
- Any change to a previous block changes its hash
136+
- This breaks the chain and immediately notifies the entire network
137+
- Makes altering historical data unfeasible
138+
139+
3. Privacy vs. Transparency:
35140

36-
*Which cryptography technology is most widely used in blockchain and why?*
141+
- **Transparency** means amounts and addresses are public.
142+
- **Privacy** ensures that real-world identities behind addresses are undisclosed.
143+
- This balance allows for accountability and anonymity in transactions.
37144

38-
So, in general, blockchain technology is a distributed record holder that records the information about ownership of an asset. To define precisely,
39-
> Blockchain is a distributed, immutable ledger that makes it easier to record transactions and track assets in a corporate network.
40-
An asset could be tangible (such as a house, car, cash, or land) or intangible (such as a business) (intellectual property, patents, copyrights, branding). A blockchain network can track and sell almost anything of value, lowering risk and costs for everyone involved.
145+
> In summary, **Blockchain technology** represents a pioneering shift in how we store, verify, and transfer value in digital systems. It's a distributed, immutable, non-physical ledger that records transactions and tracks assets across a decentralised network, without requiring **trust** in a sole entity.
146+
Blockchain networks can track and trade virtually any **asset** of value, from tangible assets like real estate, commodities, and vehicles, to intangible assets such as cryptocurrencies, intellectual property, digital art (NFTs), and carbon credits.
147+
A blockchain network can track and sell almost anything of value, lowering risk and costs for everyone involved.
41148

42-
So this is all about the introduction to blockchain technology. To learn more about the topic refer below links....
149+
This is just a brief introduction to blockchain technology.
150+
To find out more about this technology, check out the links below:
43151

44-
* <https://en.wikipedia.org/wiki/Blockchain>
45-
* <https://en.wikipedia.org/wiki/Chinese_remainder_theorem>
46-
* <https://en.wikipedia.org/wiki/Diophantine_equation>
47-
* <https://www.geeksforgeeks.org/modular-division/>
152+
- <https://en.wikipedia.org/wiki/Blockchain> - Comprehensive overview of blockchain technology
153+
- <https://bitcoin.org/bitcoin.pdf> - The original document by Satoshi Nakamoto
154+
- <https://ethereum.org/en/whitepaper/> - Introduction to programmable blockchain
155+
- <https://en.wikipedia.org/wiki/Cryptographic_hash_function> - Understanding the math behind blockchain security
156+
- <https://en.wikipedia.org/wiki/Merkle_tree> - Data structure for efficient verification
157+
- <https://web3js.readthedocs.io/> - JavaScript library for blockchain interaction
158+
- <https://en.wikipedia.org/wiki/Chinese_remainder_theorem>
159+
- <https://en.wikipedia.org/wiki/Diophantine_equation>
160+
- <https://www.geeksforgeeks.org/modular-division/>

0 commit comments

Comments
 (0)