Ad
  • Default User Avatar

    I think this issue is still there.

  • Default User Avatar

    Thx. I got it wrong.

  • Custom User Avatar

    Maybe you miss out the following description:

    choosing a single number and moving it some number of positions to the left.

    You can't move number to the right.

  • Default User Avatar

    Your example is too long, I tried your solution and found a way shorter example.
    Given a = [3, 2, 1] and b = [2, 1, 3]. Your solution returns 1, but obviously the correct answer is 2.

  • Default User Avatar

    For instance, these two arrays:
    a = [323, 160, 477, 470, 471, 436, 105, 136, 253, 248, 109, 259, 463, 488, 297, 421, 293, 180, 276, 388, 75, 345, 358, 79, 372, 373, 37, 90, 152, 389, 486, 387, 439, 77, 497, 44, 357, 148, 189, 498, 70, 250, 296, 121, 489, 400, 464, 351, 155, 426, 191, 257, 269, 80, 244, 278, 29, 161, 198, 476, 419, 335, 183, 149, 122, 294, 34, 242, 313, 102, 89, 59, 429, 144, 135, 433, 336, 328, 206, 13, 182, 212, 41, 128, 103, 87, 370, 71, 48, 172, 139, 431, 234, 61, 137, 309, 200, 413, 246, 320, 66, 11, 462, 273, 21, 2, 342, 188, 332, 58, 314, 165, 280, 344, 134, 167, 49, 460, 228, 495, 169, 281, 322, 72, 190, 158, 316, 106, 260, 288, 284, 241, 138, 292, 60, 443, 386, 299, 334, 467, 418, 179, 490, 303, 348, 97, 496, 40, 318, 207, 209, 52, 484, 120, 145, 361, 319, 219, 104, 157, 5, 325, 222, 417, 304, 442, 181, 78, 65, 68, 331, 133, 229, 450, 125, 290, 405, 245, 454, 363, 47, 35, 25, 254, 430, 472, 324, 256, 42, 291, 369, 140, 159, 92, 263, 397, 177, 194, 132, 45, 449, 33, 184, 225, 93, 475, 249, 205, 452, 438, 56, 86, 15, 367, 311, 482, 265, 46, 116, 108, 107, 131, 162, 82, 32, 51, 410, 465, 83, 378, 266, 399, 339, 483, 434, 368, 186, 402, 377, 289, 326, 143, 412, 337, 287, 201, 407, 111, 445, 31, 166, 17, 171, 374, 385, 20, 428, 214, 98, 283, 315, 10, 14, 84, 398, 308, 175, 192, 99, 453, 54, 147, 473, 251, 88, 298, 302, 415, 481, 243, 12, 233, 235, 220, 275, 110, 424, 359, 440, 435, 437, 238, 468, 193, 141, 239, 223, 118, 62, 271, 285, 392, 279, 383, 493, 73, 94, 447, 4, 362, 176, 154, 164, 216, 353, 395, 23, 330, 277, 282, 213, 466, 403, 340, 307, 310, 352, 211, 126, 204, 1, 264, 346, 456, 329, 355, 7, 270, 187, 237, 381, 360, 16, 170, 404, 350, 117, 341, 401, 142, 91, 422, 113, 391, 317, 173, 3, 210, 327, 338, 494, 28, 185, 255, 153, 203, 36, 168, 39, 146, 130, 9, 57, 356, 305, 365, 487, 115, 448, 218, 408, 380, 457, 343, 425, 217, 485, 444, 50, 202, 227, 416, 163, 394, 43, 151, 26, 406, 384, 492, 6, 226, 150, 306, 321, 236, 224, 195, 379, 272, 215, 258, 67, 199, 333, 197, 114, 375, 349, 364, 22, 18, 390, 38, 420, 8, 74, 499, 295, 409, 123, 30, 85, 53, 64, 459, 432, 300, 376, 455, 63, 81, 119, 469, 221, 19, 366, 411, 441, 156, 100, 76, 261, 423, 230, 55, 232, 208, 312, 491, 446, 262, 178, 382, 124, 301, 24, 231, 414, 127, 458, 101, 267, 474, 451, 240, 354, 479, 252, 286, 371, 427, 129, 274, 196, 500, 268, 112, 393, 461, 347, 478, 69, 96, 174, 247, 480, 95, 396, 27]

    b = [318, 497, 77, 177, 35, 58, 92, 347, 185, 164, 406, 337, 136, 105, 480, 175, 426, 68, 271, 140, 27, 147, 458, 371, 304, 202, 176, 469, 218, 325, 411, 432, 456, 67, 100, 450, 130, 103, 60, 228, 322, 169, 340, 448, 101, 328, 281, 163, 490, 311, 370, 489, 300, 439, 25, 7, 10, 148, 435, 76, 386, 459, 317, 390, 124, 321, 102, 69, 85, 226, 494, 383, 326, 420, 306, 482, 361, 151, 305, 9, 2, 44, 310, 465, 41, 50, 493, 466, 299, 135, 495, 380, 32, 89, 499, 172, 316, 170, 372, 62, 363, 332, 395, 237, 424, 479, 149, 29, 249, 242, 399, 266, 128, 421, 391, 412, 384, 488, 473, 8, 368, 183, 455, 396, 112, 433, 227, 122, 111, 314, 413, 72, 353, 366, 61, 288, 264, 374, 178, 11, 403, 93, 341, 481, 234, 296, 84, 205, 431, 356, 334, 247, 339, 198, 194, 20, 409, 291, 131, 96, 369, 295, 437, 487, 389, 354, 484, 483, 187, 330, 53, 208, 119, 440, 141, 258, 430, 99, 17, 429, 193, 132, 59, 467, 80, 313, 87, 294, 46, 241, 358, 398, 364, 315, 167, 292, 416, 323, 203, 142, 4, 320, 114, 265, 276, 81, 123, 283, 195, 3, 109, 453, 229, 452, 379, 460, 232, 63, 468, 392, 290, 273, 268, 293, 367, 402, 329, 14, 463, 447, 243, 64, 220, 425, 154, 275, 255, 75, 477, 298, 308, 55, 204, 333, 250, 246, 382, 397, 12, 189, 327, 231, 454, 417, 285, 120, 219, 470, 272, 171, 115, 352, 200, 262, 301, 445, 133, 104, 277, 197, 39, 336, 418, 400, 259, 88, 94, 475, 287, 348, 108, 74, 1, 214, 449, 23, 90, 256, 343, 56, 408, 38, 303, 110, 37, 355, 307, 446, 224, 240, 373, 434, 107, 65, 165, 474, 33, 442, 207, 385, 491, 346, 213, 284, 211, 152, 267, 331, 118, 419, 127, 190, 150, 225, 173, 209, 280, 116, 21, 253, 196, 48, 282, 410, 137, 257, 436, 464, 404, 156, 261, 98, 206, 393, 144, 423, 52, 30, 34, 251, 191, 381, 235, 143, 233, 451, 174, 286, 478, 486, 362, 365, 496, 49, 155, 335, 45, 184, 95, 360, 179, 138, 86, 344, 106, 492, 113, 388, 312, 415, 180, 26, 166, 338, 192, 57, 461, 16, 54, 405, 216, 230, 443, 394, 66, 457, 79, 42, 97, 145, 309, 43, 244, 28, 153, 377, 70, 349, 78, 139, 125, 188, 239, 212, 36, 238, 83, 126, 18, 160, 159, 289, 157, 222, 279, 31, 51, 223, 444, 342, 302, 422, 350, 146, 5, 414, 485, 186, 91, 181, 357, 378, 254, 210, 236, 215, 162, 82, 263, 182, 161, 269, 345, 438, 472, 24, 407, 471, 476, 199, 498, 278, 260, 401, 221, 319, 462, 73, 375, 201, 427, 13, 117, 324, 40, 297, 168, 245, 217, 19, 351, 6, 134, 121, 441, 252, 22, 158, 274, 376, 428, 387, 500, 71, 47, 15, 248, 270, 359, 129]

    They have a common subsequence:[105, 439, 148, 102, 89, 172, 332, 314, 72, 288, 334, 484, 430, 132, 452, 367, 402, 14, 243, 220, 275, 285, 94, 23, 213, 211, 381, 360, 113, 338, 28, 153, 36, 146, 485, 236, 215, 199, 375, 19, 441, 252, 274, 500]. len(a) == len(b) == 500 And, the common subsequence's length is 44, not 6.

    So the answer cannot be 494(which the python version says), should be no more than 456.
    Maybe you should check it out.

  • Default User Avatar

    Approved, thanks!

  • Default User Avatar
  • Default User Avatar

    You should add what is the range of all A[i] and B[j].
    In particular when they are numbered from 1 to N.
    More especially when the original kata page gives more information than you.

  • Default User Avatar

    This kata is Python only at the moment I'm writing.
    Given some users already found the correct solution, there is an issue in your solution, not in referee solution.

  • Default User Avatar

    Maybe there's something wrong with the python translation ?
    For every random test, a longer increasing sequence can be found than the answer.

  • Custom User Avatar

    Fixes It(desc, closure()) closure() variable capture which made the can solve 6x6 puzzle tests repeat the same test three or four times.

  • Default User Avatar

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

  • Custom User Avatar

    Also, the way the task is presented, minscore cannot be zero. If nobody votes for a candidate as a first choice, that candidate loses automatically and can be safely discarded. poll[c] will yield 0 for such candidate.

  • Custom User Avatar

    Why? Design an example which this code will fail.

  • Default User Avatar

    Shouldn't pass the minscore == 0 cases.

  • Loading more items...