Re: Symbolify (#169)

Sorry, forgot that rule.

Excuse me…

Already the punch line is told before

—> On 2008/07/13, at 9:56, [email protected] 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§
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
<[email protected]>

=============================

Shindo-san,
I think I understand the basic idea you were attempting to code, but
you might want to revise it; as it is written below, it doesn’t quite
work.

Matthew M. san < Thank you for your comment

On 2008/07/14, at 4:50, Matthew M. wrote:

it doesn’t quite work.

Yes(no?) it’s not only out of work but
also off-track to the context of the quiz,
I’m realizing.

I’d well review solutions of others and regenerate mine
(^_^;) – smile with sweats –

=============================
I’ve 3 bits, from time to time

     Shindo  Motoakira
<[email protected]>

=============================