Day #15: First Week in Review, and algorithm challenges: this.Bind, recursive RockPaperScissors, mergeSort & insertionSort



Subscribe to our newsletter

By subscribing, you agree with Revue’s Terms of Service and Privacy Policy and understand that #100 Days of Code will receive your email address.

Puppy Nomadic
Puppy Nomadic
This was the end of my first week at CodeSmith Immersive! The data structures and algorithms questions were a lot of fun to do via pair programming. I really appreciated my partners during these first three units.
The Algorithms questions on Saturday were particularly tricky, and I learned a lot from working through them with my partner, Aliya. Here are some of the most interesting problems:

Return a function with a context bound to this using closure.
  1. Create a new method in our context object and assign it to the passed in function.
  2. Return a function which returns the invocation of our new method
function functionBind(func, context) {
const copyContext = {...context};
copyContext.boundFunc = func;
return function() {
return copyContext.boundFunc();
const mattObj = {
name: 'matt',
shout: function() {
let boundShout = functionBind(mattObj.shout, mattObj);
Using recursion and a nested helper function, calculate all the possible outputs of num number of tosses.
(This was a particular challenging problem to solve, and we implemented a while loop version of this code. The recursive solution is just extremely beautiful.)
function rockPaperScissors(num) {
if (num === 0) return [];
const createCombo = (roundsLeft, sequence) => {
if (roundsLeft === 0) return possibleCombos.push(sequence);
createCombo(roundsLeft-1, sequence.concat('rock'));
createCombo(roundsLeft-1, sequence.concat('paper'));
createCombo(roundsLeft-1, sequence.concat('scissors'));
const possibleCombos = [];
createCombo(num, []);
return possibleCombos;
Extra grateful for Simon Chen, our fellow, who was amazing at mentoring explaining problems with clarity and precision.
We also went over mergeSort() and talked about why it is quasilinear, with O(nLog(n)), since it is a divide and conquer algorithm (logarithmic) with a merge() function that iterates through all the parts (constant time).
In another entry, I’ll write more about mergeSort() vs. insertionSort() and other sorting algorithms.
Implement Merge Sort Algorithm in JavaScript. | by Nwafor Jude | Analytics Vidhya | Medium
Sorting Algorithms Animations | Toptal®
Extra Learning
This weekend, I had thought it might be nice to spend some time implementing the Extensions data structures: graphs, tries, etc. As well as do part 2 of the algorithms challenges.
But instead, I caught up with high school and college friends, and spent time with family. Also went bike riding with my partner and played Wii with my brother. It’s great to have the break to be with people I love, and I don’t think I could do this program if I didn’t have Saturday night and Sunday off completely.
Having balance, joy, and lots of rest is also super-important to keep this sustainable!
Week one has been awesome! Looking forward to DOM manipulation in week two.
Did you enjoy this issue? Yes No
Puppy Nomadic
Puppy Nomadic @puppynomadic

Let's pull each other up by our Bootstrap.js 🪴 👩🏻‍💻 🦮

=== Journey of software craftsmanship ===

{"Formerly": ["nonprofit community organizer", "teacher", "researcher", "government director"],
"Future": ["software engineer", "web3 dev", "developer advocate", "technical program manager"]

In order to unsubscribe, click here.
If you were forwarded this newsletter and you like it, you can subscribe here.
Created with Revue by Twitter.