Compare commits

...

2 Commits

Author SHA1 Message Date
5f2c093e72 WIP of new approach 2023-12-03 16:52:32 +00:00
99db2b88a2 Scrapping the current approach. Archival purpose 2023-12-03 16:10:23 +00:00

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[T any](x T) {
func PrintAndWait(x ...any) {
fmt.Print(x)
fmt.Scanln()
}
func main() {
file, err := os.Open("./inputs/day03_test_input")
file, err := os.Open("./inputs/day03_input")
check(err)
defer file.Close()
@ -38,7 +38,25 @@ 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)
@ -50,19 +68,5 @@ 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)
}
*/
}