Ad
  • Custom User Avatar

    the error comes from your code: wrong index calculation, so you access invalid memory

    char *pos = (char*)(pins + (sizeof(char *) * num_pins) + ((cur_idx) * len));
    

    should be:

    char *pos = (char*)pins + sizeof(char *) * num_pins + cur_idx * (len + 1);
    

    (you forgot the + 1 for the nul terminator, and you got the pointer arithmetic wrong: ptr + n will add n * sizeof *ptr to ptr, so you were going out-of-bounds of pins. The cast to char * needs to happen right away, in order to have byte-level memory access.)

  • Custom User Avatar

    I do understand that, but 658 is one of the variations and that has the same pattern as 325. 6 and 8 are adjacent diagonally, but that is a valid solution

  • Custom User Avatar

    it is possible that each of the digits he saw could actually be another adjacent digit (horizontally or vertically, but not diagonally).

    See the keypad again, 3 and 5 are adjacent, but diagonally.

  • Custom User Avatar

    Hello, just trying to understand the variations.
    For this test example: "369": ["339","366","399","658","636","258","268","669","668","266","369","398","256","296","259","368","638","396","238","356","659","639","666","359","336","299","338","696","269","358","656","698","699","298","236","239"], how come 222 and 333 are not variations? Or 555? Or 325? But I see that 666 is there?

  • Custom User Avatar

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

  • Custom User Avatar

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