DEV Community

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

Posted on • Edited on

1

DAY 1 - Advent of Code 2020 w/ GoLang

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

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay