Ad
  • Custom User Avatar

    Apparently the solution is "keep attempting until the server decides to run your code 1ms faster."
    Maybe I could have gotten a little more speed by using bitshifts instead of division, but I doubt that would make the difference... If that even applies in something as high level as JS.

  • Custom User Avatar

    Fixed.

  • Custom User Avatar

    C translation (author gone)

  • Custom User Avatar

    Oh so I checked and it seems that my edits are not the reason for the error. But it needs to be fixed anyway, I will take care of this.

  • Custom User Avatar

    Oh that's because I removed one character from the alphabet and didnt adjust the sampling function. I will fix this.

    Sorry for the problem.

  • Custom User Avatar

    (OP is talking about JavaScript)
    I can confirm the issue, there is an off-by-one error in the RNG:

    let characters = "abcdefghijklmnopqrstuvwqyzABCDEFGHIJKLAMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+={}[]|\:;?/>.<,)";
    // characters.length === 91
    ...
    random += characters[Math.round(Math.random() * 91)]
    // worst-case scenario: random += characters[91] i.e. undefined
    
  • 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

  • Custom User Avatar

    This is my fault. I forgot that parseInt takes a second parameter which completely changes the behavior. It should be fixed now.

  • 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

  • Custom User Avatar

    A'ight, this kata has me thrown for a loop. There are some tests that appear that yield one result on the master test, but seem as though they should fail the problem as described. It seems to come down to how Array.prototype.some behaves when handed parseInt?

    For example, one generated test:

    seq = [
    'JDQIAXYXUNBLWRAJSFXT',
    'D',
    'WCPXZDEGMLCRZ',
    'UYJMHZ',
    'XBIHTBFUBBNZLOXRGFFABJKJFPI',
    'TCNIIHVBFLOVXYG',
    'PNPOTCZUPVFVWGTL',
    'Z',
    'XGINIHEGSOEYMRASCEKRZ',
    '',
    '',
    'JDMJVCRJUGMXWN',
    'PMIJJEJKMIBB',
    'FXU',
    'PYPSHQLTROEUN',
    'KICOX',
    'GERISTWQWDGAFERQIIFXVGJ',
    'YWLJCSNAMZGLOXJLNLGHKVNDTEPY',
    'CQLIUPVRSMVTHQSCJJC',
    'XWBQHOSFAFI',
    'FA',
    'BIMKRIOHZCAG',
    'BMDBPDDHONJOAOVUIWHGFDO',
    'CMWFHNYFQQNWPBNNKSCDFDIRB',
    'AGCWIZYRHQCGQPYEGKIES',
    'TRAGUVGYJ',
    'LSJSLBF',
    'BLIQUGELZDQ',
    'AHOORDONNUQBYDDVI',
    'EDU',
    'SVALRMLJGV',
    'DFFLUMEJHIP',
    'YNUUEJN',
    'CNTYKGQRFWLHTB',
    'YO',
    'EFMVKHWLVMEJSZWW',
    'QKDWFTLQFBBCDUUAOIAV',
    'XBWSBFBAZIPPBWBJYTT',
    '',
    'SONQBBCCBBDMGD',
    'PYNLTD',
    'JUTSGTDJUZPFNCXJHICNWMH',
    '',
    'DC',
    'CUZST',
    'KSGPQILMASPYLDRSDJNCAI',
    'SKPYFUXQYLUQFDZYE',
    'LOZQUNTQMSGRR',
    'TBWPDTYBMLJSMVFPWNKNAQHMKUA',
    'AENVOGUUJNJRYHSQVFZ',
    'GIJRVCRRHGNDQWTXOGCA',
    'YZNO',
    'SCPMMBOFEFTIRAAKNBSH',
    'CPQNNP'
    ]

    pred = parseInt

    And the output of using this sequence is:

    seq.every(parseInt) == false
    seq.some(parseInt) == true
    seq.some(x=>parseInt(x)) == false

    So a solution that runs seq.some(pred) will get a different result than one that runs seq.some(x=>pred(x)) or something to the effect of

    let trueSeen = false;

    for(const x of seq) if(pred(x)) trueSeen=true;

    return trueSeen

    will also return false.

    Just at a glance, I'd expect false (every one of those strings yields NaN), yet the built in tools yield true.
    Can anyone tell me what I'm missing?

  • Custom User Avatar

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

  • Custom User Avatar

    hahaha, bro took the role of god to a whole new level

  • Custom User Avatar

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