awk/testdir/t.randk

14 lines
107 B
Plaintext

{
k = 2
n = NF
i = 1
while ( i <= n ) {
if ( rand() < k/n ) {
print i
k--
}
n--
i++
}
}