Ad
  • Custom User Avatar

    When your first solution fails, check the examples for clues as to how the actual problem works. I had to toss this one into a spreadsheet to get a clear idea of how it actually worked. This is no different than every programming project ever.

  • Custom User Avatar

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

  • Custom User Avatar

    OP solved it, closing

  • Custom User Avatar

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

  • Custom User Avatar
    a = 1, b = 2, c = 1, d = 3
    7 = 2 * 3 + 1 * 1
    7 = b * d + a * c
    

    the (a, b), (c, d) of "on the one hand..." are not necessarily the same as the previous a, b, c, d that are used to form n; they are a permutation of it, e.g. b, a, d, c

  • Custom User Avatar

    Timing out is not a kata issue.

  • Custom User Avatar

    No worries, Racket is quite unusual in that regard.

  • Custom User Avatar

    The number 58430 is exact and therefore rational, and the number 58430.0 is inexact which does not guarantee rationality; these are not the same number. 58430.0 could represent some number which is not precisely 58430, differing by some small epsilon. Because you are instructed to return an integer and all integers are rational, you should return the rational (exact) representation.

    In strict terms it is only a coincidence of the underlying encoding that the inexact representation of this number holds precisely the same value as the intended exact representation. There are (rare, quirky) situations where assumptions like this could bite us in the arse.

  • Custom User Avatar

    Sorry there are no errors in the tests. Good luck!