#!/usr/bin/ruby class Sachy @@result = [0,0,0,0,0,0,0,0,0] def runit init(0,0) end def init(col,row) if !otestuj(col,row) then return end @@result[row] = col if row == 8 then napisReseni return end dalsi = row + 1 init(1, dalsi) init(2, dalsi) init(3, dalsi) init(4, dalsi) init(5, dalsi) init(6, dalsi) init(7, dalsi) init(8, dalsi) end def otestuj(col,row) if row == 1 then return true end plus = 1 tmp = 0 i = row - 1 while i > 0 if col == @@result[i] then return false end tmp = col + plus if tmp == @@result[i] then return false end tmp = col - plus if tmp == @@result[i] then return false end plus += 1 i -= 1 end return true end def napisReseni puts @@result[1..8].join(" ") end end objekt = Sachy.new objekt.runit