01: part1
This commit is contained in:
commit
4779e181a2
3 changed files with 2050 additions and 0 deletions
25
1/part1.go
Normal file
25
1/part1.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
count := 0
|
||||
lastValue := math.MaxInt64
|
||||
|
||||
s := bufio.NewScanner(os.Stdin)
|
||||
for s.Scan() {
|
||||
value, _ := strconv.Atoi(s.Text())
|
||||
if value > lastValue {
|
||||
count++
|
||||
}
|
||||
lastValue = value
|
||||
}
|
||||
|
||||
fmt.Println(count)
|
||||
}
|
25
1/part2.go
Normal file
25
1/part2.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
count := 0
|
||||
lastValue := math.MaxInt64
|
||||
|
||||
s := bufio.NewScanner(os.Stdin)
|
||||
for s.Scan() {
|
||||
value, _ := strconv.Atoi(s.Text())
|
||||
if value > lastValue {
|
||||
count++
|
||||
}
|
||||
lastValue = value
|
||||
}
|
||||
|
||||
fmt.Println(count)
|
||||
}
|
Loading…
Reference in a new issue