go: add «2582. Pass the Pillow»
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
d34c3e5b3d
commit
e4dbf828e0
1 changed files with 10 additions and 0 deletions
10
go/pass-the-pillow.go
Normal file
10
go/pass-the-pillow.go
Normal file
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
func passThePillow(n int, time int) int {
|
||||
rounds, leftover := time/(n-1), time%(n-1)
|
||||
|
||||
if rounds%2 == 0 {
|
||||
return leftover + 1
|
||||
}
|
||||
return n - leftover
|
||||
}
|
Loading…
Reference in a new issue