diff options
Diffstat (limited to 'challenge-078/stuart-little/lua/ch-2.lua')
| -rwxr-xr-x | challenge-078/stuart-little/lua/ch-2.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-078/stuart-little/lua/ch-2.lua b/challenge-078/stuart-little/lua/ch-2.lua new file mode 100755 index 0000000000..fd09ac713c --- /dev/null +++ b/challenge-078/stuart-little/lua/ch-2.lua @@ -0,0 +1,16 @@ +#!/usr/bin/env lua + +-- run <script> <space-separated array entries, then ' - ', then space-separated rotation indices> + +local nrs = {} +while (tonumber(arg[1])) do + table.insert(nrs,tonumber(arg[1])) + table.remove(arg,1) +end +table.remove(arg,1) +for _,v in ipairs(arg) do + local vv = (v-1)%#nrs+1 + local s=table.pack(table.unpack(nrs,vv+1)) + for i=1,vv do table.insert(s,nrs[i]) end + print(table.unpack(s)) +end |
