From: SHINDO Motoaki Date: 2008-07-13T13:43:31+09:00 Subject: [QUIZ] Symbolify (#169) Excuse me… Already the punch line is told before ---> On 2008/07/13, at 9:56, ruby@alef1.org wrote: so, my source code, putting here(below) is no spoiling? With the source, I'm in troubled of Syntax Errors. the code is of C-language-thinking of mine, and casting problems about… Char|Symbol, String, Array or REGEXP-escape, and Scope of variables It maybe another Quiz… -----source follows----- #!/usr/bin/env ruby -Ku #Oh, by the way... You may only use the characters `?`, `*`, `(`, `)` and `-`. #s #Specifically, define a function `symbolify` that accepts an integer #and returns a string composed of only the five characters shown above. #The string, when evaluated, will equal the original number passed in. def init str = ':?:*:(:):-' 5.times { |i| letters[i] = str[i] } end #init def symb1(i) s = "" p = i / 5 # p = (i.abs) / 5 unless p < 1 symb1(p) end q = i.mod(5) s += letters(q) end def symbolify(i) letters = [] init puts i symb1(i) # symb2(i) end puts symbolify(ARGV[1].to_i) === end of source === ============================= I've 3 bits, from time to time Shindo Motoakira =============================