Skip to content

Commit

Permalink
d1
Browse files Browse the repository at this point in the history
  • Loading branch information
anishthite committed Dec 1, 2021
0 parents commit 5e8eec1
Show file tree
Hide file tree
Showing 3 changed files with 2,067 additions and 0 deletions.
32 changes: 32 additions & 0 deletions day1/one.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)

func main(){

file, err := os.Open("one.txt")
if err != nil {
panic(err)
}
defer file.Close()

scanner := bufio.NewScanner(file)

var l []int
ans := 0

for scanner.Scan() {
i, _ := strconv.Atoi(scanner.Text())
l = append(l, i)
}
for i := 1; i < len(l); i++ {
if l[i] > l[i-1] {
ans += 1
}
}
fmt.Println("answer: ", ans)
}
Loading

0 comments on commit 5e8eec1

Please sign in to comment.