#!/bin/rc n = 5 if(~ $1 [3-9] || ~ $1 1[0-5]) n = $1 w = () echo Thinking of a $n letter word... while(! ~ $#w $n){ w = () fortune /lib/words | grep -v '[^a-z]' | while(w = ($w `{read -c 1})); } fn sighup sigint{ echo You gave up! The word was: echo $w | tr -d ' ' | tr a-z A-Z exit interrupted } echo Okay, got one. Guess! g = () read | tr A-Z a-z | while(g = ($g `{read -c 1})); if(~ $"g $"w) echo Wow, first try! if not echo Upper case are in right place, lower case in wrong place: while(! ~ $"g $"w){ found = () for(i in `{seq $n}) if(~ $g($i) $w($i)) found = ($found $g($i)) for(i in `{seq $n}){ if(~ $g($i) $w($i)) echo -n $g($i) | tr a-z A-Z if not if(~ $g($i) '' || ~ $g($i) $found || ! ~ $g($i) $w) echo -n - if not echo -n $g($i) | tr A-Z a-z } echo g = () read | tr A-Z a-z | while(g = ($g `{read -c 1})); } echo You got it! echo $w | tr -d ' ' | tr a-z A-Z