Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#!/bin/ksh
function in_range_random_number
{
# Create a pseudo-random number less than or equal
# to the $UPPER_LIMIT value which is passwd as command
# line argument $1.
echo "$(($RANDOM % $1 + 1))"
}
NUMSTR=4 # number of strings
X=0
for STR in sally bill greg jim
do
((X+=1)) # Increment the counter by 1
MYSTR[$X]=$STR
done
UPPER_LIMIT=$X # Random Number Upper Limit
#
# Produce the "for" loop list of elements that represent
# the number of strings
FOR_COUNT=$(
X=0
while ((X < NUMSTR))
do
((X+=1))
echo "$X "
done
)
# Build the string using random numbers to grab array
# elements from the MYSTR array.
for i in 1 2 3 4
do
NEWSTR=""
for i in $FOR_COUNT
do
NEWSTR="${NEWSTR} ${MYSTR[$(in_range_random_number $UPPER_LIMIT)]}"
done
echo $NEWSTR
done
BEGIN {
strN=split("1 2 3", str, " ")
permute(str, 1, strN)
}
function printV(v, size, i)
{
for (i = 1; i <= size; i++) {
printf("%4d", v[i] );
}
printf("\n");
}
function permute(v, start, n, i,tmp)
{
if (start == n) {
printV(v, n);
}
else {
for (i = start; i <= n; i++) {
tmp = v[i];
v[i] = v[start];
v[start] = tmp;
permute(v, start+1, n);
v[start] = v[i];
v[i] = tmp;
}
}
}