We continue on in our journey, today is Chapter 3: Sequential Logic of Building a Modern Computer From First Principles. Last time we took a look at Boolean Arithmetic and we saw how we could start to create the ALU using these arithmetic chips. These chips are called combinational chips because they compute functions that depend solely on different combinations of their given input values. These relatively simple chips are able to provide a lot of the important processing functions, but the one thing they cannot do is maintain state. Obviously it does us no good to compute a value and then lose it. We need to be able to compute a value and then store and recall this data later. We create memory elements that are built from chips called sequential chips. The actual implementation of these memory elements is an intricate process involving synchronization, clocking, and feedback loops. …

This week I will be continuing a review of Building a Modern Computer from First Principles. Last week we learned a little bit about Boolean Logic now let’s check out chapter 2: Boolean Arithmetic.

The Central Processing Unit (CPU) is the electronic circuitry within a computer that executes instructions that make up a computer program. One of the important pieces of the CPU is the Arithmetic Logical Unit (ALU). The ALU is a digital circuit that performs arithmetic and logical operations on binary numbers. …

Lately I’ve been reading the book Building a Modern Computer from First Principles and I thought it would be good to reiterate some of the things I have learned so far. If you are interested in a broad overview of how computers work from the ground up, I highly recommend checking out this resource.

In the preface of this book, they say that many computer science students are missing the forest for the trees. What they mean is that the most fundamental ideas and techniques in computer science are now hidden under many layers of obscure interfaces and proprietary implementations. And this is very true, most of us come into this field starting to learn computer science using these high level languages and we begin to forget that hardware and software are tightly interrelated through a hidden web of abstractions, interfaces, and contract-based implementations. To truly understand how the software you are creating works, you need to understand how the hardware itself is working as well. I come from a biology background and the amount of similarities between computer science and biology is astounding. I think most of us completely overlook the intricacies of the modern computer and do not have any understanding how it works. Talking to friends who have no computer science or programming background will spout off ‘oh yeah, it’s like binary or something, zeroes and ones’. …

Since its December and Advent of Code is happening, I thought we may as well give a few a go. Today we will look at the day 2, Password Philosophy problem. The passwords in our database have been corrupted and now we must go through these passwords and flag the valid passwords and return how many are valid. The passwords are given to us as strings, the first part will have two numbers separated by a dash and this represents the minimum number of times a certain number should appear and the max number of times that letter should appear. The next piece in our string is the letter we are looking for and lastly separated by a colon and another space is the password string. …

Today we will be looking at a fun library I have been working with recently called Fabric.js. Fabric provides us with an interactive object model that is on top of the native canvas element. It allows us to easily add objects to the canvas and manipulate them in various ways. Let’s check it out. I am working on a React project currently, so we will be working with fabric in React. First things first let’s head to our terminal and create our project. (Also this may only be helpful if you are familiar with React, as well as React Hooks)

cd…

Today’s problem will be Word Ladder.

Alright first things first let’s discuss what this question is asking us for. We start with a beginWord and an endWord. We want to find the SHORTEST transformation sequence (other words, shortest path) from the beginWord to the endWord. The condition is that every step we take, we can only change one letter of each word, as well each ‘transition’ word must be included in our wordList.

We can think of the beginWord and the endWord as representing two nodes on a graph, the start node and the end node. The question is then asking if it possible to connect these two nodes by using intermediate nodes given to us by the wordList. These nodes will be connected by the condition that every neighboring node can only be different by one letter. The beginWord, endWord, and wordList can all be thought of as a undirected graph, where the words are the nodes and the edges between nodes differ by one letter. Now we are able to see more clearly how it is asking us for the shortest path, from start to end node. …

Today’s question will be Determine if Two Strings are ‘Close’:

The question asks us if after performing certain operations, are the words ‘close’ (can we attain word2 from performing operations on word1). The first operation allows us to swap any two existing characters. If we think about swapping any two characters, X times, that is essentially the same as ordering our string in any way we want. Let’s look, say we had word1 = ‘abc’ and word2 = ‘bca’. In word2 if we swap ‘b’ -> ‘a’, we then have ‘acb’, and then we can swap ‘c’ -> ‘b’, and we end with ‘abc’. So it appears that unlimited swaps is the same as sorting our string. Then the next operation allows us to transform every occurrence of one existing character for another. So if word1 = ‘bba’ and word2 = ‘aab’, we can swap word2 ‘aa’ -> ‘bb’ and ‘b’ -> ‘a’, giving us ‘bba’. IF we are able to swap every occurrence then the particular letter is not important, just the relative character counts. In our example word1 = ‘bba’ has one letter with an occurrence of 2 and one letter with an occurrence of 1, word2 = ‘aab’ has one letter with an occurrence of 2 and one letter with an occurrence of 1. …

Todays problem is a fun one! Let’s take a look at Spiral Matrix.

Largest Values From Labels — Lets Get Greedy

Today’s problem will be Largest Values from Labels.

The question asks us to return the largest possible sum of the subset S. This means we should probably order our items from largest to smallest, and then we can take the items if we have not used more than the use_limit. We can keep track of how many items of each label have been used by using a hash table.