6 kyu

Paperboy 2

66 of 110TroyMaeder
Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • FArekkusu Avatar

    Examples in the description are JavaScript-specific.

  • FArekkusu Avatar

    Tests where a single paperboy can deliver everything should be added in JavaScript. Such cases are generated randomly in Python, and having at least one fixed test would be good too.

  • FArekkusu Avatar

    Initial solution is wrong in Python.

  • RealKenshiro Avatar

    Cool but tricky...

  • Unnamed Avatar

    Python random tests:

    Testing for 'Richmond upon Thames', 584, 58 and 0.25
    
    It should work for random inputs too: '47 paperboys needed for Richmond upon Thames' should equal '44 paperboys needed for Richmond upon Thames'
    
  • Voile Avatar

    Your fixes tests is a nightmare to debug.

    Why can't you run the user solution once perform one test at a time? Running them all at once and then sorting the results to do comparison is messy.

  • msachi Avatar

    Nice Kata!

    I think your rounding logic is correct, but I think it will still confuse (too) many people.

    I would suggest you:

    1. Put some of the tricky edge cases (where the solution depends on rounding) already in your example test cases, and
    2. Make your test cases print what parameters they are testing for. Otherwise it gets very frustrating

    Also your description asks for an object with a method, whereas the code template suggests a function

  • GiacomoSorbi Avatar

    Python and Ruby translations submitted; note that I opted to follow the rounding criteria chosen by the original author, so if you have problems with that, try to read the previous discussion to get some tip :)

  • mattcollier Avatar

    From reading the previous discussion, I can see that there is some indecision about rounding. This rounding error caused my implementation to fail ONLY the 'City Line' test.

    I believe your refrence implementation is introducing rounding errors. I believe a single Math.ceil rounding on the entire calculation is in order. You have chosen to round down on an arbitrary grouping.

    In situations like this it is understood that the number of papers delivered per time interval is an average and therefore it isn't valid to argue that a paper delivery person cannot deliver a fraction of a paper.

  • myjinxin2015 Avatar

    This comment has been hidden.

  • bkaes Avatar

    The code that should get written isn't really idiomatic JavaScript:

    var route1 = new Route("Brooklyn Heights", 400, 30, 1);
    Test.assertEquals(route1.paperboysNeeded(), "2 paperboys needed for Brooklyn Heights");
    

    Why not

    Test.assertEquals(paperboysNeeded("Brooklyn Heights", 400, 30, 1), "2 paperboys needed for Brooklyn Heights");
    

    After all, you ask for a function, not for an object that has a method. Either fix your description or your tests.

  • donaldsebleung Avatar

    The 5th fixed test is definitely faulty since I passed all the tests (fixed and random) except that one. I had to brute force my way through that particular test case to pass all the tests.

    Please fix it ASAP. Thank you very much :)

    Cheers, donaldsebleung

  • donaldsebleung Avatar

    Are you sure the maths in all the test cases for this Kata is correct?

    I coded a solution that passed all the example tests but failed on the 5th fixed test in your actual test fixture. Details are as follows:

    { name: 'Brownsville',
    houses: 400,
    minsPer50Houses: 45,
    deliveryTimeInHours: 1 }
    

    According to my program, only 4 extra paperboys are needed because:

    1. Assume we need 6 paperboys in total. Then productivity increases sixfold and the minutes per 50 * 6 === 300 houses is 45.
    2. This means that the minutes per house is 45 / 300, or rather, 0.15.
    3. Multiply 0.15 minutes per house by 400 houses and we get 60 minutes (i.e. 1 hour) which meets the deliveryTimeInHours exactly.

    However, that particular test case says that 5 extra paperboys are needed for the task (i.e. 7 total). Why is that?