From: anansi on 3 May 2007 11:32 Puria Nafisi Azizi wrote:> anansi wrote: >> Maybe someone is interested or has an idea for an unoffical Ruby Quiz >> for this week. I'm bored , so If someone has any idea, feel free to drop > conway's game of life? > Never heard about it but read now wiki and sounds interesting, so I would try it. Would you suggest a fixed count of columns and rows for that, if yes which? -- greets ( ) ( /\ .-"""-. /\ //\\/ ,,, \//\\ |/\| ,;;;;;, |/\| //\\\;-"""-;///\\ // \/ . \/ \\ (| ,-_| \ | / |_-, |) //`__\.-.-./__`\\ // /.-(() ())-.\ \\ (\ |) '---' (| /) ` (| |) ` jgs \) (/ one must still have chaos in oneself to be able to give birth to a dancing star From: Puria Nafisi Azizi on 3 May 2007 11:40 anansi wrote:> Never heard about it but read now wiki and sounds interesting, so I > would try it. Would you suggest a fixed count of columns and rows for pass it as an argument From: anansi on 3 May 2007 11:58 Puria Nafisi Azizi wrote:> anansi wrote: >> Never heard about it but read now wiki and sounds interesting, so I >> would try it. Would you suggest a fixed count of columns and rows for > pass it as an argument > k so far I would suggest: (I) passing row and col count as arguments (II) rules for cell stati: 1) life : a cell has 2 or 3 alive neighbours 2) death: a cell has <2 or >3 alive neighbours 3) birth: an empty field has 3 alive neighbours but what's about the initial cells to begin with ? any suggestions? randomly with a percentage Input how many cells, dependent on fields at all shall be filled ? by the hand of the user ? fixed patterns to fill them? -- greets ( ) ( /\ .-"""-. /\ //\\/ ,,, \//\\ |/\| ,;;;;;, |/\| //\\\;-"""-;///\\ // \/ . \/ \\ (| ,-_| \ | / |_-, |) //`__\.-.-./__`\\ // /.-(() ())-.\ \\ (\ |) '---' (| /) ` (| |) ` jgs \) (/ one must still have chaos in oneself to be able to give birth to a dancing star From: Puria Nafisi Azizi on 3 May 2007 13:06 anansi wrote:> Puria Nafisi Azizi wrote: >> anansi wrote: >>> Never heard about it but read now wiki and sounds interesting, so I >>> would try it. Would you suggest a fixed count of columns and rows for >> pass it as an argument >> > > k so far I would suggest: > > (I) > passing row and col count as arguments > (II) > rules for cell stati: > 1) life : a cell has 2 or 3 alive neighbours > 2) death: a cell has <2 or >3 alive neighbours > 3) birth: an empty field has 3 alive neighbours > > but what's about the initial cells to begin with ? > any suggestions? randomly with a percentage Input how many cells, > dependent on fields at all shall be filled ? by the hand of the user ? pass as an argument to star with: * a glider * a glider gun * a 10x10 input file * a 10x10 random cells * an exploder pah, is not yet friday From: Paul Novak on 3 May 2007 15:32 One more way to do it: mutually recursive functions that each strip off the last character and alternate the doubling: http://pastie.caboo.se/58669 or def luhn_sum s val = s.slice!(-1) if val==nil return 0 end val.chr.to_i + luhn_helper( s) end def luhn_helper s val = s.slice!(-1) if val==nil return 0 end (2 * val.chr.to_i).to_s.split("").inject(0){|sum,x|sum + x.to_i} + luhn_sum( s) end def luhn? s luhn_sum(s) % 10 == 0 end Regards, Paul. First  |  Prev  |  Next  |  Last