Community Projects, Contributing, Math Riddles, Math Tricks, Milestones, Murderous Maths, Simon teaching, Simon's sketch book

Simon having fun solving math puzzles on Twitter.

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!

Coding, Community Projects, Contributing, Notes on everyday life, Python, Simon teaching, Simon's Own Code, Together with sis

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):

Contributing, Milestones, Murderous Maths, Museum Time, Physics, Trips

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!

Coding, Community Projects, Computer Science, Contributing, JavaScript, Milestones, Notes on everyday life, Simon teaching, Simon's Own Code

Simon’s new “giant project”: Sorting Visualizations

this video sums up more than one week of hard work

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’s tweet about the project

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.

Coding, Community Projects, Computer Science, Contributing, JavaScript, Murderous Maths, Physics, Simon's Own Code, Simon's sketch book

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’s suggestions during a patron-only live session yesterday
a screenshot of Simon’s community contribution published on the Coding Train website

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

screenshot of the optimized version
Coding, Computer Science, Contributing, Group

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!

Coding, Community Projects, Computer Science, Contributing, Geometry Joys, Group, Milestones, Murderous Maths, Notes on everyday life

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:

Simon contributing to a discussion prior to a live session on ray tracing
Simon contributing to Daniel Shiffman’s tutorial on the computational geometry “minimum spanning tree” problem

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.

Coding, Computer Science, Contributing, Group, Milestones

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?
    • Substring Finding
    • 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

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!).

Coding, Coding Everywhere, Community Projects, Contributing, Crafty, Geometry Joys, Group, Java, Milestones, Murderous Maths, Notes on everyday life, Simon teaching, Simon's Own Code, Together with sis, Trips

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 speaking at Processing Community Day 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.

One of the tweets about Simon’s presentation
Simon next to his poster after the presentation
Working on his presentation the day before
Waiting to speak
Experimenting with other projects at the community day
At the entrance to the venue, with the poster still packed
There was a lot of interest in Simon’s project