← Back to all posts
8
ReplProblemOfTheWeek #1 Staircases

These are 2 easy questions to get you started up!
Level A is the easier one and level B is a little harder.
Level A:
John the robot trying to climb up stairs following a certain command. He starts on the ground floor (floor 0) and then follows the instructions one character at a time.

An opening parenthesis, (, means he should go up one floor, and a closing parenthesis, ), means he should go down one floor.

Examples
((() => will get him on floor 2
))(( => will get him on floor 0
((((()) => will get him on floor 3

Where does John the robot end up with the instructions!
Input: https://repl.it/@IEATPYTHON/POTW?language=python3
The input is in the input txt file

Level B:
Now, given the same instructions(An opening parenthesis, (, means he should go up one floor, and a closing parenthesis, ), means he should go down one floor.), find the position of the first character that causes him to enter the basement (floor -1). The first character in the instructions has position 1, the second character has position 2, and so on.

For example:

) causes him to enter the basement at character position 1.
()()) causes him to enter the basement at character position 5.
What is the position of the character that causes John the robot to first enter the basement?

Input: https://repl.it/@IEATPYTHON/POTW?language=python3
The input is in the input txt file. It is the same input as problem A

Good luck to all on these questions!

Please don't ask for spoon feeding or post your answers in the comments below.
put them here: https://repl.it/talk/share/ANSWERS-ReplProblemOfTheWeek-1-Staircases/8962

Commentshotnewtop
2

The link to the input file is not working.

2
1

This looks very much like 2015's First Puzzle in Advent Of Code https://adventofcode.com/2015/day/1