This class will be recorded! Its use is limited to members of the class. Please do not share with others.
Approximate overview
What does the SoLA look like?
You’ll see the list in Gradescope.
When you click one, you’ll see a warning that you have 60 minutes.
Otherwise, like a quiz.
When appropriate, I will post details to the Announcements channel.
I’m not sure if all of these links are correct. Let me know if any are not.
I will gather questions from everyone here. Then I’ll answer them in some order.
I have a question about the current SoLAs
I will not answer further questions about the current SoLAs.
What is point of this class session?
For some students, it’s a chance to ask about the sample SoLAs. For some, it’s a chance to ask more about things they realize they don’t quite understand.
What did I miss yesterday?
Discussion of pair programming in 151 and consideration of some of the issues that come up. Please watch the class (at least after the quiz part). Send Sam some thoughts.
Details of SoLAs: Think “exam” with seven problems. You can do each problem separately. Each problem is timed. It should take 20 min or less, but you have an hour for comfort.
Need to finish within the next 23 hours and 44 minutes. (as of 3:16)
Listen to yesterday’s class.
Will you make fun of me if it’s clear that I’m not listening?
Yes.
Why do the SoLAs say “group one”?
To make it clear that it’s from the first round/group/phase
They may end up saying Phase rather than Group
Can you go over a conditionals trace (i.e., a trace with conditionals)?
(define six-digits?
(lambda (str)
(if (string? str)
(if (= (string-length str) 6)
(if (integer? (string->number str))
#t
#f)
#f)
#f)))
(six-digits? (string-append "12345" "x"))
--> (six-digits? "12345x")
--> (if (string? "12345x")
(if (= (string-length "12345x") 6)
(if (integer? (string->number "12345x"))
#t
#f)
#f)
#f)
--> (if #t
(if (= (string-length "12345x") 6)
(if (integer? (string->number "12345x"))
#t
#f)
#f)
#f)
--> (if (= (string-length "12345x") 6)
(if (integer? (string->number "12345x"))
#t
#f)
#f)
--> (if (= 6 6)
(if (integer? (string->number "12345x"))
#t
#f)
#f)
--> (if #t
(if (integer? (string->number "12345x"))
#t
#f)
#f)
--> (if (integer? (string->number "12345x"))
#t
#f)
--> (if (integer? #f)
#t
#f)
--> (if #f
#t
#f)
--> #f
Can we go over practice tracing SoLA
(define f
(lambda (x y)
(string-append x "-" (string-reverse x))))
(define g
(lambda (x y)
(string-append (f x x) " " (f y x)))))
(define h
(lambda (x y)
(string-append (g x y) "&" (g y x))))
(h "foo" "bar")
--> (string-append (g "foo" "bar") "&" (g "bar" "foo"))
--> (string-append (g "foo" "bar") "&" (string-append (f "bar" "bar") " " (f "foo" "bar")))
--> (string-append (g "foo" "bar") "&" (string-append (f "bar" "bar") " " (string-append "foo" "-" (string-reverse "foo"))))
--> (string-append (g "foo" "bar") "&" (string-append (f "bar" "bar") " " (string-append "foo" "-" "oof")))
--> (string-append (g "foo" "bar") "&" (string-append (f "bar" "bar") " " "foo-oof"))
--> (string-append (g "foo" "bar") "&" (string-append (string-append "bar" "-" (string-reverse "bar")) " " "foo-oof"))
--> (string-append (g "foo" "bar") "&" (string-append (string-append "bar "-" "rab") " " "foo-oof"))
--> (string-append (g "foo" "bar") "&" (string-append "bar-rab" " " "foo-oof"))
--> (string-append (g "foo" "bar") "&" "bar-rab foo-oof")
--> (string-append (string-append (f "foo" "foo") " " (f "bar" "foo"))) "&" "bar-rab foo-oof")
--> (string-append (string-append (f "foo" "foo") " " (string-append "bar" "-" (string-reverse "bar"))) "&" "bar-rab foo-oof")
--> (string-append (string-append (f "foo" "foo") " " (string-append "bar" "-" "rab")) "&" "bar-rab foo-oof")
--> (string-append (string-append (f "foo" "foo") " " "bar-rab") "&" "bar-rab foo-oof")
--> (string-append (string-append (string-append "foo" "-" (string-reverse "foo")) " " "bar-rab") "&" "bar-rab foo-oof")
--> (string-append (string-append (string-append "foo" "-" "oof") " " "bar-rab") "&" "bar-rab foo-oof")
--> (string-append (string-append "foo-oof" " " "bar-rab") "&" "bar-rab foo-oof")
--> (string-append "foo-oof bar-rab" "&" "bar-rab foo-oof")
--> "foo-oof bar-rab&bar-rab foo-oof"
"foo-oof bar-rab&bar-rab foo-oof"
On the decomposition practice SoLA, is it okay if it’s similar?
Yes
Step one: Put on one line.
Step two: Put in carriage returns at appropriate places.
Step three: ZoB “(if TEST #t #f)” -> TEST
Step four: (equal? #t TEST) -> TEST
Step five: Check parameter to substring https://docs.racket-lang.org/reference/strings.html#%28def.%28%28quote.~23~25kernel%29._substring%29%29
Step six: Rename parameters
Step seven: (equal? TEST #f) -> (not TEST)
Step eight: (if TEST #f #t) -> (not TEST)
Step nine: (not (not TEST)) -> TEST
We are now at
(define rab
(lambda (str index)
(if (integer? (string->number (substring str index)))
(string->number (substring str index))
(if (integer? (string->number (substring str 0 index)))
(string->number (substring str 0 index))
#f))))
We could factor out the common code
(define helper
(lambda (str)
(if (integer? (string->number str))
(string->number str)
#f)))
(define rab
(lambda (str index)
(or (helper (substring str index))
(helper (substring str 0 index)))))
Can I fix helper?
(define string->integer
(lambda (str)
(and (integer? (string->number str))
(string->number str))))
(define substring->integer
(lambda (str index)
(or (string->integer (substring str index))
(string->integer (substring str 0 index)))))
; Determines whether the portion of the string starting at index is an integer or the portion of the string ending at index (exclusive) is an integer
; If so, returns that integer.