Compare commits

..

No commits in common. "5f2c093e724c523aa99927e4ac883d605b7bd2de" and "bacc1855ab83a62224f766c69f503041b2a890db" have entirely different histories.

View File

@ -7,7 +7,7 @@ import (
"bufio"
"os"
"regexp"
// "strconv"
"strconv"
)
func check(e error) {
@ -16,13 +16,13 @@ func check(e error) {
}
}
func PrintAndWait(x ...any) {
func PrintAndWait[T any](x T) {
fmt.Print(x)
fmt.Scanln()
}
func main() {
file, err := os.Open("./inputs/day03_input")
file, err := os.Open("./inputs/day03_test_input")
check(err)
defer file.Close()
@ -38,25 +38,7 @@ func main() {
lines = append(lines, scanner.Text())
}
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
// match them with corresponding strings in the file using the index
numbers := make([][]int, numLines)
@ -68,5 +50,19 @@ func main() {
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)
}
}