CMU 15-112 Summer 2020: Fundamentals of Programming and Computer Science
Collab 4 (Due Fri 22-May, at 11:59pm)
- This assignment is COLLABORATIVE. This means you may work with your week's collaboration group within the course collaboration boundaries. See the syllabus for details.
- To start:
- Create a folder named 'collab4'
- Download collab4.py and cs112_m20_day5_linter.py to that folder
- Edit collab4.py using VSCode
- When you are ready, submit collab4.py to Autolab. For this hw, you may submit up to 10 times (which is fewer times than you've had in the past), but only your last submission counts.
- Do not use sets, dictionaries, or recursion in this assignment.
- Do not hardcode the test cases in your solutions.
- NOTE: We are providing you with far fewer test cases this time around. You should be adding multiple test cases to testLookAndSay and testInverseLookAndSay.
- NOTE: This homework is going to be graded for style. Make sure that you adhere to the style guide when you're working on this HW, and double check your file against the style guide before you submit to Autolab!
-
lookAndSay(a) [15 pts]
First, read about look-and-say numbers here. Then, write the function lookAndSay(a) that takes a list of numbers and returns a list of numbers that results from "reading off" the initial list using the look-and-say method, using tuples for each (count, value) pair. For example:lookAndSay([]) == [] lookAndSay([1,1,1]) == [(3,1)] lookAndSay([-1,2,7]) == [(1,-1),(1,2),(1,7)] lookAndSay([3,3,8,-10,-10,-10]) == [(2,3),(1,8),(3,-10)]
- inverseLookAndSay(a) [10 pts]
Write the function inverseLookAndSay(a) that does the inverse of the previous problem, so that, in general:inverseLookAndSay(lookAndSay(a)) == a
Or, in particular:inverseLookAndSay([(2,3),(1,8),(3,-10)]) == [3,3,8,-10,-10,-10]