Monthly Archives: May 2020

[…] no rational argument will have a rational effect on a man who does not want to adopt a rational attitude.

Karl Popper, The Open Society and Its Enemies

Fizz Buzz in Scheme

I learned about a children’s game called Fizz Buzz today. It turns out that Fizz Buzz is a fairly common programming task that comes up during programming interviews.

Since I am learning to program, I decided to give it a shot.

Here is one way to code a Fizz Buzz procedure in Scheme.
It took me about 5 minutes to think out the solution to this and write the code.

(define (fizzbuzz x)
    (cond ((and (equal? (remainder x 3) 0) (equal? (remainder x 5) 0)) 'fizzbuzz)
          ((equal? (remainder x 3) 0) 'fizz)
          ((equal? (remainder x 5) 0) 'buzz)
          (else se x)))

Update 2020-05-28:

I learned about a new notation called “let” today.

I figured I could improve my Fizz Buzz code by adding “let” to the previous code. This way it becomes easier to alter the “fizz”, “buzz”, and “fizzbuzz” values since they would only have to be altered in one place instead of changing the number in all places in the code.

This was my first solution with “let“:

(define (fizzbuzz x)
    (let ((fizz 3)
          (buzz 5))
      (cond ((and (equal? (remainder x fizz) 0) (equal? (remainder x buzz) 0)) 'fizzbuzz)
          ((equal? (remainder x fizz) 0) 'fizz)
          ((equal? (remainder x buzz) 0) 'buzz)
          (else se x))))

I thought some more about it and figured I could improve on the code even more – rid it of the redundant parts.

Result:

(define (fizzbuzz x)
    (let ((fizz 3)
          (buzz 5))
      (let ((fizzname (equal? (remainder x fizz) 0))
            (buzzname (equal? (remainder x buzz) 0)))
      (cond ((and fizzname buzzname) 'fizzbuzz)
          (fizzname 'fizz)
          (buzzname 'buzz)
          (else se x)))))

Update 2020-05-29:

Adding some explanation to the evolution of above code.

The first code did what it was supposed to do. It gave the right answers to Fizz Buzz for numbers divisible with 3 and 5.

In the next step I added the “let” notation. Adding “let” made the code better because it made it easier to change the numbers from 3 and 5 to any other numbers.
By adding “let” one only needs to change the numbers in one single place of the code. Without “let” one would have to change every singel “3” and “5” that appears in the entire code. Thus there is less room for error after adding “let“. An error would be to eg miss to change one “3” in the code.

In the final step I added “let” to recurring parts of the code as well. By doing this, recurring parts of the code only need to be evaluated once instead of multiple times. This makes the code more efficient.

Weekly Goal Summary 2020-05-22

Period: 2020-05-16 – 2020-05-22
(“Goal weeks” starts on Saturdays and ends on Fridays.)

I met 0 out of 2 main goals for this week.
I met 1 out of 2 secondary goals this week.
I met 1 out of 1 temporary goal this week.


Main Goals

  • Programming / Simply Scheme (minimum 1 chapter / week)
    Not met. Did not finish a chapter.
  • Overreaching & learning (Write down what I know. Work on it and update it once every week.*)
    Not met. Did not write down anything.

Secondary Goals

  • Typing (minimum 30 min / day on average)
    Met. Did average more than 30 min per day.
  • Blog (minimum 1 non-goal related posts / week)
    Not met. Did not post 1 non-goal related post.

Temporary Goals

Shorter term goals. About one week. Mainly focused on working on a particular skill.

No temporary goal for the coming week.


Thoughts

I revised my old goals so that I would not overreach. I still didn’t meet my weekly goals. This time I do not think the main issue was overreaching, but evading.

I did not focus on learning overreaching & learning as I wrote down I would do. I treated it more like a secondary goal and left it for “later” every day. “Later” never came because at the end of the day I didn’t have mental energy to work on this. This coming week I will dedicate time early in the day to working on overreaching & learning.

Programming a did work on to a larger extent. Chapter 6 was fairly long. I finished it on Saturday.


I will post weekly summaries of my goals weekly until I have meet all my goals for three weeks in a row. After that I will most likely only post summaries of my goals on a monthly basis.

Simply Scheme: Chapter 6, Exercise 6.13

My main goal right now is just to learn to code. My main goal right now is not to write the best code that I possibly can.

By first focusing on just learning to code in Scheme I can focus on only that and not on writing the best possible code. This helps me to avoid overreaching (learn to code and write awesome code at the same time) and lets me improve one step at a time. Once I get better at fundamental coding in Scheme, I can focus on writing better code.

Below is how I dealt with exercise 6.13, ch 6, in Simply Scheme. My thinking process, my mistakes and how I solved them.

All my Scheme exercises can be found on Subscribestar in the $2 tier.
From chapter 4 and onwards I write out my thinking process and mistakes.
For chapter 1-3 there are only my solutions.


6.13 Write a better greet procedure that understands as many different kinds of names as you can think of:

> (greet ‘(john lennon))
(HELLO JOHN)

> (greet ‘(dr marie curie))
(HELLO DR CURIE)

> (greet ‘(dr martin luther king jr))
(HELLO DR KING)

> (greet ‘(queen elizabeth))
(HELLO YOUR MAJESTY)

(greet ‘(david livingstone))
(DR LIVINGSTONE I PRESUME?)

I will just focus on the examples given in the exercise. I will not come up with new kinds of names.

Thinking process:
1. A title will always be in front of a persons actual name – eg “dr“, “queen“, “king“.
2. For “dr” greet as “dr” followed by last name. But only if last name is not “jr” / “sr“. If last name is equal to “jr” / “sr” then use the second last name.
3. For “queen” / “king” greet as “your majesty“.
4. Don’t know how to presume if someone is a dr without making a list of all ppl that are dr.

Step 1:

Test the core concept.

(define (greet name)
    (if (equal? (first name) 'dr)
        (se '(hello dr) (last name))
        #f))

Works.


Step 2:

Add more “if” procedures. Add “king” / “queen“.

(define (greet name)
    (if (equal? (first name) 'dr)
        (se '(hello dr) (last name))
        (if (equal? (first name) (member? '(king queen)))
            (se '(hello your majesty))
            (se 'hello (first name)))))

Did not work.
member?” lacking one of its two arguments.

(define (greet name)
    (if (equal? (first name) 'dr)
        (se '(hello dr) (last name))
        (if (equal? (first name) (member? (first name) '(king queen)))
            (se '(hello your majesty))
            (se 'hello (first name)))))

Did not work.
Prints “(hello queen)

Test 1:

Effort to find the problem.

(define (greet name)
    (if (equal? (first name) (member? (first name) '(king queen)))
            (se '(hello your majesty))
            #f))

Prints “#f

Test 2:

(member? 'queen '(king queen))

Prints “#t

I think my mistake is that I am mixing the wrong domains.
member?” is a predicate (a function that returns either #t or #f). Thus “(equal? (first name) (member? (first name) ‘(king queen)))” would be evaluated as (step by step evaluation):
1. (equal? (first name) (member? (first name) ‘(king queen)))
2. (equal? ‘queen (member? ‘queen ‘(king queen)))
3. (equal? ‘queen #t)
4. #f

My “king” / “queen” code is unnecessarily confusing. I can just eliminate the “equal?” part.

(define (greet name)
    (if (equal? (first name) 'dr)
        (se '(hello dr) (last name))
        (if (member? (first name) '(king queen))
            (se '(hello your majesty))
            (se 'hello (first name)))))

Works.


Step 3:

Fix “jr” / “sr“.
jr” / “sr” only matters for ppl that are “dr” as “jr” / “sr” is at the end of the name.

(define (greet name)
    (if (equal? (first name) 'dr)
        (se '(hello dr) (last name))
        (if (and (equal? (first name) 'dr) (member? (last name) '(sr jr)))
            (se '(hello dr) (last (bl name)))
            (if (member? (first name) '(king queen))
                (se '(hello your majesty))
                (se 'hello (first name))))))

Did not work.
Prints “(hello dr jr)” for “> (greet ‘(dr martin luther king jr))“.

It is because the first “if” procedure is true. I need to change places with the first and the second procedure. That should fix it.

(define (greet name)
    (if (and (equal? (first name) 'dr) (member? (last name) '(sr jr)))
            (se '(hello dr) (last (bl name)))
            (if (equal? (first name) 'dr)
                (se '(hello dr) (last name))
                (if (member? (first name) '(king queen))
                    (se '(hello your majesty))
                    (se 'hello (first name))))))

Works.


I don’t know how to do the following without making a list of all ppl who could be considered doctors in advance.

> (greet ‘(david livingstone))
(DR LIVINGSTONE I PRESUME?)

A list of that would be something like:

(if (equal? name '(david livingstone))
        (se 'dr (last name) '(I presume?))
        ...))

Then it would look something like this:

(define (greet name)
    (if (and (equal? (first name) 'dr) (member? (last name) '(sr jr)))
            (se '(hello dr) (last (bl name)))
            (if (equal? (first name) 'dr)
                (se '(hello dr) (last name))
                (if (member? (first name) '(king queen))
                    (se '(hello your majesty))
                    (if (equal? name '(david livingstone))
                        (se 'dr (last name) '(I presume?))
                        (se 'hello (first name)))))))

Works.

Goal: Typing Goal Update – 6 Weeks In

Results, May 19th

  • Mean WPM this time: 42.77
  • Mean WPM test 5 weeks: 42.40
  • Mean WPM test 4 weeks: 38.69
  • Mean WPM test 3 weeks: 38.34
  • Mean WPM test 2 weeks: 34.67
  • Mean WPM test 1 week: 36.77
  • Mean WPM first test: 32.27 (only did one test run)
  • Mean Accuracy this time: 96.17%
  • Mean Accuracy test 5 weeks: 97.30%
  • Mean Accuracy test 4 weeks: 92.88%
  • Mean Accuracy test 3 weeks: 93.35
  • Mean Accuracy test 2 weeks: 91.69%
  • Mean Accuracy test 1 week: 94.65%
  • Mean Accuracy first test: 93.83% (only did one test run)

Reflections

Stable on new level.

I still get stressed out during the test runs when I make a mistake and it takes me a significant amount of time to fix it.

I will continue with primarily typingclub.com.

Focus will continue to be accuracy.

Training Plan & Tools

I still roughly do three sessions per day. I try to do a minimum of 30′ of typing training in total per day.

I do not move forward from one exercise to the next before I hit at least 97% accuracy on the exercise undertaken.

I have been using the following tools since the last test:

  • typingclub.com (Speed and accuracy – now includes capital letters, symbols, and numbers.)

From now on I will do the typing tests once a month instead of once a week.
(Training will continue on daily basis.)

Criticism Wanted

Do you have any criticism of my approach? Do you know a better way for me to reach this goal of mine? If you do, I would appreciate it if you let me know by posting it in the comments.

Previous Posts on Typing Goal

Goal: Learn to type faster with high accuracy (2020-04-07)
Goal: Typing Goal Update – 1 Week In (2020-04-14)
Goal: Typing Goal Update – 2 Weeks In (2020-04-21)
Goal: Typing Goal Update – 3 Weeks In (2020-04-28)
Goal: Typing Goal Update – 4 Weeks In (2020-05-05)
Goal: Typing Goal Update – 5 Weeks In (2020-05-12)

Weekly Goal Summary 2020-05-16 (& New Goal Revisions)

Period: 2020-05-09 – 2020-05-15
(“Goal weeks” starts on Saturdays and ends on Fridays.)

I met 0 out of 3 main goals for this week.
I met 1 out of 2 secondary goals this week.

Old Goals (up until 2020-05-15)

Main Goals

  • Programming / Simply Scheme (minimum 2 chapters / week)
    Not met. Finished one chapter only. Chapter 5. 
  • YESNO Philosophy (post & discuss at least 1 question with ET / Alisa / week)
    Not met. Did not discuss anything from YESNO content.
  • Overreaching & learning
    Not met. Did not have a concrete goal for this.

Secondary Goals

  • Typing (minimum 30 min / day)
    Not met. Tuesday I did less than 30 min. All other days I did at least 30 min.
  • Blog (minimum 1 non-goal related posts / week)
    Met. Posted 1 non-goal related post.

Thoughts

I am not meeting my goals. I am overreaching. I am making some changes so that I can start reaching my goals and stop overreaching.

Once I start consistently meeting my goals, I can add more ambitious goals.

I pursued this the wrong way. In “Life, Overreaching and Correcting Error“, ET writes (my bold emphasis added):

Don’t jump into the deep end; don’t sit in the shallow end forever; go step by step. (To do this, you need to figure out what you can do successfully, with a manageable error rate. That’s best accomplished by doing something really easy and succeeding, then moving forward from there with big steps, until the first failure. To find your skill level, *don’t start from the deep end and work backwards with a succession of failures* until one success; instead start from the shallow end and work forward with a succession of successes.)

I started from the deep end.

  1. Change 1: Focus on overreaching and learning to learn to understand them better and remove YESNO as a main goal for the time being.
  2. Change 2: Goal to do 1 chapter per week of Simply Scheme instead of 2 chapters.
  3. Change 3: Change typing goal to “minimum 30 min per day on average” from “minimum 30 min / day“. This way I do not fail the whole goal without being able to fix it if I for some reason miss 30 min of typing on one particular day.

New Goals (from 2020-05-16)

Main Goals

  • Programming / Simply Scheme (minimum 1 chapter / week)
  • Overreaching & learning (Write down what I know. Work on it and update it once every week.*)

Secondary Goals

  • Typing (minimum 30 min / day on average)
  • Blog (minimum 1 non-goal related posts / week)

Temporary Goals

Shorter term goals. About one week. Mainly focused on working on a particular skill.


* ET in “Non-Overreaching Learning” on Subscribestar: “1. Consider and write down what you know. 2. Work on things near the borders of your knowledge. 3. Expand your knowledge so new, additional stuff is near the borders. 4. Repeat. Add the new knowledge to your list/diagram of what you know. Reevaluate where the borders are and what’s near them. Work on stuff near the new borders.”

Young persons who hold that conviction [that ideas matter, that truth matters], do not have to “throw off the leading conformity of the only society they have known.” They do not conform in the first place: they judge and evaluate; if they accept any part of the prevalent social trends, it is through intellectual agreement (which may be mistaken), not through conformity. They do not need to know different types of society in order to discover the evils, falsehoods or contradictions of the one in which they live: intellectual honesty is the only tool required.

Ayn Rand, “The Inexplicable Personal Alchemy,”
Return of the Primitive: The Anti-Industrial Revolution

Goal: Typing Goal Update – 5 Weeks In

Results, May 12th

  • Mean WPM this time: 42.40
  • Mean WPM test 4 weeks: 38.69
  • Mean WPM test 3 weeks: 38.34
  • Mean WPM test 2 weeks: 34.67
  • Mean WPM test 1 week: 36.77
  • Mean WPM first test: 32.27 (only did one test run)
  • Mean Accuracy this time: 97.30%
  • Mean Accuracy test 4 weeks: 92.88%
  • Mean Accuracy test 3 weeks: 93.35
  • Mean Accuracy test 2 weeks: 91.69%
  • Mean Accuracy test 1 week: 94.65%
  • Mean Accuracy first test: 93.83% (only did one test run)

typing progress 2020-05-12

Reflections

Progress.

Focusing on accuracy for a week payed off. Not making mistakes improves WPM as well, as less time is wasted on correcting errors (this is true not only for typing but for all things regarding error correction).

I still get stressed out during the test runs when I make a mistake and it takes me a significant amount of time to fix it.

I will continue with primarily typingclub.com during next week. It has the most parts of actual writing (eg capital letters, symbols, and full text). Also I like using it.

Focus will continue to be accuracy.

Training Plan & Tools

I still roughly do three sessions per day. I try to do a minimum of 30′ of typing training in total per day.

One change from last week is that I do not move forward from one exercise to the next before I hit at least 97% accuracy on the exercise undertaken.

I have been using the following tools since the last test:

  • typingclub.com (Speed and accuracy – now includes capital letters, symbols, and numbers.)

Criticism Wanted

Do you have any criticism of my approach? Do you know a better way for me to reach this goal of mine? If you do, I would appreciate it if you let me know by posting it in the comments.

Previous Posts on Typing Goal

Goal: Learn to type faster with high accuracy (2020-04-07)
Goal: Typing Goal Update – 1 Week In (2020-04-14)
Goal: Typing Goal Update – 2 Weeks In (2020-04-21)
Goal: Typing Goal Update – 3 Weeks In (2020-04-28)
Goal: Typing Goal Update – 4 Weeks In (2020-05-05)

Weekly Goal Summary 2020-05-09

Period: 2020-05-02 – 2020-05-08
(“Goal weeks” starts on Saturdays and ends on Fridays.)

I met 0 out of 2 main goals for this week.
I met 2 out of 3 secondary goals this week.

Main Goals

  • Programming / Simply Scheme (minimum 2 chapters / week)
    Not met. Finished one chapter only. Chapter 5. 
  • YESNO Philosophy (post & discuss at least 1 question with ET / Alisa / week)
    Not met. Did not discuss anything from YESNO content.

Secondary Goals

  • Typing (minimum 30 min / day)
    Met. I did a minimum of 30 min / day this week.
  • Evaporating clouds (learn basics and practice making some each week)
    Not met. Did not make any evaporating clouds.
    I am removing this goal from next week on and adding a new main goal: work on understanding overreaching & learning.
  • Blog (minimum 1 non-goal related posts / week)
    Met. Posted 1 non-goal related post.

Goal: Typing Goal Update – 4 Weeks In

Results, May 5th

  • Mean WPM this time: 38.69
  • Mean WPM test 3 weeks: 38.34
  • Mean WPM test 2 weeks: 34.67
  • Mean WPM test 1 week: 36.77
  • Mean WPM first test: 32.27 (only did one test run)
  • Mean Accuracy this time: 92.88%
  • Mean Accuracy test 3 weeks: 93.35
  • Mean Accuracy test 2 weeks: 91.69%
  • Mean Accuracy test 1 week: 94.65%
  • Mean Accuracy first test: 93.83% (only did one test run)

 

typing progress 2020-05-05

Reflections

Still stuck.

I have improved on capital letters and symbols. I do not have to look at the keyboard to find them.

I do get stressed out during the test runs when I make a mistake and it takes me a significant amount of time to fix it.

I will continue with primarily typingclub.com during next week. It has the most parts of actual writing (eg capital letters, symbols, and full text). Also I like using it.

Focus will continue to be accuracy.

Training Plan & Tools

No change. I still roughly do three sessions per day. I try to do a minimum of 30′ of typing training per day.

I have been using the following tools since the last test:

  • typingclub.com (Speed and accuracy – so far no capital letters but includes symbols.)

Criticism Wanted

Do you have any criticism of my approach? Do you know a better way for me to reach this goal of mine? If you do, I would appreciate it if you let me know by posting it in the comments.

Previous Posts on Typing Goal

Goal: Learn to type faster with high accuracy (2020-04-07)
Goal: Typing Goal Update – 1 Week In (2020-04-14)
Goal: Typing Goal Update – 2 Weeks In (2020-04-21)
Goal: Typing Goal Update – 3 Weeks In (2020-04-28)