Ad
  • Custom User Avatar

    OP solved it, closing

  • Default User Avatar

    The last expression is puts ..., it returns nil.

  • Custom User Avatar

    Ruby code-

    Below code (as triangle over multiple lines) in string format works. When running tests and submit in CW's its calls 'NilClass' error for the triangle.

    The triangle in the example, this is a String class structure?

    $triangle =
    '1
    3 5
    7 9 11
    13 15 17 19
    21 23 25 27 29'

    def row_sum_odd_numbers(n)
    if $triangle.class == NilClass
    return 1
    else
    new = []

    $triangle.each_line {|x| new << x.split}
    
    var = new[n-1].each.inject(0) {|x,y| x.to_i + y.to_i}
    
    return var
    

    end

    end

  • Custom User Avatar

    The problem is that when the ruby translation was created it was misstranslated and since there have been 500+ translations submitted I cannot do anything about it.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Confusing Kata.....From description & looking at tests, if username, password contains // or || or integers this constitutes "wrong user" string. Below code passes all tests but on submit fails some. The fails seem to invalidate the initial description and objective.

    What is the objective here in Ruby?

    def validate(username, password)

    return username.length > username.delete('^a-zA-Z').length || password.length > password.delete('^a-zA-Z').length ? "Wrong username or password!" : "Successfully Logged in!"

    end

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution