Revision 83f8109e-3f6c-40c5-9f5c-aae9e4afdc0f - Code Golf Stack Exchange

#J - <del>32</del> 29

<del>Not</del> shorter than other J solution, <del>but</del> and uses a different idea

 (]{.i:@(-:@(1-])-[%]))/ ::_1:

Here is Wolfram Language ungolfing

 If[IntegerQ@#,Range[#,#-m+1,-1],-1]&[n/m+(m-1)/2]

The answer for the number of coins the highest rank gnome is getting is simply `N/M+(M-1)/2` (if it's an integer), we construct the negative of this `(-:@(1-])-[%])`. Then `i:` makes an array like that `2 1 0 _1 _2` for argument `_2` and we take M elements from it.

AltStyle によって変換されたページ (->オリジナル) /