Live data from Hacker News

How to do hard things

drmaciver.com

101–110 of 123 posts

Re: How to do hard things

#101

I am a 4th semester CS student from Germany and still don't grasp recursion, even though I already took the data structures & algorithms courses. If you did have something like a magic moment where it made sense to you, please enlighten me as I would really like to truly gain an intuition (and implement a parallelized msd-radixsort for learning-purposes because I failed to do this assignment yesterday).

Recursion is simple: It is just a function calling itself. The difficult part is that it is not getting out of control (e.g. never stops).

To make sure your function will stop calling itself you need an exit-condition. So whenever you want to write a recursive function, simply start with a template like this:

  function myFunc(list) {
    // exit condition
    if (list.length == 0) {
      // What should the function do if the exit condition is true
      return
    } else {
      // before recursion
      console.log(list[0])
      
      // recursion
      myFunc(list.slice(1))
      
      // after recursion
    }
  }
So basically you have to think about when your function aborts the recursion, what it does before the recursion (e.g. extract an element from a list), how the recursive call is different from the original call (e.g. the list got reduced by one element) and after what it does after the recursive call (e.g. push a modified element to a stack). By answering those questions you should be able to solve a whole bunch of recursive problems.

Before I learned this pattern, my recursive functions were a mess. Now, they all adhere to that very template and I find it actually fun to write recursive functions as there are some problems which are a lot easier to solve with them.

Re: How to do hard things

#102
post #69

My biggest realization about doing hard things is that I needed to let go of my intellectual entitlement. Just because something is (or seems) effortless to others, doesn't mean it will be the same for me. Part of this entitlement stemmed from a (now eroded by bitter experience) belief that I'm somehow a faster learner than normal, that _I_ don't have to do the work. For example, about seven years ago I wanted to lea…

What was the book of 5000 geometry exercises? I have students who could benefit from such a thing (and I might too!).

Geometry: Seeing, Doing, Understanding by Harold R. Jacobs

Preview: https://books.google.de/books/about/Geometry.html?id=u5o6DwA...

You can purchase a complete solution manual separately, which is very handy.

Re: How to do hard things

#104
post #83

My biggest realization about doing hard things is that I needed to let go of my intellectual entitlement. Just because something is (or seems) effortless to others, doesn't mean it will be the same for me. Part of this entitlement stemmed from a (now eroded by bitter experience) belief that I'm somehow a faster learner than normal, that _I_ don't have to do the work. For example, about seven years ago I wanted to lea…

> Just because something is (or seems) effortless to others, doesn't mean it will be the same for me. I think it's also important to remember it is rarely effortless to others. You just don't see the effort. I was fortunate enough to hang out with some people in college who were valedictorians at their high schools, and would generally be considered smart. They ended up graduating college with 4.0s. Since I hung out…

As much as it hurts me to believe as much, I'm confident that there really are people for whom at least certain things are "basically effortless". I've seen this occur around my peers, especially with music, where some (who already play piano but only by notes) learn to play by ear in a summer, but others are still struggling after five years of daily practice.

Re: How to do hard things

#105

Earlier quoted context omitted.

> (I can't remember the thing now) Don’t worry about the details; it was just a made-up story in the book Art & Fear ; I have never seen any evidence such a pottery class ever existed. https://kk.org/cooltools/art-fear/ > The ceramics teacher announced on opening day that he was dividing the class into two groups. All those on the left side of the studio, he said, would be graded solely on the quantity of work they p…

This story is somewhat true actually if you correct for the literary license taken. James Clear reached out to the authors of Art& Fear and this is his footnote: (Link: https://jamesclear.com/repetitions ) This story comes from page 29 of Art & Fear by David Bayles and Ted Orland. In an email conversation with Orland on October 18, 2016, he explained the origins of the story. “Yes, the ‘ceramics story’ in ‘Art & Fear…

It's a ironic to me that the original inspiration for the story was not ceramics, but photography. My main pastime is photography, and I took this advice to heart and started being as prolific as possible, which is something that digital photography has made easy and compared to film, inexpensive. It was a great relief to just accept that the first attempts at anything are going to be terrible and that failure was a necessary barrier to entry of getting good. Ten years, and tens of thousands of photos later and I've gained a lot of experience and produced some work that I'm proud to call my own.

Re: How to do hard things

#106

My biggest realization about doing hard things is that I needed to let go of my intellectual entitlement. Just because something is (or seems) effortless to others, doesn't mean it will be the same for me. Part of this entitlement stemmed from a (now eroded by bitter experience) belief that I'm somehow a faster learner than normal, that _I_ don't have to do the work. For example, about seven years ago I wanted to lea…

>A year later, guess what? I couldn't remember jack-shit. Moreover, I couldn't solve problems, which is basically the reason I was learning math anyway. Any bystander could have predicted this outcome, but I was blinded by my own entitlement.

I'm a third year university student; I did all the exercises set last year to do well in the exam and over the course of the whole year. And now, only one year later, I can't remember how to do some of the most fundamental problems. I can remember the derivative and integral of trig functions, but the method of doing even moderately challenging exercises with them I don't remember well and I'd need to look it up. I don't know what that signifies, but I have the impression that even just doing the exercises doesn't last long unless you use what you have learned semi-regularly at the least.

Re: How to do hard things

#107
post #77
post #75

Earlier quoted context omitted.

Most valuable things I did not learned at university: * Ignore whole craze toward being cool, participating in random competitions, chasing opposite sex * Keep detailed notes of your days, who did you meet, what did you learned? * Don't worry too much about acquiring every possible new skills that you come across * The most important part of the textbook is exercises and that's not because there would be tests. If yo…

Sounds like you could've used a harder course then, if you picked something that suited you, you wouldn't be able to get through it without most of these.

I _think_ he's saying he learned them, just not at university, or in spite of his time at university...

Re: How to do hard things

#108
post #83

Earlier quoted context omitted.

> Just because something is (or seems) effortless to others, doesn't mean it will be the same for me. I think it's also important to remember it is rarely effortless to others. You just don't see the effort. I was fortunate enough to hang out with some people in college who were valedictorians at their high schools, and would generally be considered smart. They ended up graduating college with 4.0s. Since I hung out…

As much as it hurts me to believe as much, I'm confident that there really are people for whom at least certain things are "basically effortless". I've seen this occur around my peers, especially with music, where some (who already play piano but only by notes) learn to play by ear in a summer, but others are still struggling after five years of daily practice.

Absolutely. There are definitely people where certain things just come easier. You mentioned music, which I have seen. Same with athletics. But even those people often spend way more time practicing than they are given credit for.

Re: How to do hard things

#109

My biggest realization about doing hard things is that I needed to let go of my intellectual entitlement. Just because something is (or seems) effortless to others, doesn't mean it will be the same for me. Part of this entitlement stemmed from a (now eroded by bitter experience) belief that I'm somehow a faster learner than normal, that _I_ don't have to do the work. For example, about seven years ago I wanted to lea…

>A year later, guess what? I couldn't remember jack-shit. Moreover, I couldn't solve problems, which is basically the reason I was learning math anyway. Any bystander could have predicted this outcome, but I was blinded by my own entitlement. I'm a third year university student; I did all the exercises set last year to do well in the exam and over the course of the whole year. And now, only one year later, I can't re…

To add to your point, I think this reinforces the value of spaced repetition learning. It's been show to been one of the best ways to actually retain information. So, as you said, just doing the exercises only gets one so far. You'll need to either use what you learned or at least do refresher exercises to better put what you learned into memory. The benefit is that you may be able to do these refreshers and greater intervals over time, effectively retaining the information longer.

For me personally, there does seem to be a tipping point where what I learned really sticks in my brain and degrades much slower. However, I can't seem to pinpoint where that point happens or if it is even consistent. There are some coding concepts I never forget, and some that seem to leave me within a month.

https://en.wikipedia.org/wiki/Spaced_repetition

https://eric.ed.gov/?id=ED427772

https://www.theguardian.com/education/2016/jan/23/spaced-rep...

Re: How to do hard things

#110

I am a 4th semester CS student from Germany and still don't grasp recursion, even though I already took the data structures & algorithms courses. If you did have something like a magic moment where it made sense to you, please enlighten me as I would really like to truly gain an intuition (and implement a parallelized msd-radixsort for learning-purposes because I failed to do this assignment yesterday).

I'll pitch in with my own intuition; the easiest way to understand it is to view it as a call stack. Using this example function:

  function RecFunc(n, max) {
    let result; // intialize the return variable
    if (n 
When you call the function, we descend down the stack until it hits the exit condition. Notice that `result` is undefined in the upper levels of the stack; when `n` is equal to `max`, the function is finally able to assign a value to `result` and exit:

  | RecFunc
  v   n: 0, max: 3, result: undefined
  |   RecFunc
  v     n: 1, max: 3, result: undefined
  |     RecFunc
  v       n: 2, max: 3, result: undefined
  |       RecFunc
  v         n: 3, max: 3, result: 3
Now that the exit condition has been met, we go back up the stack, returning the result at each step:

  ^ RecFunc
  |   n: 0, max: 3, result: 3
  ^   RecFunc
  |     n: 1, max: 3, result: 3
  ^     RecFunc
  |       n: 2, max: 3, result: 3
  ^       RecFunc
  |         n: 3, max: 3, result: 3
Notice how the call stack resembles stepping through a for-loop:

  var result = 0;
  for (var i=0; i++; i
If you really want to see a mind-blowing example of recursion, step through an implementation of the `compose`[0] function some time. :)

[0] https://github.com/reduxjs/redux/blob/master/src/compose.js

Post reply on HN