|
Written by regicide666
|
|
Tuesday, 15 August 2006 |
|
#!/bin/bash # amcoder written for binrev forums programming challenge #5 # by regicide666 # converts text to morse code and morse code to text #http://www.binrev.com/forums/index.php?showtopic=22332&st=0&gopid=202112&#entry202112 morse=(.- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. \ -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- \ --.. .---- ..--- ...-- ....- ..... -.... --... ---.. \ ----. ----- " ") alfanum=(a b c d e f g h i j k l m n o p q r s t u v w x y z \ 1 2 3 4 5 6 7 8 9 0 " ") function echoall { count=0 while (( $count <= 36 )) do echo -n "${alfanum[$count]} = ${morse[$count]} " ((count++)) done } function astoms { count=0 while (( $count < ${#string} )) do count1=0 until [[ ${string:$count:1} == ${alfanum[$count1]} || $count1 == "37" ]] do ((count1++)) done if [[ $count1 == 37 ]] then echo " Unknown Charachter ${string:$count:1} " exit 1 else output[$count]=${morse[$count1]} fi ((count++)) done } function mstoas { count=0 while (( $count < ${#codes[*]} )) do count1=0 until [[ ${codes[$count]} == ${morse[$count1]} || $count1 == "37" ]] do ((count1++)) done if [[ $count1 == 37 ]] then echo " Unknown Code ${codes[$count]} " exit 1 else output[$count]=${alfanum[$count1]} ((count++)) fi done } function usage { echo "amcoder [ a m ] \"words or codes to change\"" echo "amcoder [ h ]" echo "a will change morse to text" echo "m will change text to morse" echo "everything to convert must be in quotes" } if (( $# > 2 )) then usage exit 1 fi case $1 in a) codes=($2) mstoas;; m) string="$2" astoms;; h) usage echoall;; *) usage exit 1;; esac echo ${output[*]} |
|
Last Updated ( Tuesday, 15 August 2006 )
|
|
|
Written by regicide666
|
|
Sunday, 13 August 2006 |
#!/bin/bash #Tower of Hanoi written for binrev forums programming challenge #4 #by regicide666 #This was a fun little game to make and it is fun to play. #The object is to move all the peices to the 3rd peg #without the number on top being greater than the number #on bottom. #http://www.binrev.com/forums/index.php?showtopic=22173 #http://www.regicide666.com/cms/content/view/42/9/ discs=$1 peg1space=1 peg2space=0 peg3space=0 peg1[0]=0 peg2[0]=0 peg3[0]=0 win[0]=0 move=0 function firstplace { while (( $discs > 0 )) do let "peg1[$peg1space] = $discs" let "win[$peg1space] = $discs" ((peg1space++)) ((discs--)) done } function readboard { line=$peg1space clear while (( $line > 0 )) do echo " ${peg1[$line]} ${peg2[$line]} ${peg3[$line]}" ((line--)) done echo "--------------------" echo "peg1 peg2 peg3" echo "" echo "" checkwin getmove } function getmove { echo -n "Frome what peg number: " read fmv echo "" echo -n " To what peg number: " read pmv getdisc } function getdisc { case $fmv in 1) let " peg1top = ${#peg1[*]} - 1" dmv=${peg1[$peg1top]};; 2) let " peg2top = ${#peg2[*]} - 1" dmv=${peg2[$peg2top]};; 3) let " peg3top = ${#peg3[*]} - 1" dmv=${peg3[$peg3top]};; esac if (( $dmv == 0 )) then echo "nope try again" getmove fi checkmove } function checkmove { case $pmv in 1) let " peg1top = ${#peg1[*]} - 1" if (( $dmv < ${peg1[$peg1top]} || "${#peg1[*]}" == 1 )) then echo "move ok" move fi;; 2) let " peg2top = ${#peg2[*]} - 1" if (( $dmv < ${peg2[$peg2top]} || "${#peg2[*]}" == 1 )) then echo "move ok" move fi;; 3) let " peg3top = ${#peg3[*]} - 1" if (( $dmv < ${peg3[$peg3top]} || "${#peg3[*]}" == 1 )) then echo "move ok" move fi;; esac echo "nope try again" getmove } function move { case $fmv in 1) peg1=(${peg1[@]:0:$((${#peg1[@]}-1))});; 2) peg2=(${peg2[@]:0:$((${#peg2[@]}-1))});; 3) peg3=(${peg3[@]:0:$((${#peg3[@]}-1))});; esac case $pmv in 1) peg1=("${peg1[@]}" $dmv);; 2) peg2=("${peg2[@]}" $dmv);; 3) peg3=("${peg3[@]}" $dmv);; esac ((move++)) readboard } function checkwin { wincheck="${win[*]}" peg3check="${peg3[*]}" if [ "$wincheck" == "$peg3check" ] then echo " You Won in $SECONDS seconds!!" echo " It took you $move moves" exit fi } firstplace readboard |
|
Last Updated ( Sunday, 13 August 2006 )
|
|
|
Written by regicide666
|
|
Sunday, 22 May 2005 |
|
I worte this just because I wanted to learn some perl. It takes input from aim and sends back the output. |
|
Read more...
|
|
|
Written by regicide666
|
|
Sunday, 22 May 2005 |
|
This is just a simple price guessing game. There is a logic to it and you should be able to win every time. |
|
Read more...
|
|
|
Written by regicide666
|
|
Sunday, 22 May 2005 |
|
I had to do this for a class so it is basic but can be fun to kill some time. Maybe you could put it on your shell server. |
|
Read more...
|
|
|