Ad
  • Custom User Avatar

    I don't get how to get around this - I need a hintier hint please ;)

    I assume there's some bind() thing that I'm missing, but as far as I can tell the error comes from teh call, not the function that is called? SO I can't work out how to modify the scope of the test

  • Custom User Avatar
  • Custom User Avatar

    _rqy dalao!

  • Default User Avatar

    When I see returning a pointer in a C++ version of a kata, I beat my head against a nearby wall and switch to a different language. Even more so when I see returning a pointer to a pointer for a rectangular array.
    As for the terms, int[4][4] is what I'd call a multidimensional array, while an array of arrays is just an array of arrays.

  • Default User Avatar

    In C++ after you create an array of arrays you can use [][] for multidimensional indexing.
    But you can not declare an array of array by writing [][]!
    In C++ the mentioned int ans[4][4] is just one array: int *ans. Meaning that it's equivalent with int ans[16] and the compiler is nice enough to do the reindexing for you.
    It is used to make sure that every sub-array's dimension is equal, or to ensure that the allocation of the n x n element is contiguous, hence it is one (contiguous) array.

    True multidimensional arrays on the other hand can be "anywhere" in memory, only sub-arrays will be contiguous, not the whole.
    And to hell: even every sub-array can have different dimension!

    The functions are expecting int **, so you have to create an array of int * first, then the sub-arrays in that.
    Many solution used the new[] allocation... but I really hate the idea to using new without delete, so I went with static (aka globals :) ).

  • Custom User Avatar

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

  • Custom User Avatar

    It's not mathematics, it's category theory.

  • Custom User Avatar

    Yes, that's the only ugly part is this kata, which requires some ugly hacks to make it work.

    Tip: Some stuff doesn't need to be declared (like |x|) to be used. Think about why ;-)

  • Custom User Avatar

    Big hint: Think about what scope having is in ;-)