Ad
  • Default User Avatar

    In swift, the example test give away the solution

  • Default User Avatar
  • Default User Avatar

    This kata states Every number in the sequence after the first index will be greater than the previous and that there will be no duplicates.

    The data generated in random tests does not comply with that (have duplicates and no order)

    [90, 91, 92, 0, 94, 95, 96, 0, 98, 0, 0, 101, 102, 103, 104, 105, 106, 107, 108, 109, 0, 0, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 0, 123, 124, 0, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 0, 138, 139, 0, 141, 142, 143, 0, 145, 0, 147, 148, 149, 0, 151, 0, 153, 154, 0, 156, 157, 0, 159, 0, 161, 0, 0, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 0, 175, 176, 177, 0, 179, 180, 181, 182, 183, 184, 185, 0, 187, 188, 189, 190, 0, 192, 193, 194, 195, 196, 197, 198, 199, 200, 0, 202, 203, 204, 0, 206, 207, 208, 0, 210, 211, 212, 213, 214, 0, 216, 0, 218, 0, 220, 221, 222, 223, 224, 225, 0, 227, 228, 229, 230, 231, 0, 0, 234, 235, 0, 237, 238, 239, 240, 241, 0, 243, 244, 245, 0, 0, 0, 249, 250, 251, 252, 253, 254, 255, 256, 257, 0, 0, 260, 0, 262, 263, 264, 0, 0, 267, 0, 0, 270, 271, 272, 0, 0, 0, 276, 277, 278, 279, 280, 0, 282, 283, 284, 0, 286, 0, 0, 0, 290, 291, 292, 293, 0, 0, 0, 297, 0, 299, 300, 301, 302, 303, 304, 305, 0, 307, 0, 309, 310, 311, 312, 313, 314, 315, 0, 317, 0, 319, 0, 0, 322, 0, 324, 325, 0, 0, 328, 0, 0, 331, 332, 333, 334, 335, 336, 337, 338, 0, 340, 0, 342, 343, 0, 0, 346, 347, 0, 349, 0, 351, 0, 0, 354, 355, 356, 0, 0, 0, 0, 361, 362, 363, 364, 365, 366, 0, 368, 0, 0, 371, 372, 0, 374, 375, 376, 377, 378, 379, 0, 0, 382, 383, 384, 385, 386, 387, 0, 389, 0, 0, 392]

  • Default User Avatar

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

  • Custom User Avatar

    Indeed, but declaring vars in the scope it is used prevents bugs and improves readability.

  • Custom User Avatar

    In java, when you divide 2 numbers with the same type, the result has the same type that the operands have.
    5 and 9 are ints, so java converts the result of 5/9 (0.5555555556) to an int using half down rounding, resulting in 0.
    But, since 5.0 and 9.0 are both floats, the result is also a float by the Java rules, so it does no conversion and the result is 0.555555556.