Compare commits
2 Commits
bacc1855ab
...
5f2c093e72
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f2c093e72 | |||
| 99db2b88a2 |
@ -7,7 +7,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
// "strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func check(e error) {
|
func check(e error) {
|
||||||
@ -16,13 +16,13 @@ func check(e error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func PrintAndWait[T any](x T) {
|
func PrintAndWait(x ...any) {
|
||||||
fmt.Print(x)
|
fmt.Print(x)
|
||||||
fmt.Scanln()
|
fmt.Scanln()
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
file, err := os.Open("./inputs/day03_test_input")
|
file, err := os.Open("./inputs/day03_input")
|
||||||
check(err)
|
check(err)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
@ -38,7 +38,25 @@ func main() {
|
|||||||
lines = append(lines, scanner.Text())
|
lines = append(lines, scanner.Text())
|
||||||
}
|
}
|
||||||
numLines := len(lines)
|
numLines := len(lines)
|
||||||
|
numbers := make([][]int, numLines)
|
||||||
|
_ = numbers
|
||||||
|
|
||||||
|
/* Line [0] needs to check only line 1 for symbols.
|
||||||
|
Similarly, the last line needs to check only
|
||||||
|
(last line index - 1) for symbols.
|
||||||
|
So we first check the line [0], then start a loop
|
||||||
|
from 1 to (last line index - 1)
|
||||||
|
*/
|
||||||
|
firstLineNums := renum.FindAllStringIndex(lines[0], -1)
|
||||||
|
firstLineSymbolsIndex := resym.FindAllStringIndex(lines[0], -1)
|
||||||
|
secondLineSymbolsIndex := resym.FindAllStringIndex(lines[1], -1)
|
||||||
|
|
||||||
|
PrintAndWait(firstLineNums)
|
||||||
|
PrintAndWait(firstLineSymbolsIndex)
|
||||||
|
PrintAndWait(secondLineSymbolsIndex)
|
||||||
|
|
||||||
|
|
||||||
|
/* This code may need to be scrapped, not sure yet.
|
||||||
// The 2D array of numbers will hold all the numbers to easily
|
// The 2D array of numbers will hold all the numbers to easily
|
||||||
// match them with corresponding strings in the file using the index
|
// match them with corresponding strings in the file using the index
|
||||||
numbers := make([][]int, numLines)
|
numbers := make([][]int, numLines)
|
||||||
@ -50,19 +68,5 @@ func main() {
|
|||||||
numbers[i] = append(numbers[i], num)
|
numbers[i] = append(numbers[i], num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// We store the index of a symbol on the line it appears
|
|
||||||
symbolsIndex := make([][]int, numLines)
|
|
||||||
symbols := make([][]string, numLines)
|
|
||||||
_ = symbolsIndex
|
|
||||||
// For every line
|
|
||||||
for i := 0; i < numLines; i++ {
|
|
||||||
// We put all the symbols in a string
|
|
||||||
tempSymbols := resym.FindAllString(lines[i], -1)
|
|
||||||
// We associate symbols with an index
|
|
||||||
tempSymbolsIndex := resym.FindAllStringIndex(lines[i], -1)
|
|
||||||
// Add symbols and indexes to the arrays
|
|
||||||
symbols = append(symbols, tempSymbols)
|
|
||||||
//symbolsIndex = append(symbolsIndex, tempSymbolsIndex)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user