Ad
  • Custom User Avatar

    Just a quick feedback : perhaps make the description a bit more detailed :

    I had to look up what cubed numbers mean, and perhaps one example wouldn't hurt :)

  • Custom User Avatar

    You shouldn't beat yourself up : I also think too much of myself as producing 'garbage' code - but that is not the point of kata's like these. They are meant (at least for me they do) to think about a problem and produce a solution, and then trying to clean the solution as best as I possibly can. And that in itself is invaluable training. :)

  • Custom User Avatar

    EDIT : never mind, I found the culprit. For anyone who has the same problem : check WHEN you are rounding in your code :)


    I think some of the tests are inaccurate :

    I'm trying to solve this recursively and all seems well with my own tests, however, here I stumble on precision errors.

    As I've said, all seems to work well with relative low $n numbers with little to no rounding errors but for example with $n beeing 36 I get this :

    (I've deliberately formatted the number to show 20 decimals, to illustrate my point)

    Failed asserting that two strings are equal.
    Expected: '2.26'
    Actual : '2.24999999999999689138'

    I've manually (yeah, I know :) ) calculated this and taking rounding into account, this should be 2.25.

    Did I oversee something, or am I doing something wrong?

    PS : did not include my solution ATM, but if you understand recursive, you get the idea of what I'm doing :)

  • Custom User Avatar

    You're mutating the input list, affecting the control function.

  • Custom User Avatar

    Acknowledged, but if this is the case, then there should be a standard test that incorporates just that, just to eleminate any doubt. So, needs (some) fixing :)

    Anyway, moving on...

  • Custom User Avatar

    ...needless directions removed (W<->E or S<->N side by side)

    Note
    Not all paths can be made simpler. The path ["NORTH", "WEST", "SOUTH", "EAST"] is not reducible. "NORTH" and "WEST", "WEST" and "SOUTH", "SOUTH" and "EAST" are not directly opposite of each other and can't become such. Hence the result path is itself : ["NORTH", "WEST", "SOUTH", "EAST"].

    It's already there.

  • Custom User Avatar

    I have :

    "Write a function dirReduc which will take an array of strings and returns an array of strings with the needless directions removed (W<->E or S<->N side by side)."

    The Expected array still has those directions which can be removed. The fact that these are not side by side should not matter, they are needless and can be removed.

    Either fix the kata to include that ONLY the directions which are side by side are to be removed (AND add a test which reflects this without question), or fix the solution alltogether so that the result really are simplified directions.

    I am not the only one saying the solution is confusing, by the way :)

    I am moving on, just a pity for the work I've put in so far.

  • Custom User Avatar

    Nothing to fix. Read the instructions again.

  • Custom User Avatar

    I'm sorry, the PHP Random tests are flawed : just think about it :

    Failed asserting that two arrays are equal.
    Expected: Array (
    0 => 'SOUTH'
    1 => 'WEST'
    2 => 'NORTH'
    3 => 'EAST'
    4 => 'SOUTH'
    5 => 'WEST'
    6 => 'WEST'
    7 => 'NORTH'
    )
    Actual : Array (
    0 => 'WEST'
    1 => 'WEST'
    )

    Whip open Excel or write it down : place start in the middle of the sheet and count the steps to the expected destination and compare to the actual solution. Beats the expected solution every time.

    Can this be fixed ASAP ?

  • Custom User Avatar

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