[solution] quizz 126

Discussion in 'Ruby' started by philip, Jun 3, 2007.

  1. philip

    philip Guest

    Hi,
    here is the one i came up with:

    ------first-----------------------------

    c=100

    def chaos_coop x
    a1,a2 = (x % 3 == 0) ? ["Fizz","Fizz"] : ["",x]
    (x % 5 == 0) ? a1 +"Buzz" : a2
    end

    (1..c).each {|x|
    puts chaos_coop(x) }

    -----second-----------------------------------

    c=100
    def square_coop x
    a3=(x % 3 == 0) ? 1 : 0
    a5=(x % 5 == 0) ? 2 : 0

    case a3+a5
    when 0 : x
    when 1 : "Fizz"
    when 2 : "Buzz"
    when 3 : "FizzBuzz"
    end
    end

    (1..c).each {|x|
    puts square_coop(x) }
     
    philip, Jun 3, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tyshanchn
    Replies:
    1
    Views:
    330
    Thomas Schodt
    May 10, 2006
  2. tyshanchn
    Replies:
    2
    Views:
    562
    Matt Atterbury
    May 10, 2006
  3. Rick DeNatale
    Replies:
    0
    Views:
    117
    Rick DeNatale
    Jun 3, 2007
  4. doug meyer

    [QUIZ] FizzBuzz (#126) [SOLUTION]

    doug meyer, Jun 3, 2007, in forum: Ruby
    Replies:
    0
    Views:
    152
    doug meyer
    Jun 3, 2007
  5. MenTaLguY
    Replies:
    12
    Views:
    322
    MenTaLguY
    Jun 7, 2007
Loading...

Share This Page