C (86137 characters)
#include <stdio.h>
void rotate(int * aarray, int n, int wk) {
whileint todo = (w--1<<n+1) {-1;
int i = n0, j;
int tmp = a[i-1];array[0];
while (todo) {
if (todo & 1<<i) {
j = (i--k+n)%n;
a[i] array[i] = a[itodo & 1<<j ? array[j] : tmp;
todo -1%n];= 1<<i;
*a i = tmp;j;
} else tmp = array[++i];
}
}
int main() {
int a[] = {1,2,3,4,5,6,7,8,9};
rotate(a, 9, 4);
for (int i=0; i<9;i++) printf("%d ", a[i]);
printf("\n");
}
Function ´rotate´rotate
minified to 86137 characters:
void r(int*a,int n,int wk){whileint m=(w-1<<n+1)-1,i=0,j,t=a[0];while(m)if(m&1<<i){int i=n,t=a[i-1];whilej=(i--k+n)a[i]=a[i%n;a[i]=(m&1<<j)?a[j]:t;m-1%n];*a=t;=1<<i;i=j;}else t=a[++i];}