
Write a Python program, in a file called forest_map.py, to solve the following problem: Hansel and Gretel are abandoned in a forest with only a bag of breadcrumbs and must find their way home. The forest is laid out in a grid pattern. They can only take a step at a time through the forest, going either South or East. They cannot move diagonally, they cannot move North, and they cannot move West. As they leave a space, they will leave a breadcrumb (“*”) behind just in case -- if they have any breadcrumbs left. They do not leave a breadcrumb in the space where the path ends. If they don’t have enough breadcrumbs, they still move on to the next space, leaving their current space as it was. Given (as input) the number of breadcrumbs Hansel and Gretel have, and given the forest layout (as a fixed, but changeable, two-dimensional list in your code), determine whether Hansel and Gretel have just enough, more than enough, or not enough, breadcrumbs to leave in the path to get to the end. If they have more than enough, display how many breadcrumbs remain. An empty space (‘ ’) in the forest layout denotes a path and an ‘X’ in the forest layout denotes a tree in the forest. Hansel and Gretel cannot move where a tree is. The end of the path is denoted by an ‘E’ in the lower right-hand corner of the forest. Hansel and Gretel always start in the upper left-hand corner of the forest. There is always only one direction that they can move in, they will never have to choose between South and East. Your program must include the following: • function main that contains the forest layout as a list (you can just make it up here, it doesn’t have to be input, but the sizes of the dimensions should be flexible and the starting position always has to be in the top left corner of the list); it asks the user for the number of breadcrumbs as an integer; it should print the resulting forest map showing the breadcrumbs (just print the 2-D list, it doesn’t have to be formatted) and also make use of the following functions to compute and print the message to the user • function distance which takes, as parameters, the forest layout and the initial number of breadcrumbs, and returns the number of breadcrumbs they used to get to the end – this value will be negative if they run out before reaching the end; remember, unknown to Hansel and Gretel but known to you, the path only continues either East or South, and there is only one path and no dead-ends • function crumbsLeft which takes, as a parameter, the number of breadcrumbs left (which may be negative if the path is longer than the number of breadcrumbs) and prints that there were not enough breadcrumbs, just enough breadcrumbs, or the actual amount of breadcrumbs left For example, given the following forest map: forestPath = [[' ',' ',' ','X','X'],\ ['X','X',' ',' ','X'],\ ['X','X','X',' ','X'],\ [' ','X','X',' ',' '],\ [' ','X','X','X',' '],\ [' ',' ','X','X',' '],\ [' ',' ','X','X','E']] If the number of breadcrumbs given is 12, sample output would be: Enter number of breadcrumbs: 12 [['*', '*', '*', 'X', 'X'], ['X', 'X', '*', '*', 'X'], ['X', 'X', 'X', '*', 'X'], [' ', 'X', 'X', '*', '*'], [' ', 'X', 'X', 'X', '*'], [' ', ' ', 'X', 'X', '*'], [' ', ' ', 'X', 'X', 'E']] 2 breadcrumb(s) are left If the number of breadcrumbs given is 5, sample output would be: Enter number of breadcrumbs: 5 [['*', '*', '*', 'X', 'X'], ['X', 'X', '*', '*', 'X'], ['X', 'X', 'X', ' ', 'X'], [' ', 'X', 'X', ' ', ' '], [' ', 'X', 'X', 'X', ' '], [' ', ' ', 'X', 'X', ' '], [' ', ' ', 'X', 'X', 'E']] Not enough breadcrumbs for the trip. If the number of breadcrumbs given is 10, sample output would be: Enter number of breadcrumbs: 10 [['*', '*', '*', 'X', 'X'], ['X', 'X', '*', '*', 'X'], ['X', 'X', 'X', '*', 'X'], [' ', 'X', 'X', '*', '*'], [' ', 'X', 'X', 'X', '*'], [' ', ' ', 'X', 'X', '*'], [' ', ' ', 'X', 'X', 'E']] Phew, just enough breadcrumbs for the trip.

Step by stepSolved in 4 steps with 3 images

- Write a Python Program that will simulate a registration system, as follows: Welcome: Display a message to welcome the user and ask for their info Capture user input: Ask the user to input the following information: o First name (String) Last name (String) o Age (integer) you must adjust value by subtracting 2 years Current GPA (float) you must adjust by adding 0.5 o Hobbies (only 3) (a string Collection containing 3 items) (all strings) Hint: you can ask user to specify each hobby one by one, and then you can update (or add) each item to the Collection Display user information: thank user for registration & show their info Goodbye: Display a Goodbye message and end Programarrow_forwardWrite a program that reads movie data from a csv (comma separated values) file and output the data in a formatted table. The program first reads the name of the CSV file from the user. The program then reads the csv file and outputs the contents according to the following requirements: Each row contains the title, rating, and all showtimes of a unique movie. A space is placed before and after each vertical separator (|) in each row. Column 1 displays the movie titles and is left justified with a minimum of 44 characters. If the movie title has more than 44 characters, output the first 44 characters only. Column 2 displays the movie ratings and is right justified with a minimum of 5 characters. Column 3 displays all the showtimes of the same movie, separated by a space. Each row of the csv file contains the showtime, title, and rating of a movie. Assume data of the same movie are grouped in consecutive rows. Ex: If the input of the program is: movies.csv and the contents of movies.csv…arrow_forwardUsing Python build your own song remixing solution. As an example: given the following American children’s song (this is ONE of the 3 songs I’m giving you in the starter code that includes the data you'll use for your program) Starter file: music.py (data file for my songs and playlist) here below; SONG = ['old macdonald had a farm - ee-i-ee-i-o.', 'and on that farm he had a cow - ee-i-ee-i-o.', 'with a moo moo here and a moo moo there', 'here a moo - there a moo - everywhere a moo moo', 'old macdonald had a farm - ee-i-ee-i-o.' ] Do This: Create a solution that allows users to: Load a new song from our playlist When requested, show the title of the song you’re currently remixing Continue the above operations on demand, until the user explicitly quits your program. Note that there is punctuation in some of the songs we've given you. When you remix a song, you should remove the punctuation (see the example reverse below). If you are unable to perform…arrow_forward
- Code in PYTHONarrow_forwardWrite a program that lists all Fibonacci numbers that are less than or equal to the number k (k≥2) entered by the user. Definition:The Fibonacci sequence is a sequence of numbers in which each additional term is the sum of the previous two. It is based on the fact that each member of the sequence is formed by the sum of the previous two members, the sequence starting with the numbers 1 and 1. (Example 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233 , 377, 610, 987 write program in c languagearrow_forwardWrite a program that prompts the user to enter the length from thecenter of a pentagon in pythonarrow_forward
- Write a program that reads movie data from a CSV (comma separated values) file and output the data in a formatted table. The program first reads the name of the CSV file from the user. The program then reads the CSV file and outputs the contents according to the following requirements: Each row contains the title, rating, and all showtimes of a unique movie. A space is placed before and after each vertical separator ('|') in each row. Column 1 displays the movie titles and is left justified with a minimum of 44 characters. If the movie title has more than 44 characters, output the first 44 characters only. Column 2 displays the movie ratings and is right justified with a minimum of 5 characters. Column 3 displays all the showtimes of the same movie, separated by a space. Each row of the CSV file contains the showtime, title, and rating of a movie. Assume data of the same movie are grouped in consecutive rows. Hints: Use the find() function to find the index of a comma in each row of…arrow_forwardWrite a Java program (Hangman.java) to play the classic word game Hangman. In the game, a word is randomly selected from an array of possible words. Then, the user is prompted to guess letters in the word one at a time. When the user makes a correct guess, all instances of that letter in the word are shown. When all letters in the word have been guessed, the game ends and the score (number of missed guesses) is displayed. A user can play the game multiple times if they choose. Here is a sample run of a correct program (user input indicated by orange text):Enter a letter in word ******** > cEnter a letter in word c******* > rEnter a letter in word c******r > s s is not in the wordEnter a letter in word c******r > tEnter a letter in word c****t*r > mEnter a letter in word c*m**t*r > t t is already in the wordEnter a letter in word c*m**t*r > pEnter a letter in word c*mp*t*r > oEnter a letter in word comp*t*r > eEnter a letter in word comp*ter >…arrow_forwardWrite a program that reads a sequence of input values and displays a bar chart of the values, using asterisks - with captions- like this: Egypt ********************* France***************************** Japan ************************ Uruguay ******************** Switzerland **********arrow_forward
- Create a python program that would perform the given description below B. Imagine a list - not very long, not very complicated, just a simple list containing some integer numbers. Some of these numbers may be repeated, and this is the clue. We don't want any repetitions. We want them to be removed. Your task is to write a program that removes all the number repetitions from the list. The goal is to have a list in which all the numbers appear not more than once. Note: Assume that the source list is hard-coded inside the code - you don't have to enter it from the keyboard. Of course, you can improve the code and add a part that can carry out a conversation with the user and obtain all the data from her/him. Hint: we encourage you to create a new list as a temporary work areaarrow_forwardIn Python, Solve the locker riddle which reads as follows:Imagine 100 lockers numbered 1 to 100 with 100 students lined up in front of those 100lockers:The first student opens every locker.The second student closes every 2nd locker.The 3rd student changes every 3rd locker; if it’s closed, she opens it; if it’s open, she closes it.The 4th student changes every fourth locker (e.g., 4th, 8th, etc.).The 5th student changes every 5th locker (e.g., 5th, 10th, etc.).That same pattern continues for all 100 students. Which lockers are left open after all 100 students have walked the rowof lockers?arrow_forwardimplement C# code to create a list of Card objects, add two Card objects to the list, use a loop to flip the cards in the list and print it.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





