Generating a random permutation using code like
#! /bin/bash # # ranperm256 - write to std-out a random permutation of the 256 integers # 0..255. The random permutation is writen as a 16x16 matrix. awk 'BEGIN { for (i = 0; i < 256; i++) p[i] = i srand() for (i = 0; i < 255; i++) { j = i + int(rand()*(256 - i)) t = p[i] p[i] = p[j] p[j] = t } for (i = 0; i < 16; i++) { for (j = 0; j < 16; j++) printf "%4d", p[i*16 + j] print "" } exit } '
This page last modified on 24 January 2006.