Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.62 KB | None | 0 0
  1. package main
  2.  
  3. func main() {
  4.     var tx, ty, tr int
  5.     var total = -9999999999
  6.     for x := 0; x < 300; x++ {
  7.         println(x)
  8.         for y := 0; y < 300; y++ {
  9.             for f := 1; f < 30; f++ {
  10.                 var r = 0
  11.                 for x1 := x; x1 < x+f; x1++ {
  12.                     for y1 := y; y1 < y+f; y1++ {
  13.                         r += calcPowerLevel(x1, y1, 7689)
  14.                     }
  15.                 }
  16.                 if r > total {
  17.                     total = r
  18.                     tr = f
  19.                     tx = x
  20.                     ty = y
  21.                 }
  22.             }
  23.         }
  24.     }
  25.  
  26.     println(tx, ty, tr, total)
  27. }
  28.  
  29. func calcPowerLevel(x, y, serial int) int {
  30.     rackId := x + 10
  31.     power := rackId * y
  32.     power += serial
  33.     power *= rackId
  34.     hundr := (power / 100) % 10
  35.     hundr -= 5
  36.     return hundr
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement