Day 1 - Discoded/adventofcode GitHub Wiki

Summary

The newly-improved calibration document consists of lines of text; each line originally contained a specific calibration value that the Elves now need to recover. On each line, the calibration value can be found by combining the first digit and the last digit (in that order) to form a single two-digit number.

Input:

1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet

Output:

12
38
15
77

Final answer: 142 (sum total of each line output)

Solution:

Parse each character on each line and check if it's a digit
Return once you find the first digit,
Start from the end or reverse the string
Return once you find the first digit(last digit)

Day 1 Part 2

Input:

two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen

Output:

29
93
13
24
42
14
76

Final answer: 281 (sum total of each line output)

Solution:

In each line, find strings: "one", "two", .... 'nine",
Replace each found string as '1', '2', '3', ... '9'
Run solution for Part 1