While in Southern France, Simon really enjoyed solving this puzzle (he originally saw in a Brilliant.org vid). He was so happy with his solution he kept drawing it out on paper and in digital apps, and later shared the puzzle on Twitter. This sparked quite a few reactions from fellow math lovers, encouraged Brilliant to tweet new puzzles and now Brilliant follows Simon on Twitter, how cool is that!

# Category Archives: Contributing

# Drawing with Turtle

Here we are, on the day of my 40th birthday, while recording a lesson of drawing with turtle in Python. It was meant to be my birthday present, a beginner-friendly hour of code, in which Neva would also be able to take an active part. We ended up recording two beautiful sessions only to find out later that our screen capture video was irreparably corrupted (never record in mp4 in OBS). Simon was inconsolable. We also thought this webcam recording was gone but rediscovered it a day later. So nice to have it as a memory.

And I’m relieved to say that we have managed to redo the whole project from scratch today (sadly without Neva’s participation this time as she had better things to do, so I look rather redundant sitting there next to Simon giving the lesson). Once Simon is done with the editing (which is another two days of work I’m afraid), he will upload the hour of code on YouTube. He also plans to create a website for this project to enable his “students” to draw in a built-in application.

From our session today:

And here is an example of Simon drawing with turtle for his own pleasure, a Serpinski triangle in Python (a few days ago):

# The Brachistochrone

Simon believes that he has found a mistake in one of the installations at the Technopolis science museum. Or at least that the background description of the exhibit lacks a crucial piece of info. The exhibit that allows to simultaneously roll three equal-weight balls down three differently shaped tracks, with the start and the end at identical height in all the three tracks, supposes that the ball in the steepest track reaches the end the quickest. The explanation on the exhibit says that it is because that ball accelerates the most. Simon has noticed, however, that the middle track highly resembles a cycloid and says a cycloid is known to be the fastest descent, also called the Brachistochrone Curve in mathematics and physics.

In Simon’s own words:

You need the track to be steep, because then it will accelerate more – that’s right. But it also has to be quite a short track, otherwise it takes long to get from A to B – which is not in the explanation. It’s not the steepest track, it’s the balance between the shortest track and the steepest track.

Galileo Galilei thought that it is the arc of a circle. But then, Johan Bernoulli took over, and proved that the cycloid is the fastest.

The (only) most elegant proof I’ve seen so far is in this 3Blue1Brown video: https://www.youtube.com/watch?v=Cld0p3a43fU

There’s also a VSauce1 video, where they made a mechanical version of this (like Technopolis): https://www.youtube.com/watch?v=skvnj67YGmw

Wikipedia Page: https://en.wikipedia.org/wiki/Brachistochrone_curve

We’ve also made some slow motion footage of us using the exhibit (you can see that the cycloid is slightly faster, but as far as I can tell, it’s not precision-made, so it wasn’t the fastest track every time): https://www.youtube.com/watch?v=5Brub0FnpmQ

I hope that you could mention the brachistochrone/ cycloid in your exhibit explanation. I don’t think you can include the proof, because for such a general audience, it can’t fit on a single postcard!

# Simon’s new “giant project”: Sorting Visualizations

Simon writes: I’ve built a giant project; a website / community project / platform for making algorithms! I’ve built in this video Bubble Sort, Selection Sort, Insertion Sort, Mergesort, Quicksort, Heapsort, Shell Sort and Radix Sort. So I’m done with the sorting part of the project. In the next video I’ll show you the making of the Pathfinding part of the project, and then, I’m going to put it on GitHub, and pass it on to the community, to put more algorithms on there, and even new types of algorithms!

Play with Simon’s visualizations on Repl.it at: https://repl.it/@simontiger/SortingImproved

Simon has already recorded a series of video tutorials about sorting algorithms earlier this spring. In the videos, he codes on his RaspberryPi, but here are the links to the Python code available on his GitHub page: Parts 1 – 5; Parts 6 – 7.

# Always listen to Simon!

Just a funny piece from a member-only Coding Train session ðŸ˜‰

# Simon’s Community Contribution: Variation of 2D Casting Coding Challenge in p5.js

This is Simon’s version of Daniel Shiffman’s 2D Casting code, made on Wednesday last week right after the live session. Link to the live session including the coding challenge.

Code and interactive animation are online at: https://editor.p5js.org/simontiger/sketches/ugHX4yKQC

Play with the animation online at:

https://editor.p5js.org/simontiger/present/ugHX4yKQC

https://editor.p5js.org/simontiger/full/ugHX4yKQC

Simon has also made one more, optimized version of this project (with fewer rays, runs faster): https://editor.p5js.org/simontiger/present/F6TCHAZs_

https://editor.p5js.org/simontiger/sketches/F6TCHAZs_

Both of Simon’s versions have been added to the community contributions on the Coding Train website: https://thecodingtrain.com/CodingChallenges/145-2d-ray-casting.html

# Example of Simon contributing an issue on GitHub

Below is Simon’s issue/ topic suggestion he contributed to the Coding Train GitHub yesterday, addressed to Daniel Shiffman:

## Function Overloading

Nah.

## Operator Overloading

OK, first, we have to understand the `valueOf()`

function. `valueOf()`

is a function, that typically performs on a string, that converts it into a “primitive” data type.

A number is a primitive data type, because it’s not an object. And, you can see that by opening a Terminal window, running `node`

and type:

> 2 + 2 // and get 4

Because JS doesn’t have any “real” overloading, you can’t put `+`

in between two objects, in between two objects, and get an answer!

Well, with one slight exception, which is the `valueOf()`

function. It will tell JS how to interpret an instance of an object as a primitive data type, whenever you want to add them together or something. If you put a `valueOf()`

function into the prototype (or class, if you will) of an object, and it converts it into a number, or some other primitive data type, you can suddenly do arithmetic on these objects!

This does have a limitation, though. Say you write a class:

class Vector { constructor(x=0, y=0) { this.x = x; this.y = y; } // Maybe you want a valueOf() function to add them together valueOf() { // TL;DR What goes here??? } }

Maybe you want to add the individual components of a vector to add two vectors together.

It turns out, the answer is, *nothing can go in the place of the question mark*!

Here’s why: There’s no real primitive data type, with further components. That’s because that’s what a primitive data type is! It doesn’t have data, it *is it’s own data!* A Vector does have further components, however, and so we arrive at a contradiction. Because a vector has further components, and `valueOf()`

must return something without further components, this situation is impossible!

## String Overloading

Well, it’s really the same as Operator Overloading, except you need to use the `toString()`

function instead of the `valueOf()`

function. It converts it into a string. I don’t really know why you’d want to do this, maybe you would affect how you print it. I actually don’t even know if `toString()`

can do this.

## [TL;DR] Overloading

Look at this messy video about Matrix Math that you made: https://www.youtube.com/watch?v=NgZAIkDcPkI, at 23:15.

Guess what, there’s a way to fix that!

I don’t know how this one is called. When you say `this`

, it’s an object. But, because objects are associative arrays, you can actually treat `this`

as an associative array! Something like this:

class Matrix { constructor(rows, cols) { this.rows = rows; this.cols = cols; // this.data = [] for (let i = 0; i < this.rows; i++) { this[i] = []; // OMG for (let j = 0; j < this.cols; j++) { this[i][j] = 0; // OMG } } } // . // . // . }

It’s as easy as that!

If you want to, you could even add a `this.length`

variable, and suddenly, you would even be able to iterate over it, with a `for..of`

loop!

# More examples of Simon’s chat contributions on math and coding

Simon is always extremely active in the discussions about the current projects made by/ lectures given by NYU’s Asdociate Professor Daniel Shiffman during his live sessions on the Coding Train channel. He also enjoys “initiating discussions” among the channel’s patrons (grown-up programmers) and Daniel. “Mom, the discussion I initiated is still going on!” I couldn’t possibly post all the coding and math comments/ suggestions that Simon makes in the chats on YouTube, Slack and GitHub (and I don’t believe I should either), but every now and then, I like collecting samples of Simon’s contributing to the discussion:

The small font above says:

Correction: The MST problem does not allow any loops (like A->B, B->C, C->D, D->A again.) So the solution at 2:30 is wrong! In fact, _no wonder it does that_, because Prim’s Algorithm will never find a loop. Here’s why:

Let’s suppose that it could find a loop (let’s say, a loop of 4, so A->B, B->C, C->D, D->A again, but this argument would work the same each way.) Ok, so it will start from A, and mark it as reached. It will check A against B, C and D, find B, and mark B as reached. Then, it will check A against C and D, and B against C and D. and it will find that it should connect B and C, and mark C as reached. Then, it will check A, B and C all against D, and find that it should connect C and D, and mark D as reached. But now, we reach a problem. It *will not* connect D and A, because both are already reached!

Why was it designed like that? Because that’s what the problem says! It’s a Minimum Spanning _Tree_, so it can’t have any loops.

So there you go, that’s why Prim’s algorithm will not find a loop.

# Simon’s Computer Science Algorithm Suggestions

Simon’s suggestion for the Coding Train on GitHub:

Because I like computer science these days, here are some computer science algorithm suggestions:

- Data Structures
- Array
- Linked List
- Hash Table
- Stack
- Queue
- Priority Queue (Binary heap)
- Suffix Array
- Graph Theory
- Graph (general)
- Tree
- Binary Tree
- Full vs. Complete
- BST
- Binary Heap
- AVL Tree
- Red-Black Tree
- Segment Tree
- DFA

- Biparite
- UFDS
- Fenwick Tree
- Min Spanning Tree
- Suffix Tree

- Computational Geometry
- Polygon, etc.

- Algorithms
- Shuffling
- Fisher-Yates Algorithm

- Sorting
- Bubble Sort
- Selection Sort
- Insertion Sort
- Merge Sort
- Quicksort
- Counting Sort
- Radix Sort
- More?
- Even More? (Scroll down to see a GIANT table)

- Traversal / Pathfinding / SSSP
- Basic
- Pre-order
- In-order
- Post-order
- Depth-first
- Breadth-first
- More?

- Shortest Pathfinding
- Dijkstra’s Shortest Path
- A*

- More?
- Even More?

- Basic
- Substring Finding
- Brute-force
- DFA
- KMP
- More?

- Min Spanning Tree
- Brute-force
- Kruskal’s Algorithm
- Prim’s Algorithm(s)

- Max-flow
- Graph Matching
- Cycle Finding
- Convex Hull
- Gift Wrapping
- Graham Scan
- Quickhull
- “The Ultimate Planar Convex Hull Algorithm”
- More?

- Min Vertex Cover
- Brute-force
- MVC
- Approximation

- Traveling Salesman
- Brute-force
- Dynamic Programming
- Approximation

- Steiner Tree

- Shuffling

If you’re brave, Do you want more even after *all of this*?

One last note: **you’re not going to do all of them (probably!)**.

# Simon speaking at the Processing Community Day in Amsterdam

Simon had his first public performance in front of a large audience last Saturday (February 9, 2019): he spoke about his Times Tables Visualization project at the Processing Community Day in Amsterdam!

Simon writes: **You can access the code of the poster and the animation (and the logo for my upcoming company!) and download the presentation in PowerPoint, on GitHub at** **https://github.com/simon-tiger/times_tables**

**If you’d like to buy a printed copy of the poster, please contact me and I’ll send you one. Status: 3 LEFT.**