Ad
  • Default User Avatar

    Very good kata for practice !!! ;)

  • Default User Avatar

    Same for me !!! Not good at all !!!

  • Default User Avatar

    Can you guys help me , why doesn't my average function works :
    class Array
    def square
    # create your square method here
    self.map {|n| n ** 2}
    end

    def cube()
    self.map {|n| n**3}

    end

    def average()

    self.map ((sum.inject(0) { |z,x| sum + x }) / self.length)

    end

    def sum(x)

    sum.inject(0){|sum,x| sum + x }
    end
    def even()

    even.values_at(* even.each_index.select {|i| i.even?})

    end
    def odd()
    odd() { return this.filter(odd(x) { return 0 == x % 2; }); }
    end

    now fill in the rest

    end

    when I tested it's giving "wrong number of agruments."