[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Symbolify (#169

ruby

7/13/2008 12:57:00 AM

Sorry, forgot that rule.

>> Just make test pass....
>
>According to my watch, you're about 24 hours too early.
>

3 Answers

SHINDO Motoaki

7/13/2008 4:44:00 AM

0

Excuse me=85

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=85
Char|Symbol, String, Array or REGEXP-escape,
and Scope of variables

It maybe another Quiz=85

-----source follows-----

#!/usr/bin/env ruby -Ku

#Oh, by the way... You may only use the characters `?`, `*`, `(`, `)` =20=

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 =3D ':?:*:(:):-'
5.times { |i|
letters[i] =3D str[i]
}
end #init

def symb1(i)
s =3D ""
p =3D i / 5
# p =3D (i.abs) / 5
unless p < 1
symb1(p)
end
q =3D i.mod(5)
=09
s +=3D letters(q)
end


def symbolify(i)
letters =3D []
init

puts i
symb1(i)
# symb2(i)
end


puts symbolify(ARGV[1].to_i)

=3D=3D=3D end of source =3D=3D=3D



=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
I've 3 bits, from time to time

Shindo Motoakira
<motoakira@mac.com>
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D









Matthew Moss

7/13/2008 7:50:00 PM

0

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.


On Jul 12, 11:43=A0pm, SHINDO Motoaki <motoak...@mac.com> wrote:
> #!/usr/bin/env ruby -Ku
>
> #Oh, by the way... You may only use the characters `?`, `*`, `(`, `)` =A0
> 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
> =A0 =A0 =A0 =A0 str =3D ':?:*:(:):-'
> =A0 =A0 =A0 =A0 5.times { |i|
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 letters[i] =3D str[i]
> =A0 =A0 =A0 =A0 }
> end #init
>
> def symb1(i)
> =A0 =A0 =A0 =A0 s =3D ""
> =A0 =A0 =A0 =A0 p =3D i / 5
> # =A0 =A0 =A0 p =3D (i.abs) / 5
> =A0 =A0 =A0 =A0 unless p < 1
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 symb1(p)
> =A0 =A0 =A0 =A0 end
> =A0 =A0 =A0 =A0 q =3D i.mod(5)
>
> =A0 =A0 =A0 =A0 s +=3D letters(q)
> end
>
> def symbolify(i)
> letters =3D []
> =A0 =A0 =A0 =A0 init
>
> =A0 =A0 =A0 =A0 puts i
> =A0 =A0 =A0 =A0 symb1(i)
> # =A0 =A0 =A0 symb2(i)
> end
>
> puts symbolify(ARGV[1].to_i)
>

SHINDO Motoaki

7/13/2008 11:55:00 PM

0

Matthew Moss san < Thank you for your comment

On 2008/07/14, at 4:50, Matthew Moss 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
<motoakira@mac.com>
=============================