9 int main(int argc
, char **argv
)
13 int size
= atoi(argv
[1]);
14 if (size
< 2 || size
> 256)
16 unsigned char *list
= malloc (size
);
17 for (int i
= 0; i
< size
; i
++)
24 while ((length
= strtol (p
, &end
, 10)), p
!= end
) {
25 printf ("length %d, skip %d, pos %d\n", length
, skip
, pos
% size
);
26 for (int i
= 0; i
< length
/ 2; i
++) {
27 int tmp
= list
[(i
+ pos
) % size
];
28 list
[(i
+ pos
) % size
] = list
[(length
- i
- 1 + pos
) % size
];
29 list
[(length
- i
- 1 + pos
) % size
] = tmp
;
32 printf (" %d %d %d %d %d\n", list
[0], list
[1], list
[2], list
[3], list
[4]);
33 pos
+= length
+ skip
++;
36 printf ("final product %d\n", list
[0] * list
[1]);
42 int main(int argc
, char **argv
)
47 unsigned char list
[size
];
48 for (int i
= 0; i
< size
; i
++)
52 const char suffix
[6] = { 17, 31, 73, 47, 23 };
53 char *str
= malloc(strlen(argv
[1]) + 5 + 1);
54 strcpy(stpcpy(str
, argv
[1]), suffix
);
55 for (int j
= 0; j
< 64; j
++) {
56 printf ("round %d, skip %d, pos %d\n", j
, skip
, pos
% size
);
57 for (char *p
= str
; *p
; p
++) {
59 for (int i
= 0; i
< length
/ 2; i
++) {
60 int tmp
= list
[(i
+ pos
) % size
];
61 list
[(i
+ pos
) % size
] = list
[(length
- i
- 1 + pos
) % size
];
62 list
[(length
- i
- 1 + pos
) % size
] = tmp
;
64 pos
+= length
+ skip
++;
67 unsigned char chunk
= 0;
68 for (int i
= 0; i
< size
; i
++) {
71 printf ("%02x", chunk
);