Code With ADHD
  • Home
  • Posts
  • About

Posts

Thoughts from a 46 year old programmer with ADHD

April 11, 2025

Learn to Code In 5 Minutes A Day: Lesson 14

Solution for IX and X Does your solution look like this: package main func roman(number int) string { result := "" if number >= 10 { result = "X" number = number - 10 } if number >= 9 { result = "IX" number = number - 9 } if number >= 5 { result = "V" number = number - 5 } if number == 4 { result = "IV" number = number - 4 } for i := 0; i < number; i++ { result += "I" } return result } Do your tests look like this?
read more
April 7, 2025

Learn to Code In 5 Minutes A Day: Lesson 13

Lesson 12 Solution So yesterday you worked on converting 6, 7, and 8 to VI, VII, and VIII. Does your solution look like this? romans_test.go: func TestRoman6(t *testing.T) { result := roman(6) expected := "VI" if result != expected { t.Errorf("result was incorrect, got: %v, want: %v.", result, expected) } } func TestRoman7(t *testing.T) { result := roman(7) expected := "VII" if result != expected { t.Errorf("result was incorrect, got: %v, want: %v.
read more
April 3, 2025

Learn to Code In 5 Minutes A Day: Lesson 12

Lesson 11 Solution Yesterday you were supposed to add a unit test and code for the roman numeral 5. Did you come up with this? Unit Test: func TestRoman5(t *testing.T) { result := roman(5) expected := "V" if result != expected { t.Errorf("result was incorrect, got: %v, want: %v.", result, expected) } } Run the Test Did you remember to run the test first before trying to solve it? go test --- FAIL: TestRoman5 (0.
read more
March 30, 2025

Learn to Code In 5 Minutes A Day: Lesson 11

Lesson 10 Solution: Roman Numeral 4 Did you get a solution that looks something like this? func roman(number int) string { result := "" if number == 4 { return "IV" } for i := 0; i < number; i++ { result += "I" } return result } or did you get a solution that looks like this? package main func roman(number int) string { result := "" if number == 4 { result = "IV" number = number - 4 } for i := 0; i < number; i++ { result += "I" } return result } Either way works:
read more
November 3, 2024

Learn to Code In 5 Minutes A Day: Lesson 10

Lesson 9 Solution: Refactoring Yesterday’s exercise was to see if you could figure out a way to refactor our code so far. In other words, we wanted to see if we could simplify this code: func roman(number int) string { if number == 3 { return "III" } if number == 2 { return "II" } return "I" } The way we do this is with a loop. A loop lets us repeat things over and over and is one of the fundamental tools of programming.
read more
June 10, 2024

Learn to Code in 5 Minutes a Day: Lesson 9

Lesson 8 Solution: Roman Numeral III Yesterday’s exercise was to get to roman numeral III. Did you get something like this? roman.go func roman(number int) string { if number == 3 { return "III" } if number == 2 { return "II" } return "I" } roman_test.go package main import ( "testing" ) func TestRoman1(t *testing.T) { result := roman(1) expected := "I" if result != expected { t.Errorf("result was incorrect, got: %v, want: %v.
read more
June 8, 2024

Learn to Code in 5 Minutes a Day: Lesson 8

Lesson 7 Solution: Roman Numeral II If you completed lesson 7, you should have gotten something like the following. Remember, there is no one correct way to program any more than there is one right way to write a story or paint a picture. If you came up with a slightly different solution but it passes your unit tests, awesome!!! roman_test.go func TestRoman1(t *testing.T) { result := roman(1) expected := "I" if result !
read more
June 7, 2024

Learn to Code in 5 Minutes a Day: Lesson 7

Lesson 6 Solution: Roman Numeral I You should have come up with a solution that looks like the following. If you did, great! All it took was changing: return "" to return “I” roman.go func roman(number int) string { return "I" } roman_test.go func TestRoman(t *testing.T) { result := roman(1) expected := "I" if result != expected { t.Errorf("result was incorrect, got: %v, want: %v.", result, expected) } } go test PASS ok hello 0.
read more
June 6, 2024

Learn to Code in 5 Minutes a Day: Lesson 6

Recap of progress to date So far you’ve learned some basics of writing code. We haven’t talked about terms, but you’ve learned how to compile and format code, how to create functions, how to define variables, how to unit test, and how to do conditional statements (aka if statements). Even more importantly, you’ve learned how to search for answers and experiment. You’ve got a lot of the building blocks for coding.
read more
June 3, 2024

Learn to Code in 5 Minutes a Day: Lesson 5

Session 4 Solution: hello_test.go func TestHelloInigoMontoya(t *testing.T) { result := hello("inigo montoya") expected := "hello, inigo montoya" if result != expected { t.Errorf("result was incorrect, got: %v, want: %v.", result, expected) } } func TestHelloDuaLipa(t *testing.T) { result := hello("Dua Lipa") expected := "hello, Dua Lipa" if result != expected { t.Errorf("result was incorrect, got: %v, want: %v.", result, expected) } } func TestHelloDarthVader(t *testing.T) { result := hello("Darth Vader") expected := "hello, Darth Vader" if result !
read more
  • ««
  • «
  • 1
  • 2
  • »
  • »»
© Code With ADHD 2025