Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- func main() {
- var tx, ty, tr int
- var total = -9999999999
- for x := 0; x < 300; x++ {
- println(x)
- for y := 0; y < 300; y++ {
- for f := 1; f < 30; f++ {
- var r = 0
- for x1 := x; x1 < x+f; x1++ {
- for y1 := y; y1 < y+f; y1++ {
- r += calcPowerLevel(x1, y1, 7689)
- }
- }
- if r > total {
- total = r
- tr = f
- tx = x
- ty = y
- }
- }
- }
- }
- println(tx, ty, tr, total)
- }
- func calcPowerLevel(x, y, serial int) int {
- rackId := x + 10
- power := rackId * y
- power += serial
- power *= rackId
- hundr := (power / 100) % 10
- hundr -= 5
- return hundr
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement