Skip to main content
Commonmark migration
Source Link

#Bash, 81

Bash, 81

for((s=20;i++<$1;t=s,s+=RANDOM%5-2,s=s<0|s>39?t:s)){ printf %${s}s.\\n sleep $2 } 

Edit: If the step takes the walker outsite the range 1 to 40 it should be just ignored and the walker position stays the same handled correctly.

Input from command-line options. E.g.:

$ ./randwalk.sh 5 0.5 . . . . . $ 

#Bash, 81

for((s=20;i++<$1;t=s,s+=RANDOM%5-2,s=s<0|s>39?t:s)){ printf %${s}s.\\n sleep $2 } 

Edit: If the step takes the walker outsite the range 1 to 40 it should be just ignored and the walker position stays the same handled correctly.

Input from command-line options. E.g.:

$ ./randwalk.sh 5 0.5 . . . . . $ 

Bash, 81

for((s=20;i++<$1;t=s,s+=RANDOM%5-2,s=s<0|s>39?t:s)){ printf %${s}s.\\n sleep $2 } 

Edit: If the step takes the walker outsite the range 1 to 40 it should be just ignored and the walker position stays the same handled correctly.

Input from command-line options. E.g.:

$ ./randwalk.sh 5 0.5 . . . . . $ 
added 36 characters in body
Source Link
Digital Trauma
  • 73.8k
  • 10
  • 117
  • 268

#Bash, 81

for((s=20;i++<$1;t=s,s+=RANDOM%5-2,s=s<0|s>39?t:s)){ printf %${s}s.\\n sleep $2 } 
for((s=20;i++<$1;t=s,s+=RANDOM%5-2,s=s<0|s>39?t:s)){ printf %${s}s.\\n sleep $2 } 

Edit: If the step takes the walker outsite the range 1 to 40 it should be just ignored and the walker position stays the same handled correctly.

Input from command-line options. E.g.:

$ ./randwalk.sh 5 0.5 . . . . . $ 
$ ./randwalk.sh 5 0.5 . . . . . $ 

#Bash, 81

for((s=20;i++<$1;t=s,s+=RANDOM%5-2,s=s<0|s>39?t:s)){ printf %${s}s.\\n sleep $2 } 

Edit: If the step takes the walker outsite the range 1 to 40 it should be just ignored and the walker position stays the same handled correctly.

Input from command-line options. E.g.:

$ ./randwalk.sh 5 0.5 . . . . . $ 

#Bash, 81

for((s=20;i++<$1;t=s,s+=RANDOM%5-2,s=s<0|s>39?t:s)){ printf %${s}s.\\n sleep $2 } 

Edit: If the step takes the walker outsite the range 1 to 40 it should be just ignored and the walker position stays the same handled correctly.

Input from command-line options. E.g.:

$ ./randwalk.sh 5 0.5 . . . . . $ 
added 212 characters in body
Source Link
Digital Trauma
  • 73.8k
  • 10
  • 117
  • 268

#Bash, 8381

for((s=20;i++<$1;s+=$[RANDOM%5s=20;i++<$1;t=s,s+=RANDOM%5-2]2,s=s<0?0:s>39s=s<0|s>39?39t:s)){ printf %${s}s.\\n sleep $2 } 

Edit: If the step takes the walker outsite the range 1 to 40 it should be just ignored and the walker position stays the same handled correctly.

Input from command-line options. E.g.:

$ ./randwalk.sh 5 0.5 . . . . . $  

#Bash, 83

for((s=20;i++<$1;s+=$[RANDOM%5-2],s=s<0?0:s>39?39:s)){ printf %${s}s.\\n sleep $2 } 

#Bash, 81

for((s=20;i++<$1;t=s,s+=RANDOM%5-2,s=s<0|s>39?t:s)){ printf %${s}s.\\n sleep $2 } 

Edit: If the step takes the walker outsite the range 1 to 40 it should be just ignored and the walker position stays the same handled correctly.

Input from command-line options. E.g.:

$ ./randwalk.sh 5 0.5 . . . . . $  
Source Link
Digital Trauma
  • 73.8k
  • 10
  • 117
  • 268
Loading