BİLGİSAYAR TAHMİNLİ SAYI OYUNU  DL is deprecated, please use Fiddle irb(main):001:0> def oyun irb(main):002:1> puts 'bilgisayar tahminli sayi oyunu' irb(main):003:1> a=[] irb(main):004:1> sayi=(1..1000).to_a.sample irb(main):005:1> tahmin=(1..1000).to_a.sample irb(main):006:1> a<<tahmin irb(main):007:1> sayac=1 irb(main):008:1> while sayi!=tahmin do irb(main):009:2* if sayi>tahmin then irb(main):010:3* tahmin=(1..1000).to_a.sample irb(main):011:3> a<<tahmin irb(main):012:3> sayac=sayac+1 irb(main):013:3> else if sayi< tahmin then irb(main):014:4* tahmin=(1..1000).to_a.sample irb(main):015:4> a<<tahmin irb(main):016:4> sayac=sayac+1 irb(main):017:4> end irb(main):018:3> end irb(main):019:2> end irb(main):020:1> p "bulundugunuz tahminler #{a}" irb(main):021:1> p " sayi #{sayac}. seferde dogru tahmin edilmistir" irb(main):022:1> p "aranilan sayi  #{sayi} sizin tahmininiz #{tahmin}" irb(main):023:1> end  KULLANICI TAHMİNLİ SAYI OYUNU  DL is deprecated, please use Fiddle irb(main):001:0>  def oyun irb(main):002:1>  puts 'Kullanıcı tahminli sayi oyunu' irb(main):003:1>  puts '1 ile 100 arasında sayi tahmini yapınız' irb(main):004:1>  sayac=1 irb(main):005:1>  a=[] irb(main):006:1>  sayi=(1..100).to_a.sample irb(main):007:1>  tahmin=gets.to_i irb(main):008:1>  a<<tahmin irb(main):009:1>  while sayi !=tahmin do irb(main):010:2*  if tahmin > sayi then irb(main):011:3*  p 'lutfen daha kucuk bir sayi tahmin ediniz' irb(main):012:3>  tahmin=gets.to_i irb(main):013:3>  a<<tahmin irb(main):014:3>  sayac=sayac+1 irb(main):015:3>  else if tahmin < sayi then irb(main):016:4*  p 'lutfen daha buyuk bir sayi tahmin ediniz' irb(main):017:4>  tahmin=gets.to_i irb(main):018:4>  a<<tahmin irb(main):019:4>  sayac=sayac+1 irb(main):020:4>  else irb(main):021:4*  end irb(main):022:3>  end irb(main):023:2>  end irb(main):024:1>  p "bulundugunuz tahminler #{a}" irb(main):025:1> <ler sayiyi #{sayac}.denemenizde dogru tahmin ettiniz" irb(main):027:1> irb(main):028:1*  p "aranilan sayi  #{sayi} sizin tahmininiz #{tahmin}" irb(main):029:1> irb(main):030:1*  end