From 9925c227a4e5538b74b564d7f7921afbd41ec51b Mon Sep 17 00:00:00 2001 From: Davide Oddone Date: Sun, 3 Dec 2023 16:10:23 +0000 Subject: [PATCH] Scrapping the current approach. Archival purpose --- day03/engine-schema.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/day03/engine-schema.go b/day03/engine-schema.go index dc7cc7b..7c54951 100644 --- a/day03/engine-schema.go +++ b/day03/engine-schema.go @@ -16,7 +16,7 @@ func check(e error) { } } -func PrintAndWait[T any](x T) { +func PrintAndWait(x ...any) { fmt.Print(x) fmt.Scanln() } @@ -61,8 +61,26 @@ func main() { tempSymbols := resym.FindAllString(lines[i], -1) // We associate symbols with an index tempSymbolsIndex := resym.FindAllStringIndex(lines[i], -1) + PrintAndWait(i, "First loop.") + // A line can contain 0 symbols + if len(tempSymbols) == 0 { + symbols[i] = make([]string, 0) + symbolsIndex[i] = make([]int, 0) + } // Add symbols and indexes to the arrays - symbols = append(symbols, tempSymbols) + for j := 0; j < len(tempSymbols); j++ { + PrintAndWait(i, j, "Second loop.") + symbols[i] = append(symbols[i], tempSymbols[j]) + } + for j:= 0; j < len(tempSymbolsIndex); j++ { + PrintAndWait(i, j, "Third loop.") + PrintAndWait(tempSymbolsIndex) + symbolsIndex[i] = append(symbolsIndex[i], tempSymbolsIndex[j][0]) + symbolsIndex[i] = append(symbolsIndex[i], tempSymbolsIndex[j][1]) + } + PrintAndWait(symbols) + PrintAndWait(symbolsIndex) //symbolsIndex = append(symbolsIndex, tempSymbolsIndex) } + PrintAndWait(numbers) }