7 kyu

String to integer conversion

2,056 of 4,481Uraza
Description
Loading description...
Strings
Regular Expressions
Fundamentals
  • Please sign in or sign up to leave a comment.
  • serqiiiio Avatar

    11 should equal 'NaN' 123 should equal 'NaN' there is assertion errors for python

  • ejini战神 Avatar

    CS:

    • No random tests

    • mocha + chai should be used

    • Test.expect should be aborted

  • ejini战神 Avatar

    JS:

    • No random tests

    • mocha + chai should be used

    • Test.expect should be aborted

  • ejini战神 Avatar

    No random tests in Ruby

  • Wei-Ting Yang Avatar

    No random test in Python.

  • user9644768 Avatar

    Ruby 3.0 should be enabled, see this to learn how to do it

  • user4896126 Avatar

    🤮🤮🤮 🤮🤮🤮 🤮🤮🤮

  • trashy_incel Avatar

    (and eventually spaces - including tabs, line feeds... - at both ends)

    Don't you mean possibly ?

  • spik3scarlett Avatar

    I am unable to pass 7th and 8th test in "should return NaN for non-integer strings" (ruby). What's in them?

  • kvkvshka Avatar

    what is 5th test in "should return NaN for non-integer strings"?

  • DJRockstar Avatar

    This comment has been hidden.

  • user7212986 Avatar

    This comment has been hidden.

  • sourcevitor Avatar

    Very good for learning about regex within if

  • Mattt321 Avatar

    Hi, I would like to ask, what is right solution with last test case, I can't get it right even if output is 16.5 (and test case is "16.5") . What am I doing wrong, or what I get wrong from description? : )

  • Ollynov Avatar

    All cases pass except for the following. From my understanding these should indeed return the number, rather than NaN. (because new lines and spaces are OK). Am I missing something??? [ '1', ' ', '1' ] Value is not what was expected [ '1', ' ', '2', ' ', '3' ]

  • GSCVirus Avatar

    When I press the submit button I get an "unknown error" this happens on IE

  • gurbraj Avatar

    It is not clear what is meant by "should parse number starting with properly"

    Shows up when you submit.

  • better1 Avatar

    Once again pass all but one returns 'Value is not what was expected' says I pass 114 with one Failed.

  • better1 Avatar

    Passing all but one test (114 of 115), would be great if i knew what the string was;

  • Valda Avatar

    This comment has been hidden.

  • visortelle Avatar

    This comment has been hidden.

  • ne_xitri Avatar

    This comment has been hidden.

  • KirillTerentiev Avatar

    This comment has been hidden.

  • Thoreact Avatar

    This comment has been hidden.

  • Thoreact Avatar

    This comment has been hidden.

  • OnlyHughMan Avatar

    description shows this: parseInt("10 apples") also returns 10 one of the tests: Test.assert_equals(my_parse_int("5 friends"),"NaN")

    ???????? huh

  • greetingsfromtw Avatar

    This comment has been hidden.

  • greetingsfromtw Avatar

    This comment has been hidden.

  • waisbrot Avatar

    This comment has been hidden.

  • donaldsebleung Avatar

    The Javascript test fixture lacks random tests; remember to keep random tests in mind when making future Kata :)

  • balajiramakrishnan Avatar

    Any idea what this failure "None should equal 0" means ? What's the test case?

  • Tankerxyz Avatar

    1 test not passed -_-

  • jrjames83 Avatar

    This comment has been hidden.

  • Mujaddadi Avatar

    It shold be written in the description that octal numbers will also be consider as NaN since in one of the test it is expected 0x10 to be Nan whereas it is actually a integer.

  • cercatrova Avatar

    My code (python) is throwing up the error: 11 should equal NaN

    I thought it might be that I needed to ensure that the string argument actualy had type 'str' before parsing, but that didn't seem to work. Any ideas? This is for the blind test cases under the heading "should return NaN for non-integer strings." Thanks

    To clarify, my code currently outputs "NaN" for input 11, and 11 for input "11"

  • fenring76 Avatar

    This is a minor issue, but in the python version, it wants "NaN" as a string, not literally nan (which you can return with float('nan'). This should be specified.

  • GiacomoSorbi Avatar

    Translated again into both Python and Ruby; I say in the template to return "NaN" as a string, but let me know if you might appreciate me to update the description a bit :)

  • saurabhgupta050890 Avatar

    Description doesn't makes its clear for getting NaN in case of '1 2 3'

  • ClayCooperLA Avatar

    it wasn't clear about all the tests that would be ran. I passed the examples but kept failing on one actual test, and I have no idea what it was testing for.

  • EARnagram Avatar

    I passed the challenge by beating two of the most difficult test cases - if you add a few more letters/add more strange characters to the NaN test case, I think that would prevent people from simply beating the test case and coming up with the desired answer.

  • ailinalbertoni Avatar

    Is not clear that only numbers with space between them have to be NaN result

  • Unnamed Avatar

    CoffeeScript translation published.

  • Unnamed Avatar

    This comment has been hidden.

  • Unnamed Avatar

    Is a "+" or "-" allowed before a number? Whatever the answer is, a test like "+1" would fail some solutions.

  • rderijk Avatar

    It was not directly clear for me that floats need to be returned as NaN. Only after the provided test with a float failed I noticed that I need to return NaN.

  • wthit56 Avatar

    There's a typo in the example test fixture, saying IsNaN instead of isNaN, which produces an error.