This video is free to watch  hope you enjoy it! If you like what you see, there's a ton more where that came from...
Correcting Errors in a Digital Transmission, Part 1
There are *always* errors during the transmission of information, digital or otherwise. Whether it's written (typos, illegible writing), spoken (mumbling, environment noise) or digital (flipped bits), we have to account for and fix these problems.
This content is for subscribers only  which you can become in just 30 seconds!
As you watch this video, note that it’s not always smooth and seamless. Behind the scenes, Vimeo (my video provider) is adjusting for bandwith changes, alternating the sources based on throughput. The player is compensating for packet loss as well, correcting for errors in audio and video.
This stuff is complicated and you’re about to see why.
This is part 1 of a 2part series where we try to answer two simple questions:
 Was there an error in the transmission?
 Where is it?
 This is tricky stuff! We’ll tackle the theory in this video and in the next one, part 2, we’ll spend the entire time writing the code necessary to fix my favorite Big Lebowski quote.
The Code
Here’s the code used in the video. Note that the blurbs below are mostly for example. In the next video we’ll write more useful stuff.
class Encoder{
constructor(){
this.encoding = {
"A" : "01000000000",
"B" : "10000000000",
"C" : "00100000000",
"D" : "00101000000",
"E" : "10100000000",
"F" : "10010000000",
"G" : "01010000000",
"H" : "11000000000",
"I" : "11010000000",
"J" : "01011000000",
"K" : "01011001000",
"L" : "10001000000",
"M" : "01010100000",
"N" : "01100000000",
"O" : "01110000000",
"P" : "10000100000",
"Q" : "01011000100",
"R" : "11100000000",
"S" : "11110000000",
"T" : "00110000000",
"U" : "10011000000",
"V" : "01011010000",
"W" : "00100100000",
"X" : "01011000110",
"Y" : "01011100000",
"Z" : "01011000111",
" " : "00000000000"
}
}
encode(message){
//loop the characters in the message
//we'll assume for now that they won't enter anything but alpha numeric with a space for separation
//also ... uppercase to reduce pain
const words = message.toUpperCase(), out = [];
for(let word of words){
for(let char of word){
const encoding = this.encoding[char];
//if the character can be encoded great. If not, ignore
if(encoding) out.push(encoding);
}
}
return out.join("");
}
//add the methods below
}
evenParity(){
const keys = Object.keys(this.encoding);
for(let key of keys){
//default to even
let pad = "0";
//split into a character array so we can filter
const chars = this.encoding[key].split('');
const ones = chars.filter(v => v === "1");
//check mod 2 to see if we're odd, if so, set the pad to 1
if(ones.length % 2 !==0) pad = "1"
//update the encoding with a pad at the end
this.encoding[key]+= pad;
}
console.log(this.encoding);
}
checkParity(word){
//make sure we have the right length
if(word.length !== 12) return false;
//now make sure it's even
return word.split("").filter(char => char === "1").length %2 === 0;
}
decode(binaryMessage){
let out = [], codeWord = "";
const pad = this.encoding.A.length;
for(let i = 0; i < binaryMessage.length; i+=pad){
codeWord = binaryMessage.substring(i, i + pad);
const noError = this.checkParity(codeWord);
if(noError){
const key = this.getAlpha(codeWord);
out.push(key);
codeWord = "";
}else{
//this is an error!
console.log("Got an error with ", codeWord);
const fix = this.simpleHammingErrorCorrector(codeWord);
console.log("Fixing with best guess:", fix);
out.push(fix.word);
}
}
return out.join("");
}
simpleHammingErrorCorrector(binaryMessage){
const codeWords = Object.values(this.encoding);
let bestCandidate = {}, bestDistance = Number.POSITIVE_INFINITY;
for(let codeWord of codeWords){
let thisDistance = 0;;
//we're scanning each word for a match
for(let i = 0; i < codeWord.length; i++){
if(codeWord[i] !== binaryMessage[i]) {
thisDistance+=1;
}
}
if(thisDistance < bestDistance){
bestDistance = thisDistance;
bestCandidate = {word: this.getAlpha(codeWord), binary: codeWord, distance: bestDistance}
}
}
return bestCandidate;
}

The Basics of Logic
Let’s jump right in at the only place we can: the very begining, diving into the perfectly obvious and terribly argumentative 'rules of logic'.

Boolean Algebra
You're George Boole, a selftaught mathematician and somewhat of a genius. You want to know what God's thinking so you decide to take Aristotle's ideas of logic and go 'above and beyond' to include mathematical proofs.

Binary Mathematics
This is a famous interview question: 'write a routine that adds two positive integers and do it without using mathematic operators'. Turns out you can do this using binary!

Bitwise Operators
This is a famous interview question: 'write a routine that adds two positive integers and do it without using mathematic operators'. Turns out you can do this using binary!

Logical Negation
We've covered how to add binary numbers together, but how do you subtract them? For that, you need a system for recognizing a number as negative and a few extra rules. Those rules are one's and two's complement.

Entropy and Quantifying Information
Now that we know how to use binary to create switches and digitally represent information we need to ask the obvious question: 'is this worthwhile'? Are we improving things and if so, how much?

Encoding and Lossless Compression
Claude Shannon showed us how to change the way we encode things in order to increase efficiency and speed up information trasmission. We see how in this video.

Correcting Errors in a Digital Transmission, Part 1
There are *always* errors during the transmission of information, digital or otherwise. Whether it's written (typos, illegible writing), spoken (mumbling, environment noise) or digital (flipped bits), we have to account for and fix these problems.

Functional Programming
Functional programming builds on the concepts developed by Church when he created Lambda Calculus. We'll be using Elixir for this one, which is a wonderful language to use when discovering functional programming for the first time

Lambda Calculus
Before their were computers or programming languages, Alonzo Church came up with a set of rules for working with functions, what he termed lambdas. These rules allow you to compute anything that can be computed.

Database Normalization
How does a spreadsheet become a highlytuned set of tables in a relational system? There are rules for this  the rules of normalization  which is an essential skill for any developer working with data

Big O Notation
Understanding Big O has many real world benefits, aside from passing a technical interview. In this post I'll provide a cheat sheet and some real world examples.

Arrays and Linked Lists
The building block data structures from which so many others are built. Arrays are incredibly simple  but how much do you know about them? Can you build a linked list from scratch?

Stacks, Queues and Hash Tables
You can build all kinds of things using the flexibility of a linked list. In this video we'll get to know a few of the more common data structures that you use every day.

Trees, Binary Trees and Graphs
The bread and butter of technical interview questions. If you're going for a job at Google, Microsoft, Amazon or Facebook  you can be almost guaranteed to be asked a question that used a binary tree of some kind.

Basic Sorting Algorithms
You will likely *never* need to implement a sorting algorithm  but understanding how they work could come in handy at some point. Interviews and workarounds for framework problems come to mind.

DFS, BFS and Binary Tree Search
You now know all about trees and graphs  but how do you use them? With search and traversal algorithms of course! This is the next part you'll need to know when you're asked a traversal question in an interview. And you will be.

Dynamic Programming and Fibonnaci
Dynamic programming gives us a way to elegantly create algorithms for various problems and can greatly improve the way you solve problems in your daily work. It can also help you ace an interview.

Calculating Prime Numbers
The use of prime numbers is everywhere in computer science... in fact you're using them right now to connect to this website, read your email and send text messages.

Graph Traversal: Bellman Ford
How can you traverse a graph ensuring you take the route with the lowest cost? The BellmanFord algorithm will answer this question.

Graph Traversal: Djikstra
BellmanFord works well but it takes too long and your graph can't have cycles. Djikstra solved this problem with an elegant solution.