6 kyu

Friendly Pairs I

221 of 241erdos2n
Description
Loading description...
Number Theory
Algorithms
  • Please sign in or sign up to leave a comment.
  • wqqzum Avatar

    This comment has been hidden.

  • wqqzum Avatar

    This comment has been hidden.

  • ahmet_popaj Avatar

    Really interesting challenge, compliments for the kata.

  • FArekkusu Avatar
  • user9644768 Avatar

    Ruby 3.0 should be enabled, see this to learn how to do it

    Please organize the structure of test fixture as following (although it has been mentioned in the attached link, I'm repeated here again)

    describe "<This message should describe the categories of test groups inside this block>" do
      it "<A short message describing this test group>" do
        expect(...).to eq(...) #Assertions
        #Or Test.assert_equals(user_response, reference_response)
      end
    end
    
  • anter69 Avatar

    Ruby translation kumited, including slightly improved description. Please check and approve

  • anter69 Avatar
    • the docstring (comment) asks to "Return True if they are friendly pairs", but the description says otherwise
    • furthermore, the description asks to return "Friendly", but the tests expect "Friendly!"
    • function name should use friendly_numbers, instead of friendlyNumbers (see note below)
    • could make python 3 the default version
    • description could use a little fixing (put a space after bullet points, highlight variable names, etc)

    Note: to fix the naming in a compatible way, put this at the top of the test suite:

    try:
        friendly_numbers = friendlyNumbers
    except NameError:
        pass
    

    ...and rename all appearances of the function name (also in the sample test, solution, etc. boxes)

  • Voile Avatar

    Approved

  • Blind4Basics Avatar

    I almost declared that an issue, but... Well, in python that works...

    => it's bad practice to return different type of output so you should always return a string. "Friends!" for example.

    Note that in some languages, it's impossible to return different types of output with the same function.

    • erdos2n Avatar

      Great suggestion! Update: Made the edit and republished.

    • Blind4Basics Avatar

      Well, I have some others, actually ;)

      • you might want to give the range of the values (that could reassure those who are not confortable with this kind of stuff)
      • the description misses some important (?) informations:
        • what about the precision in the comparison of A(m) and A(n)? since we compare doubles, do we need to take some extra care about that? (Yes, we do not, but that would be nice mentionning something about it, I believe)
        • more important: say explicitly that we'll need to simplify the fractions.
    • Blind4Basics Avatar

      Two (EDIT: well... not only... x-D ) more things:

      • add your fixed (sample) tests to the test cases.
      • about that, it would be nice to have a "real" bunch of fixed tests in the test cases (more than the 3 (4? :o ) sample tests, I mean)
      • use Test.decribe("...") before each of your loops to present the tests, so one knows what this is about
      • ... 8-o (this one will need a new message...)
      • There may be a drawback with the "Frinedly!" tests: a wonrg calculation still leading to equal values will pass the tests (something like... A(m) = A(n) = 0... I did it (=> should be in my bed, right now, actually)). If you put some fixed tests before those, that shouldn't bother you. If it does anyway, you'll have to change again the output... ('Friendly! X/Y both!"?)
    • Blind4Basics Avatar

      This comment has been hidden.

    • erdos2n Avatar

      This comment has been hidden.

    • Blind4Basics Avatar

      This comment has been hidden.

    • erdos2n Avatar

      I made more edits to the explanation and added more test cases. I'm going to mark as resolved, if there's more to do, let me know. Thanks again!

      Suggestion marked resolved by erdos2n 8 years ago
    • Blind4Basics Avatar

      Floats should be left on without rounding when you compare the abundancies of the two numbers ;)

    • erdos2n Avatar

      it's all fixed now...i think :)