Excel VBA, 59 46 Bytes
Golfed
Anonymous VBE Immediate window funtion that takes a space (
) delimited array string as input from range [A1]
and output the numbers modulus their 1-based index in the starting list to the VBE immediate window
For Each n In Split([A1]):i=i+1:?n Mod i;:Next
Input / Output:
[A1]="10 9 8 7 6 5 4 3 2 1" ''# or manually set the value
For Each n In Split([A1]):i=i+1:?n Mod i;:Next
0 1 2 3 1 5 4 3 2 1
Old Sub
routine version
Subroutine that takes input as a passed array and outouts to the VBE immediate window.
Sub m(n)
For Each a In n
i=i+1
Debug.?a Mod i;
Next
End Sub
Input / Ouput:
m Array(10,9,8,7,6,5,4,3,2,1)
0 1 2 3 1 5 4 3 2 1
Ungolfed
Option Private Module
Option Compare Binary
Option Explicit
Option Base 0 ''# apparently Option Base 1 does not work with ParamArrays
Public Sub modIndex(ParamArray n() As Variant)
Dim index As Integer
For index = LBound(n) To UBound(n)
Debug.Print n(index) Mod (index + 1);
Next index
End Sub
Input / Output:
Call modIndex(10,9,8,7,6,5,4,3,2,1)
0 1 2 3 1 5 4 3 2 1
1What... this is a thing? – JAD – 2017-06-15T12:35:47.850
2@JarkoDubbeldam Yes. The game allows players to create their own scenarios, and there is an in-game scripting language designed to supplement mission designing. However, since the language is Turing-complete, you can do pretty much whatever you want with it. – Steadybox – 2017-06-15T13:22:42.937