1D Maze in a list Python

QUESTION:
You are in a 1D maze encoded as a list of non-negative numbers. You enter the room on the leftmost number and the rule is you can only move to squares EXACTLY the number of squares away from the square you’re standing on (left or right). The exit is the rightmost number, the last number in the list, and is always 0 (and is the only 0 in the list). Here’s a list with one hop to the exit: [3, 9, 9, 0]…you jump from 3 to 0 and you’re out!

Write can_exit(i, L) to return whether you can exit the maze L from position index i. (Assume the maze does not have any loops; like [1, 1, 1, 0], where your code can get stuck jumping left and right repeatedly and never get out.)

For example: [1, 3, 5, 10, 2, 10, 10, 0] – can you get out?

1 right-jump to 3, 3 right-jump to 2, 2 left-jump to 5, 5 right-jump to 0. YES you can!
Some mazes you can’t, like [10, 0], so when can you and when can’t you?
Example calls:

>>> <strong>can_exit(0, [3, 9, 9, 0])</strong>
True
>>> <strong>can_exit(0, [1, 3, 5, 10, 2, 10, 10, 0])</strong>
True
>>> <strong>can_exit(0, [10, 0])</strong>

Sample Solution

Opera, they were best friends, while in adulthood he “betrayed” Dieyi by marrying a concubine and by giving up upon Peking Opera. At last, Dieyi realized that the reason why Xiaolou “betrayed” him is not the woman. It’s homophobia that made the distance between Xiaolou and Dieyi farther over time. (Hee, 2009) However, who is born to be homophobic? There are a lot of psychological debates on the whether homophobia is a natural trait or a nurtural behavior, as there are too many uncertainties in the dynamics. However, when we look back to the Chinese history, it’s interesting to discover that there are seldom voices of homophobia, because they were living in the time and culture with respect and normal views to sexual minorities, which makes me believe that homophobes in contemporary China were produced by the repressing politics and society.
After the foundation of People’s Republic of China, which ruled by Mao Zedong of the Communist Party. Dictatorship and the cult of Mao is born to rule the population of 550 million. The strategy of Mao’s ruling is to control the ideology and mindsets of every single person by integrating all of his words and poems about his great ambition of ruling the country to a red book, requiring everyone to own, with his face on the cover surrounded by a golden star and glares. Propagandas were posted everywhere on the street and his portrait was hung in everyone’s home. To controlling the ideology, he wanted to minimize the diversity and difference between people’s mind, thus banning all the controversial topics, including topics around LGBTQ+. If someone talks or does something related to LGBTQ+, they will be imprisoned or executed for the accusation of treason. Also, there is no record of gays, lesbians or more being punished in that kind of time, because no regular people dares to disobey the authority of Mao.

This question has been answered.

Get Answer
WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
👋 Hi, Welcome to Compliant Papers.