Skip to content

Commit 36ef49f

Browse files
committed
Solved Day 01 of AOC 2015 in R
1 parent bd1b843 commit 36ef49f

File tree

7 files changed

+62
-2002
lines changed

7 files changed

+62
-2002
lines changed

2015/assignments/day01.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
*--- Day 1: Not Quite Lisp ---*
2+
3+
Santa was hoping for a white Christmas, but his weather machine's "snow" function is powered by stars, and he's fresh out! To save Christmas, he needs you to collect fifty stars by December 25th.
4+
5+
Collect stars by helping Santa solve puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck!
6+
7+
Here's an easy puzzle to warm you up.
8+
9+
Santa is trying to deliver presents in a large apartment building, but he can't find the right floor - the directions he got are a little confusing. He starts on the ground floor (floor 0) and then follows the instructions one character at a time.
10+
11+
An opening parenthesis, (, means he should go up one floor, and a closing parenthesis, ), means he should go down one floor.
12+
13+
The apartment building is very tall, and the basement is very deep; he will never find the top or bottom floors.
14+
15+
For example:
16+
17+
(()) and ()() both result in floor 0.
18+
((( and (()(()( both result in floor 3.
19+
))((((( also results in floor 3.
20+
()) and ))( both result in floor -1 (the first basement level).
21+
))) and )())()) both result in floor -3.
22+
23+
**To what floor do the instructions take Santa?**
24+
25+
*--- Part Two ---*
26+
27+
Now, given the same instructions, 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.
28+
29+
For example:
30+
31+
* ) causes him to enter the basement at character position 1.
32+
* ()()) causes him to enter the basement at character position 5.
33+
34+
**What is the position of the character that causes Santa to first enter the basement?**

0 commit comments

Comments
 (0)