DEV Community

loading...
Cover image for DAY 1 - Advent of Code 2020 w/ GoLang

DAY 1 - Advent of Code 2020 w/ GoLang

dizveloper profile image Edvin ・Updated on ・1 min read

DAY 1:
O(n^3) πŸ˜…

package days

import (
    "fmt"

    inputs "../inputs"
)

// One : advent of code, day one part1 and 2
func One() {
    inputSlice := inputs.Day1

    for i := 0; i < len(inputSlice); i++ {
        for j := i + 1; j < len(inputSlice); j++ {
            for y := j + 1; y < len(inputSlice); y++ {
                if (inputSlice[i] + inputSlice[j] + inputSlice[y]) == 2020 {
                    fmt.Println(inputSlice[i] * inputSlice[j] * inputSlice[y])
                }
            }
        }
    }
}

Enter fullscreen mode Exit fullscreen mode

Link to Github source file

Discussion (0)

pic
Editor guide