Starting from:

$29.99

CS1301 Homework 9 - Recursion Solution

How to Think Like a Computer Scientist
CS 1301 YouTube Channel
Comment out or delete all function calls. Only import statements, global variables, and comments are okay to be outside of your functions.
Read the entire document before starting this assignment.
The goal of this homework is for you to enhance your understanding of recursion. The homework will consist of 5 functions for you to implement. You have been given HW09.py skeleton file to fill out. However, below you will find more detailed information to complete your assignment. Read it thoroughly before you begin.
Hidden Test Cases: In an effort to encourage debugging and writing robust code, we will be including hidden test cases on Gradescope for some functions. You will not be able to see the input or output to these cases. Below is an example output from a failed hidden test case:

Written by Alexa O'Reilly (aoreilly@gatech.edu), Yara Seif (yaraseif@gatech.edu), and Michael Sullivan (michaelsullivan@gatech.edu)
Helpful Information to Know

All of these functions must be implemented recursively. You are not allowed to use loops in any of the functions.

xkcd.com
Picky Eater
Function Name: pickyEater()
Parameters: food list ( list )
Returns: number of food items that can be eaten ( int )
Description: You and your friends are throwing a Thanksgiving party and have invited a friend who is a picky eater. Your friend only eats food if it has an even number of characters. Given a list of the food that you will be serving, return the number of items that your friend can eat. If one of the items in the list is an empty string, do not count it as an even food.



Invite Friends
Function Name: inviteFriends()
Parameters: list of invitees ( list )
Returns: flattened list of all invitees ( list )
Description: For your friendsgiving dinner, you want to make sure you are inviting everyone you know! You ask your friends who you should invite. Some friends give you a name of one invitee, some give you a list of invitees, and some even give you a list of lists containing invitees and their friends! To make things easy, write a function that takes in the nested list and returns a flattened list containing all of the names that your friends suggested.



Friendsgiving Dinner
Function Name: friendsgiving()
Parameters: stores ( list ), budget ( float ), maxDistance ( int )
Returns: price of sauce at each store ( dict )


Palindrome Finder
Function Name: palindrome()
Parameters: string ( str ), guess ( int )
Returns: Whether the string contains a number of palindromes ( bool )
Description: You saw a meme about how tacocat is a palindrome and want to learn more about palindromes. However, when you try to guess the number of palindromes, you're not always correct. Write a function that takes in a string and a guess for how many 3 letter palindromes are in the string. The function should return whether this guess is correct. You can assume that the guess will never be negative.
Note: A 3 letter palindrome is a character surrounded by a different character on each side in the form aba. The pattern aaa does not count.


Grading Rubric

Function Points
pickyEater() 20
inviteFriends() 20
friendsgiving() 30
palindrome() 30
Total 100
Provided
The HW09.py skeleton file has been provided to you. This is the file you will edit and implement. All instructions for what the functions should do are in this skeleton and this document.
Submission Process

More products