Light Bot Solutions: an analysis

Slides:



Advertisements
Similar presentations
Identify the number of solutions of an equation
Advertisements

 Communication:  Provide context, e.g., s …  TA Office hour for next Tuesday: CANCELLED  My name is: ??  Show  Scores on-line, Quiz-1 results.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 Changing Control.
New Mexico Computer Science For All More Algorithms Maureen Psaila-Dombrowski.
Programming Concept #2 Iteration. Is just a fancy way of saying that you would like something to repeat more than one time. It is used in any modern programming.
CS107 Introduction to Computer Science Loops. Instructions Pseudocode Assign values to variables using basic arithmetic operations x = 3 y = x/10 z =
10-1 Programming Remember: –programming language –how to program (conceptually) –intro to programming the “ROBOT” computer In this lecture: –programming.
Copyright Kenneth M. Chipps Ph.D. 1 How To Do VLSM Last Update
Solve Equations with Variables on Both Sides
EXAMPLE 1 Solve an equation with variables on both sides 7 – 8x = 4x – 17 7 – 8x + 8x = 4x – x 7 = 12x – = 12x Write original equation. Add.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 What can a computer be commanded to do?
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 Assignment 6.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 We’re underway …
Block Maths Pyramid Maths. Example X What is ? 39 ? 3 X.
1.5 Solving Inequalities Remember the rules of solving inequalities.
Lesson 3-2 Solving Equations by Using Addition and Subtraction.
Inequalities and their Graphs Objective: To write and graph simple inequalities with one variable.
Factors, Prime Numbers & Composite Numbers. Definition Product – An answer to a multiplication problem. 7 x 8 = 56 Product.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004.
Example 1 Solving Two-Step Equations SOLUTION a. 12x2x + 5 = Write original equation. 112x2x + – = 15 – Subtract 1 from each side. (Subtraction property.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 Functional Abstraction Reduces Complexity.
1.4 Solving Absolute Value Equations Evaluate and solve Absolute Value problems.
Two paths diverge in the lectures 2 Think of the first as concepts, the second as capabilities This ClassPrinciplesDoing stuff.
Objective: Compare 3-digit numbers using the symbols: ● greater than (>) ● less than (
Steps to Write Decimals as Fractions
Entry Task Factor 9x2 – 25 (3x – 5)(3x + 5).
Inequalities and their Graphs
Inequalities and their Graphs
Coming up: Next three class periods:
Lightbot and Functions CSE 120 Winter 2017
2-4, 2-5 Warm Up
Light Bot Solutions: an analysis
Involving One Operation
Announcement Tomorrow’s office hr: CANCELLED! Show work!!
To do … Web Exercise: Quiz-3, HW#2 Score: update
Inequalities and their Graphs
Warm-up 1. Answer: 3, Answer: 5 3. Answer: 8.
Lightbot and Functions CSE 120 Winter 2018
Inequalities and their Graphs
Announcements Mid-Term Exam!! Quiz 5 Again + Quiz 6 Exercise 5
Light Bot Solutions: an analysis
Announcement Function ppt: download again
A colorful way to find the factors of given numbers
Announcements How’s it going? My internet/power supply?
Digital Thinking: Animation, Video Games, and the Social Web
Topic 1: Problem Solving
Announcements SGID Feedback! Thank you!! Readings:
Announcements: Reading materials are posted on Discussion Board.
Algorithms.
Involving One Operation
Two Paths Diverge in the Lectures
Variables, Assignments Testing + Iteration
Involving One Operation
Lawrence Snyder University of Washington, Seattle
Computational Thinking
Announcements How to save your work? Quiz solution 5/5/2019
Announcements: Questions: Names on the board? Why?
Basic Processing … Drawing pictures … It’s not art, it’s fun
Solving Equations By Balancing.
Example 5A: Solving Simple Rational Equations
Involving One Operation
Digital Thinking: Animation, Video Games, and the Social Web
Lawrence Snyder University of Washington
Routines for Reasoning
Solving Equations By Balancing.
Announcements Survey feedback: summary Quiz: HW 7:
Today: to list: Syllabus change: Grade on-line
Announcements Jack group member by Thursday!! Quiz-8? HW10
Lecture 6 - Recursion.
Presentation transcript:

Light Bot Solutions: an analysis Let’s gather our thoughts … on LightBot … Light Bot Solutions: an analysis Kelvin Sung University of Washington, Bothell (* Use/Modification with permission based on Larry Snyder’s CSE120) © Lawrence Snyder 2004

Questions? Comments? Here is your graded HW1 Summary of your HW1 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Goal for today: Practice Abstraction An instruction (of the Lightbot or any other computer) is abstracted into the command name; functions abstract useful and meaningful operations, functions abstract functions built of functions, etc. Layer upon layer, we build software solutions 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

What did we learn? Find a pattern (problem): give it a name form a concept: functional abstraction Solve the problem by defining a function F1( ): Process Riser F2( ): Move To Next Riser 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Pattern? 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Process of finding a pattern? Method 1: Brute force: S + P + S + P + S + P + S + P … Stare at the solution! Repeated: Step + Power! Answer: Define ProcessOne() SP Function name + Function Body Repeatedly invoke (call) ProcessOne until done. 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Brute force is ok … or ? Method 2: observations 3 strips of identical “thinging” How to solve one “strip”? Define ProcessOneStrip() SPSPSP There are 3 strips so … Answer: 3: ProcessOneStrip Both solutions are equally good! 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

How about this one? 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Pattern? What patterns do you see? 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Pattern? 3 identical strips of Abstractions: Strip has Two connected 2 steps Abstractions: Strip has TwoSteps “Turn”: connecting the steps 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Solving all concepts Def ProcessOneStrip() Def ProcessTwoSteps() MakeTheTurn Power Def ProcessTwoSteps() SS Def MakeTheTurn() LSL 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Solution to problem Verbally 3:(ProcessOneStrip : L) Process first strip Turn Left Process second strip Process third strip 3:(ProcessOneStrip : L) 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

How about this? Pattern? 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

How about this? Pattern? Obvious one: Any other pattern? So: 4x connected sides A side is 4 steps + Power Any other pattern? Too simple Not obvious enough So: How to get to the beginning of first pattern? 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Solution … Get to the pattern: Def ProcessAnEdge() Solution: PJPJPLSS or 2:(PJ)PL2:(S) Def ProcessAnEdge() SSSSPL Solution: GetToThePattern 4:(SSSSPL) 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Fun yet? Pattern? 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Fun yet? Pattern? Facing: Front step need power Right step need power 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Solution? Solution: Notice: Def ProcessFacing() After ProcessFacing J P R J P L L Notice: After ProcessFacing The problem repeats itself!! Well, almost … 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

One small (but important) Point Power: Toggles NOT: on/off Observe Odd ones: Off Even ones: On Each block: Has 3 sets of “Facing” 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Last one … Pattern? 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Last one … Pattern? 4 sets of Def ProcessStairs() 3-step stairs Observation: Up and down are the same (we knew this!) Def ProcessStairs() J J J P 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Trickier … StairSet: 2 StairSets! Two stairs with Connected with Power + L 2 StairSets! 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Process StairSet … Def ProcessStairSet() ProcessStairs L 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)

Today: Practice Abstraction Brute force: List out solution, find patterns from the solution Observe problem Break into smaller problems that repeat themselves in the original problem Define function: solution for the smaller problem Re-use function Can be tricky to observe pattern! 12/30/2018 Kelvin Sung (Use/modify with permission from © 2010-2012 Larry Snyder, CSE)