horvathm

Untitled

Dec 15th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.47 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5. )
  6.  
  7. func main() {
  8.     turns := 30000000
  9.     input := []int{0, 20, 7, 16, 1, 18, 15}
  10.     nums := make([]int, turns + len(input) + 1)
  11.     turn := 1
  12.  
  13.     for _, i := range input {
  14.         nums[i] = turn
  15.         turn++
  16.     }
  17.  
  18.     last := input[len(input) - 1];
  19.  
  20.     for turn <= turns {
  21.         lastturn := nums[last];
  22.         nums[last] = turn - 1;
  23.  
  24.         if lastturn == 0 {
  25.             last = 0;
  26.         } else {
  27.             last = turn - lastturn - 1;
  28.         }
  29.  
  30.         turn++
  31.     }
  32.     fmt.Println(turn, last)
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment