W3D2: Sleep is goot



Gnarly stomachache this morning. Could not bring myself to wake up and get ready, so I texted Richard not to pick me up.

  Mak-gul-li (Alcoholic rice beverage) and Bossam (Boiled pork belly) = The best of combinations

One of my best friends, Minjae, took me to go have bossam + mak-gul-li last night. I'm not sure if it's because of the food, but I know that all the stress has been contributing to the knot in my stomache. I told MKS I'd be late and took this chance to get some more sleep in.

I felt really bad for my sprint partner for missing out on a few hours of pairing. But no worries! I finally got to the ROC, only to find him with a graph already finished.


It's surprising how amazing sleep is. Really clears up your mind so that next day I can look at my code again to find obvious mistakes that were not so obvious the previous night

In the D3 sprint we were two take 2 sets of data, with D3 make a graphic/visual out of the two, and present them to both junior and senior cohorts. They were very flexible on what was allowed and what was not.

We had some free time after the presentations, I put smash on my laptop and people started gathering like moths around a fire (shoutouts to Elly)
                                                             
Excuse me for the less-than-fruitful post last night. I've been having mood swings.


What we did today:
1. Toy Problem

Tree Depth-First Select


Implement a depth-first method on a tree class.
DFSelect accepts a filter function, calls that function on each of the nodes in Depth First order, and returns a flat array of node values of the tree for which the filter returns true.
Example:
var root1 = new Tree(1);
var branch2 = root1.addChild(2);
var branch3 = root1.addChild(3);
var leaf4 = branch2.addChild(4);
var leaf5 = branch2.addChild(5);
var leaf6 = branch3.addChild(6);
var leaf7 = branch3.addChild(7);

root1.DFSelect(function (value, depth) {
  return value % 2 === 1;
}) //=> [1, 5, 3, 7]

root1.DFSelect(function (value, depth) {
  return depth === 1;
}) //=> [2, 3]
 CODE TEMPLATE:
var Tree = function(value){
  this.value = value;
  this.children = [];
};
Tree.prototype.DFSelect = function(filter) {  
  //YOUR CODE HERE
  var results = [];
  return results;
};
Tree.prototype.addChild = function(child){
  if (!child || !(child instanceof Tree)){
    child = new Tree(child);
  }
  if(!this.isDescendant(child)){
    this.children.push(child);
    // this.children[this.children.length - 1].depth += 1;
  }else {
    throw new Error("That child is already a child of this tree");
  }
  // return the new child node for convenience
  return child;
};
Tree.prototype.isDescendant = function(child){
  if(this.children.indexOf(child) !== -1){
    // `child` is an immediate child of this tree
    return true;
  }else{
    for(var i = 0; i < this.children.length; i++){
      if(this.children[i].isDescendant(child)){
        // `child` is descendant of this tree
        return true;
      }
    }
    return false;
  }
};
Tree.prototype.removeChild = function(child){
  var index = this.children.indexOf(child);
  if(index !== -1){
    // remove the child
    this.children.splice(index,1);
  }else{
    throw new Error("That node is not an immediate child of this tree");
  }
};

2. Continue pair programming on D3

3. D3 presentations
Part of the sprint was also to present our graphs to the cohorts (29 and 32). We hard coded Smash Melee stats into an array of objects and made a transitioning graph out of it. This took most of our time-- Daniel told me he made his graph in 10 minutes (questionable????). His data set was on the number of the unemployed throughout the years, which was downloaded as a json file.

1.26.16

No comments:

Post a Comment