Category Archives: Programming

I Finished “Ruby Programming for Everyone”

I finished “Ruby Programming for Everyone“.

The online course basically starts out as short walkthrough videos of the basics in Ruby. The course pretty much lacks exercises for the most part. It is mostly a “code along”. I recommend you play a little with the code after each video to learn faster.
The last part, part 3, covers “classes” and is the best part of this course in my opinion. Part 3 is ok.

The teacher says things like “Ruby programmers tend to really like the ‘each loop’. They use it for everything, seems like. So it’s sort of the cool thing to do.” (from the “each loops” video).
I’m interested in learning to write good code, not to do the “cool thing” for whatever reason. I guess that there is a good reason for the preference of “each loops” in Ruby. There is however no explanation to what that is in this course – just that it is “cool”. I do not care if it is considered “cool” or not.

Programming for Everyone” is ok. It is nothing special. My recommendation would be to find something that has you being more hands on from the start instead if you are a complete beginner. Once you learn some basics you can come and check out the 3rd part of the course (“classes”) if you want to.

I Finished “Ruby Essential Training Part 1: The Basics”

I finished Ruby Essential Training Part 1: The Basics.

The online course started out ok but it was more of a demo of what one can do with the basics in Ruby. Not enough time is spent on actually get solid at the basics.

Ruby Essential Training Part 1: The Basics” works through how to do basic things in Ruby.

It works through too much stuff too fast for my taste. I would like a lot more exercises for each part. As it is now there is a “challenge” at the end of each chapter. I would learn more and better if there were challenges after each lecture / video instead of one challenge after a full block of videos.
There are examples to work with in every lecture / video, but those are not enough to actually learn.

The lectures / videos show alternative ways to do most things and then says that it is not common practice in Ruby. This is confusing for a beginner. Just show one way to do it and say there are other ways and link to the other ways. That way it would be less confusing.
The teacher doesn’t always explain some basic stuff but treats it as one should already know it. Sometimes I didn’t know that stuff.
Sometimes the teacher started to use short hand in his examples and solutions. There is no need to do that on beginner level in my opinion.

I wouldn’t recommend “Ruby Essential Training Part 1: The Basics” as a good start if you are completely new to programming.

I Am Learning Ruby

I have decided to start learning Ruby and to make a serious effort learning it.

My primary learning resources will be:

I will also check some videos on YouTube about learning Ruby at times.

I might or might not add new Ruby learning resources in the future on the blog to this post.

Commissions Earned on Amazon links.


Edit 2020-10-06:

I bought the book “Learn to Program (Facets of Ruby) 2nd Edition“. I will add this to my current learning resources.


Edit 2020-10-08:

I finished “Ruby Essential Training Part 1: The Basics“. Not a fan. I added “Ruby Programming For Everyone” to the above list.


Edit 2020-10-08:

I finished “Ruby Programming For Everyone“. It was ok. I added Pragmatic Studio’s three Ruby courses. It seemed by far the most ambitious course and had some good reviews. I bought their “mastery bundle” on Ruby (includes: “Ruby Course“, “Ruby Blocks Course“, “Rails Course“).

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.

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)

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)

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)

Goal: Typing Goal Update – 3 Weeks In

Results, April 28th

  • Mean WPM this time: 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: 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-04-28

Reflections

I seem to have hit a plateau.

My biggest problems during the typing test are capital letters and symbols. I will utilise the tools that use capital letters and symbols in my training more in the coming week, to see if that helps me improve.

I am not honest with myself regarding accuracy being the focus. I usually try to go faster instead of being more accurate. That might be a reason to why my accuracy is not improving at all.
I will put more effort into being more accurate when I type train this coming week.

Training Plan & Tools

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:

  • zty.pe (Speed over accuracy – no capital letters or symbols – game.)
  • typeracer.com (Speed and accuracy – includes capital letters and symbols – compete w/ other ppl.)
  • typingclub.com (Speed and accuracy – so far no capital letters but includes symbols.)
  • KeyKey (Speed and accuracy – no capital letters or symbols (might have these if you have a US keyboard).)

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)