7 kyu

Filter the number

9,887 of 18,952matt c
Description
Loading description...
Strings
Fundamentals
  • Please sign in or sign up to leave a comment.
  • hobovsky Avatar

    D translation moved from duplicate kata Get number from string.

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • RileyHunter Avatar

    Pursuant to this issue:

    https://www.codewars.com/kata/55b051fac50a3292a9000025/discuss#64d41c95c734e70031455390

    I've published a fork which replaces the (frankly ridiculous) JS random test generator with one which does not generate test cases greater than Number.MAX_SAFE_INTEGER. While requiring users to use BigInt to correctly handle larger inputs would be better overall and more in line with other languages, doing so would invalidate the vast majority of existing JS solutions so I've chosen not to.

    https://www.codewars.com/kumite/64d435116fad180037ece9d4?sel=64d435116fad180037ece9d4

    Would appreciate review/feedback.

  • mykalimba Avatar

    2023 here. Can not get a JavaScript solution to pass the random test(s). I suspect that the random test case generator is creating test cases that can not be converted to values within the normal JS integer (Number) ranges. Example response: Just return the numbers: expected 60908777950325700000 to equal 60908777950325694000. Number.MAX_SAFE_INTEGER is 9007199254740991, so the test case is expecting a value that can't be contained in a variable of Number type. I tried throwing BigInt into the mix, but that didn't solve this issue.

  • derrickfdavis Avatar

    In Java I get a failed test for random
    input string : 42ipio1262znstzbhi852389369152sbxc5 my ans : 4212628523893691525 expected ans "4212628523893691525" How is that wrong?

  • hobovsky Avatar

    This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/154.
    Please join the discussion to help us identify duplicate kata and retire them.

  • heretoshleigh Avatar

    In JavaScript, I think the function name should be in camel case, not pascal case, no?

  • akar-0 Avatar

    This comment has been hidden.

  • Hohnik Avatar

    You have to return a long ... that should have been mentioned.

  • rimbold1 Avatar

    This comment has been hidden.

  • Dess1996 Avatar

    I solved this kata by 3 ways:) Thank you

  • trashy_incel Avatar

    the description should mention that the number wont be signed

  • user9644768 Avatar

    Ruby 3.0 should be enabled.

  • clcraig Avatar

    Java, C, C++, and NASM translations. Please review.

  • FArekkusu Avatar

    Python 3 should be enabled.

  • shwen4477 Avatar

    How can you do it guys???!!!

  • dpsumner1289 Avatar

    Hi! I can't seem to see why this isn't working. Any clues?

    var FilterString = function(value) {
      var newarr = value.split("");
      for(var i = 0; i < newarr.length; i++){
        var arr = [];
        if (Number(newarr[i]) !== "NaN") {
          arr.push(newarr[i]);    
        }
      }
      return Number(arr);
    }
    

    Thanks in advance!

  • microslayer Avatar

    This comment has been hidden.

  • kingdraconovich Avatar

    This comment has been hidden.

  • aleybal Avatar

    This comment has been hidden.

  • aleybal Avatar

    This Kata will not work for JS with the current test cases: The max safe int is 2^52 or: 9007199254740991 Several test cases run well over that. This Kata does not accept stringoutputs and does not correctly test its own input for JavaScript. Please fix test cases for JS; even the testing program itself is broken, see below.


    Running a test to print out the input value and the output the automated test expects from us we get: Input: ae410d57182d3cb7cf41bbde0fd658f2 Output tested for: 41057182374106584 Despite the fact that all of us can clearly see it should be: 41057182374106582

    Another, more obvious test: Input Vale: db8d1b5149a0371b2b603095d969c1ac Just return the numbers - Expected: 815149037126031000000

    Despite that it should clearly be 815149037126030959691

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

  • hedgehoggrandpa Avatar

    tests don't pass (Python):

    File "", line 8 Test.describe('Fixed Tests') ^ SyntaxError: invalid syntax

  • GiacomoSorbi Avatar

    Translated it into both Ruby and Python, if you want to accept them :)

    A small note: you didn't specify how to behave for strings with no numbers, so I assumed each string must have at least a number; let me know if you thought otherwise and I'll fix it.

    Also, nice testing code you created for the JS version :)!

  • arifhp86 Avatar

    This comment has been hidden.