CMU 15-112: Fundamentals of Programming and Computer Science
Homework 11 (Due Saturday 30-Jul at 8pm ET)


Important notes about hw11 bonus:
  1. As usual, this homework is solo. You must not collaborate with anyone (besides current course TA's and faculty) in any way. See the syllabus for more details.
  2. To start:
    1. Create a folder named 'hw11'
    2. Download all of these to that folder, and note that we are using week 5's linter for this assignment:
    3. Edit hw11.py
    4. When you have completed and fully tested hw11, submit hw11.py to Autolab. For this hw, you may submit up to 5 times, but only your last submission counts.
  3. Do not hardcode the test cases in your solutions.

A few more notes:
Homework 11 Overview:
  1. Recursion-Only oddCount(L) [25 pts]
  2. Recursion-Only oddSum(L) [25 pts]
  3. Recursion-Only oddsOnly(L) [25 pts]
  4. Recursion-Only maxOdd(L) [25 pts]
  5. Bonus/Optional: Recursion-Only Recursive Tetris! [3 pts]

  1. Recursion-Only oddCount(L) [25 pts] [autograded]
    Without using iteration, write the recursive function oddCount(L) which given a possibly-empty list L of integers, returns the number of odd integers in L.

  2. Recursion-Only oddSum(L) [25 pts] [autograded]
    Without using iteration, write the recursive function oddSum(L) which given a possibly-empty list L of integers, returns the sum of the odd integers in L. Return 0 if the list has no odd integers in it.
    Note: You may not simply create a new list of just the odd numbers and find the sum of that list. Your solution should only need to read each element in the list once.

  3. Recursion-Only oddsOnly(L) [25 pts] [autograded]
    Without using iteration, write the recursive function oddsOnly(L) which given a possibly-empty list L of integers, returns a new list containing only the odd integers in L in the same order they appear in L.

  4. Recursion-Only maxOdd(L) [25 pts] [autograded]
    Without using iteration, write the recursive function maxOdd(L) which given a possibly-empty list L of integers, returns the largest odd integer in L, or None if L does not contain any odd integers.

  5. Bonus/Optional: Recursion-Only Recursive Tetris! [3 pts] [manually graded]
    For bonus this week, submit a new entirely-recursive version of Tetris to hw11-bonus (a separate assignment on autolab). You may start from the Tetris code you submitted for hw9, but then convert it to be entirely recursive. No loops, and no built-ins unless they run in O(1)!