Coding, Contributing, JavaScript, Milestones, Server Side Programming, Simon's Own Code

Question Bot

Simon has built a question bot that will collect questions on The Coding Train Discord so that Daniel Shiffman can answer them during the following live session.

This is something Simon worked on for days and he was thrilled to be able to present a working bot to Daniel. The only issue that remains unresolved is whether the mods should control the bot via a secret password or should a more advanced security system be developed. Daniel has decided to take a long break from live streaming, so the whole project probably won’t be revived until the streams resume. In any case, as Simon has put it, “I know, it’s messy, but it works. And that’s what’s important to me”.

Simon has also created several other bots (and built a separate Discord playground where other people can test their bots as well). He has been doing quite a lot of server side programming lately.

The code is on GitHub: https://github.com/simon-tiger/Question-Bot

The website is on Heroku: http://questionbot-discord.herokuapp.com/

Simon’s “question-answering round” Discord bot is a clone of CJ (Coding Garden)’s VOX system.

Coding, Community Projects, Computer Science, Contributing, Geometry Joys, JavaScript, Lingua franca, live stream, Machine Learning, Math and Computer Science Everywhere, Math Riddles, Math Tricks, Milestones, Murderous Maths, Notes on everyday life, Physics, Python, Set the beautiful mind free, Simon makes gamez, Simon teaching, Simon's Own Code, Simon's sketch book, Thoughts about the world

New Friends. New Horizons.

This is a little video compilation of a few moments I captured Simon talking to his new peers in April 2020

Thanks to the lock-down, Simon’s got new friends. For a little over a month now, he has been part of exciting daily discussions, challenging coding sessions and just playing together with his new gang (warning: playing always involves math). We’ve never seen him like this before, so drawn to socializing with his peers, even taking the lead in some meetings and initiating streams.

And then we realized: this is how social Simon is once he meets his tribe and can communicate in his language, at his level. Most of his new friends are in their late teens and early twenties. Most of them didn’t use to hang out together before the crisis, probably busy with college, commuting, etc. The extraordinary circumstances around covid-19 has freed up some extra online time for many talented young people, creating better chances to meet like-minded peers across the world. Finally, Simon has a group of friends he can really relate to, share what he is working on, ask for constructive help. And even though he is the youngest in the group, he is being treated as an equal. It’s beautiful to overhear his conversations and the laughter he shares with the guys (even though sometimes I wish he wasn’t listening to a physics lecture simultaneously, his speakers producing a whole cacophony of sound effects, but he likes it that way and seems to be able to process two incoming feeds at once).

Last week, Simon took part in a World Science Scholars workshop by Dr. Ruth Gotian, an internationally recognized mentorship expert. The workshop was about, you guessed it, how to go about finding a mentor. One of the things that struck me most in Dr. Gotian’s presentation was her mentioning the importance of ‘communities of practice’. I looked it up on Etienne Wenger’s site (the educational theorist who actually came up with the term in the 1990s):

A community of practice is a group of people who share a concern or a passion for something they do, and learn how to do it better as they interact regularly. This definition reflects the fundamentally social nature of human learning. It is very broad. It applies to a street gang, whose members learn how to survive in a hostile world, as well as a group of engineers who learn how to design better devices or a group of civil servants who seek to improve service to citizens. their interactions produce resources that affect their practice (whether they engage in actual practice together or separately).

It is through the process of sharing information and experiences with the group that members learn from each other, and have an opportunity to develop personally and professionally, Wenger wrote in 1991. But communities of practice isn’t a new thing. In fact, it’s the oldest way to acquire and imperfect one’s skills. John Dewey relied on this phenomenon in his principle of learning through occupation.

It has been almost spooky to observe this milestone in Simon’s development and learn the sociological term for it the same month, as if some cosmic puzzle has clicked together.

Of course, it would be a misrepresentation to say nothing of the internal conflict the new social reality unveiled in my mothering heart as I struggled to accept that Simon started skipping Stephen Wolfram’s livestreams in favour of coding together with his new friends. 👬Yet even those little episodes of friction we experienced have eventually led to us understand Simon better. We sat down for what turned into a very eye-opening talk, which involved Simon asking me to take down the framed Domain of Science posters we’d recently put up above his desktop and pointing to those infographics depicted on the posters that represented the areas of his greatest interest.

we got our posters at the DFTBA shop

Simon simply guided us through the Doughnut of Knowledge, Map of Physics, Map of Computer Science and Map of Mathematics posters as if were on tour inside his head. And he made it clear to us that he seriously preferred pure mathematics, theoretical computer science and computer architecture and programming to applied mathematics (anything applied, really) and even computational physics, even though he genuinely enjoyed cosmology and Wolfram’s books.

“Mom, you always think that what you’re interested in is also what I’m interested in”, he told me openheartedly. It was at that moment it hit me he had grown up enough to gain a clearer vision of his path (or rather, his web). That I no longer needed to absolutely expose him to a broadest possible plethora of the arts and sciences within the doughnut of knowledge, but that from now on, I can trust him even more as he ventures upon his first independent steps in the direction he has chosen for himself, leaning back on me when necessary.

So far, in just one month, Simon has led a live covid-19 simulation stream, programming in JS as he got live feedback from his friends, cooperated on a 3D rendering engine in turtle (🤯), co-created Twitch overlays, participated in over a hundred Clashes of Code (compelling coding battles) and multiple code katas (programming exercises with a bow to the to the Japanese concept of kata in the martial arts).

example of a Clash of Code problem
e of a Clash of Code problem
This is Simon’s code in one of the Clashes of Code (he won this round from 6 other players). Such programming battles last somewhere between 5 and 15 minutes and come in three modes: fastest mode (in which you must complete the puzzle as fast as possible), shortest mode (you need to write the lowest code size) and reverse mode (you have to guess what to do by observing the provided set of tests). Simon especially likes the last mode, because you have to find the code by finding patterns in the given test cases, which appeals to his mathematical talent.
CJ from the Coding Garden discussing Simon’s solution
Simon working on a 3D renderer project together with his friends
Simon came up with a plan to work on the 3D renderer

Last month, ten young programmers including Simon formed a separate “Secret Editors’ Club Riding Every Train” group on Discord, uniting some “nice and active” people who met on The Coding Train channel (they also included Dan Shiffman in the group). Simon really enjoys long voice chats with the other secret editors, going down the rabbit holes of math proofs and computer algorithms. Last Tuesday, he was ecstatic recounting his 3-hour call with his new peer Maxim during which Simon managed to convince Maxim that 0.999… equals 1 by “presenting a written proof that involved Calculus”:

We even talked about infinity along the way, aleph null and stuff. There was a part where he almost won, because of the proof I showed him when we talked about infinities. I was almost stumped.

The guys have now inspired Simon to take part in the Spring Challenge 2020 on CodingGame.com, a whole new adventure. To us, the lockdown experience has felt like an extra oxygen valve gone open in our world, another wall gone down, another door swung open, all allowing Simon to breathe, move and see a new horizon.

Simon trying to explain why he didn’t fulfil a promise, he has finally found the people who speak his language 🙂
Coding, Geometry Joys, JavaScript, Milestones, Murderous Maths, Simon teaching, Simon's Own Code, Simon's sketch book

Space-filling Curves in p5.js.

Simon prepared this project as a community contribution for The Coding Train (Simon came up with his own way to draw the Hilbert Curve and added interactive elements to enable the user to create other colourful space-filling curves (Hilbert Curve, Z-order Curve, Peano Curve and more!). You can see Daniel Shiffman’s Hilbert Curve tutorial and coding challenge on The Coding Train’s website (including a link to Simon’s contribution) via this link: https://thecodingtrain.com/CodingInTheCabana/003-hilbert-curve.html

Interactive full-screen version, allowing you to change the seed and the grid size: https://editor.p5js.org/simontiger/full/2CrT12N4

Code: https://editor.p5js.org/simontiger/sketches/2CrT12N4

Screen shot of The Coding Train website with a link to Simon’s contribution
Coding, Contributing, Group, JavaScript, live stream, Milestones, Notes on everyday life, Simon teaching

How Simon takes part in the Coding train live sessions

Every live session Daniel Shiffman mentions Simon several times, usually because Simon gives good feedback/ advice. On the other end, Simon is invigorated and jumping about the room. Sometimes resulting in serious bumps against the furniture.

Coding, Computer Science, Contributing, JavaScript, Milestones, Murderous Maths, Notes on everyday life, Simon makes gamez, Simon teaching, Simon's Own Code, Simon's sketch book

Simon Builds a Chess AI with Minimax

I’ve been terrible at keeping this blog up to date. One of Simon’s best project in December 2019 was creating a chess robot and I haven’t even shared it here.

We were joking how this is Simon’s baby and her name is Chessy. Simon also made an improved version with a drop-down menu allowing to choose 1 to 5 steps ahead difficulty level (warning: levels 4 and 5 may run quite slowly): https://chess-ai-user-friendly–simontiger.repl.co/

Code: https://repl.it/@simontiger/Chess-AI-User-friendly

Simon’s original 2-steps-ahead game: https://chess-ai–simontiger.repl.co/ Code: https://repl.it/@simontiger/Chess-AI

While researching how to apply the Minimax algorithm, Simon has relied on Sebastian Lague’s Algorithms Explained – minimax and alpha-beta pruning; Keith Galli’s How does a Board Game AI Work? (Connect 4, Othello, Chess, Checkers) – Minimax Algorithm Explained; a Medium article on Programming a Chess AI: A step-by-step guide to building a simple chess AI by Lauri Hartikka; of course, The Coding Train’s challenge Tic Tac Toe AI with Minimax; and What is the Minimax Algorithm? – Artificial Intelligence by Gaurav Sen.

Simon contributed his chess robot to the MINIMAX coding challenge page on the Coding Train website:

And naturally we’ve had a lot of fun simply playing with Chessy as a family:

Coding, Community Projects, Contributing, Experiments, JavaScript, live stream, Machine Learning, Milestones, Physics, Simon's Own Code

Simon’s Random Number Generator

This one’s back from mid-October, forgot to post here.

Simon created a random number generator that generates a frequency, and then picks it back up. Then, it calculates the error between the generated frequency and the picked up frequency. This is one of my community contributions for a Coding Train challenge: https://thecodingtrain.com/CodingChallenges/151-ukulele-tuner.html

Link to project: https://editor.p5js.org/simontiger/sketches/eOXdkP7tz
Link to the random number plots: https://www.wolframcloud.com/env/monajune0/ukalele%20tuner%20generated%20random%20number%20analysis.nb
Link to Daniel Shiffman’s live stream featured at the beginning of this vid: https://youtu.be/jKHgVdyC55M

plot of the random numbers generated by Simon’s ukulele tuner random number generator (plotted in Wolfram Mathematica)
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, 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!).