Ad
  • Custom User Avatar

    CoffeeScript random tests sometimes include two or three zero arguments. That's not a valid triangle, and according to the description shouldn't be tested.

    One of the arguments equals zero.
    You will not be expected to handle any erronous data in your solution.

  • Custom User Avatar
  • Custom User Avatar

    Typos corrected, maybe you could try again? Thanks all for your posts about Crystal.

  • Custom User Avatar

    I can't neither :[. Seems that there's a typo in a method in the test cases.

  • Custom User Avatar

    Nice output in the tests.

  • Custom User Avatar

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

  • Custom User Avatar
  • Custom User Avatar

    Оспс за перевод :)

  • Custom User Avatar

    Вот невезет) Лог запусти да посмотри)

  • Custom User Avatar

    Great, thank you!

  • Custom User Avatar

    Вот рабочий код, для теста {"Paraguay"=>"Paraguay,113942,149030,323310", "Uruguay"=>"Uruguay,24709,519674,16683", "China"=>"China,275550,728143,25494", "Iran"=>"Iran,428961,438063,9826", "UEA"=>"UEA,587597,590633,174208", "Korea-N"=>"Korea-N,112098,11703,25040", "Germany"=>"Germany,102520,237449,442660", "Iraq"=>"Iraq,360058,592029,664551", "Norway"=>"Norway,35149,159242,794559", "Finland"=>"Finland,177447,654318,288166", "USA"=>"USA,618781,25920,481752", "Korea_S"=>"Korea_S,556992,355449,1852"} выдает правильный результат "USA-UEA-Korea_S-Iran-Iraq-China-Finland-Paraguay-Korea-N-Germany-Norway-Uruguay"

    def order_countries(list_of_countries)
      list_of_countries.each { |key, value| list_of_countries[key] = list_of_countries[key].gsub(/\D+,/, '').split(',').map(&:to_i) }.sort { |a,b| (a[1] <=> b[1]).nonzero? || (b[0] <=> a[0]) }.reverse.to_h.keys.join('-')
    end
    

    Но, автор перевода в тесткейсах намудрил, или вырубил поддержку split :)

  • Custom User Avatar

    Если так, то можно будет проверку по размеру из sort выкинуть, т.к. sort для string-чисел работает не как натуральный.

  • Custom User Avatar

    Как-то так :) Только нужно придумать что с значениями ключей сделать вида 140890,58174,117569. Быть может их в массив с числами. Твои идеи? :)

    def order_countries(list_of_countries)
      list_of_countries.each { |key, value| value.gsub!(/\D+,/, '')}.sort { |a,b| ([a[1].size, a[1]] <=> [b[1].size, b[1]]).nonzero? || (b[0] <=> a[0]) }.reverse.to_h.keys.join('-')
    end
    
  • Custom User Avatar

    Нихера не поянл) Какое другое?

  • Custom User Avatar

    Pretty good indeed, although starting from a Ruby one, in this case alone, might have helped ;)

  • Loading more items...