#!/usr/bin/tclsh
set number [expr floor(rand()*99)+1]
set guess 0
set times 0
puts {Guess a number between 1 and 100}
while {$guess != $number} {
puts -nonewline {Your guess: }
flush stdout
set guess [gets stdin]
set times [expr $times + 1]
if {$number != $guess} {
if {$number > $guess} {
puts {The number is bigger}
} else {
puts {The number is smaller}
}
} else {
puts "It did take you $times tries to find the number."
return
}
}