The most beautiful experience we can have is the mysterious.

Simulating How Computers Add Numbers

A hardware simulation of 4-bit numbers adder. How the addition operates in binary – example: 6 (A)+7 (B) = 13 (C): Below is a hardware logic diagram of a full adder, which is used to do 1-bit additions. It uses 5 logic gates, each made out of 4-6 transistors. There are also other ways to combine different logic gates to produce a full adder. To operate 4-bit additions, it requires roughly 4 full adders connecting like below.

ER Modelling

Case - London Oyster Card (simplified)

Objective Record information: User information: name, address Oyster card information: card id, create date, card type, balance Trips: travel from, touch in date and time, travel to, touch out date and time, fare Dummy data 3rd Normal Form is used below to normalise the data. It is a 3 steps process, each step depends on the completion of the previous step and progressively transforming the data. 1st Normal Form: Atomicity

Sum Of Digits

Sum all the digits of number N (>0), if result has more than one digit, repeat summing all the digits of the result of each round, until reaching a single digit number R. For example: $$N = 365 => 3 + 6 + 5 = 14 => R = 1 + 4 = 5 $$ Algorithm: $$R = (N – 1) mod 9 + 1$$ Proof Represent each digit in N as a_{k}

Unbeatable Noughts & Crosses

Deep Blue Algorithm (Minimax)

The AI algorithm Minimax is used to decide the next best move in two player games like chess and go zero-sum games. It goes through all the possible moves between two players, and scores each simulated game result according to the end status: If the AI player wins, it is given a positive score If the opponent player wins, it is given a negative score If it is a draw, it is given score 0 The scores will be rolled up to their upper level nodes:

Estimate Pi

Monte Carlo Method

Area of square: $$S_s = L*L$$ Area of circle: $$S_c = Pi*(L/2)2$$ Draw random dots, with sufficient dots, the probability of dots appearing in the circle approaximately equals the area of the circle within the area of the square: $$N_c ⁄ N_c ≈ S_c ⁄ S_s = (Pi*(L/2)2) ⁄ (L*L)$$ $$=> Pi = N_c ⁄ N_s *4 $$ Play the demo here Code in Github