This problem is part of our Ada Lovelace Day celebration.
It is for practice only and will NOT count towards your grade!
(just have fun and use it to improve your skills: there is no submission deadline!)
In this problem you should submit a function as described. Inside the function do not print anything that was not asked!
The name of the .py source file you submit to Mooshak should NOT start with a digit (you will get an error if you submit it like that).
Carol Shaw was one of the first women to design and program commercial video games.
She worked at Atari and later created River Raid, published by Activision in 1982 for the Atari 2600.
In River Raid, players fly a plane along a river, avoiding enemies and obstacles while trying to keep enough fuel to continue the mission.
Carol needs your help to design an initial screen for the game. Your job is to help her draw different river boards with fuel, obstacles, and enemies.
Implement the function river_raid(n, objects). The function receives a positive integer n and a list objects, and returns a string representing a square board with n rows and n columns.
Each cell contains exactly one character:
The parameter objects is a list of tuples. Each tuple has the form (position, symbol), where position determines where the object is placed on the board and symbol is "F", "O", or "E".
For example, the list of tuples:[(5, "F"), (3, "O"), (7, "E")]
places fuel at position 5, an obstacle at position 3, and an enemy at position 7.
The objects may appear in any order in the list, i.e., [(7, "E"), (3, "O"), (5, "F")]
would be equivalent to the previous example.
Positions are numbered from 1 to n × n, moving from left to right across each row, then continuing on the next row.
For a 3 × 3 board, the positions would correspond to:
1 2 3 4 5 6 7 8 9
The function should return a string corresponding to the board.
When that string is printed, i.e., print(river_raid(....)) it must show exactly n lines, each containing exactly n characters.
The following limits are guaranteed in all the test cases that will be given to your program:
| 2 ≤ |n| ≤ 20 | size of the board n × n | |
| 0 ≤ |objects| ≤ n2 | number of objects inserted in the grid | |
| objects will not contain repeated positions |
| Example Function Call 1 | Example Output 1 |
print(river_raid(4, [(2, "F"), (7, "O"), (12, "E"), (15, "F")])) |
#F## ##O# ###E ##F# |
| Example Function Call 2 | Example Output 2 |
print(river_raid(5, [(1, "F"), (2, "F"), (8, "E"), (13, "O"), (18, "E"), (24, "O")])) |
FF### ##E## ##O## ##E## ###O# |
| Example Function Call 3 | Example Output 3 |
print(river_raid(3, [])) |
### ### ### |
In the last example, the list of objects is empty, so all the cells are river (#).