go: add «2582. Pass the Pillow»

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-07-06 11:05:16 +02:00
parent d34c3e5b3d
commit e4dbf828e0
Signed by: mfocko
SSH key fingerprint: SHA256:5YXD7WbPuK60gxnG6DjAwJiS9+swoWj33/HFu8g8JVo

10
go/pass-the-pillow.go Normal file
View 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
}