-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.go
60 lines (48 loc) · 766 Bytes
/
input.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"fmt"
)
type Unit struct {
x, y, z float64
}
type Turn struct {
Power float64
L, R string
}
type Game struct {
Units []Unit
}
func InputGame(data []string) Game {
var err error
var game Game
var size int
size = StrToInt(data[0])
data = data[1:]
var unit Unit
units := make([]Unit, 0, size)
for i := 0; i < size; i++ {
_, err = fmt.Sscan(data[i], &unit.x, &unit.y, &unit.z)
if err != nil {
panic(err)
}
units = append(units, unit)
}
// some additional logic
game.Units = units
return game
}
func InputStep(data []string) Turn {
var err error
var turn Turn
_, err = fmt.Sscan(
data[0],
&turn.Power,
&turn.L,
&turn.R,
)
if err != nil {
panic(err)
}
// some additional logic
return turn
}