6 kyu

Number , number ... wait LETTER !

892 of 1,742user3879542
Description
Loading description...
Strings
Mathematics
Fundamentals
View
AllIssues8Questions5Suggestions7Show Resolved
  • Please sign in or sign up to leave a comment.
  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • AngelitoVuela Avatar

    This comment has been hidden.

  • piotr201110 Avatar

    Examples : "24z6 1z23 y369 89z 900b" = 900 + 369 - 246 * 123 / 89 = 1414

    "In the case of duplicate alphabet letters, you have to arrange them according to the number that appeared first in the input string."

    Expected order 24z6 1z23 89z I lost more time than needed because I was ordering it correctly which was 1z23 24z6 and then 89z

  • raswonders Avatar

    Nice kata overall but this part seem quite ambiguous: Basic math rules do NOT apply, you have to do each computation in exactly this order.

    It would help if you say sth like: ignore operator precedence and evaluate in left to right order.

  • Awesome A.D. Avatar

    Remember to also round the final answer to the nearest integer.

    This is ambiguous (depending on the chosen language, here I'm particularly targeting Python). The description should explicitly state what kind of rounding method to use. E.g. here it just so happens to be (again, in Python) "nearest even integer".

  • silviluliuma Avatar

    I think this kata is not for 6 kyu level. I found it too difficult...

  • Pascal1989 Avatar

    Nice challenge!

  • SirSamiboi Avatar

    Great kata, but way to difficult for a 6 kyu. It should be at least 5 kyu difficulty

  • jarekadamowicz Avatar

    Hi, for JS the issue is with limitation to Node.js v8. It has buggy Array.prototype.sort implementation (as it moves object that should stay in place). Therefore it causes random test fails. Stable sort is available for Node.js since v12 as mendtiond in MDN resource here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort

    So I would suggest to update the Node.js version of this kata, otherwise, rewriting sort method for an array using any reasonable algorithm is a must for JS solution.

  • marjan Avatar

    Please make it possible to do in c++.

  • laurelis24 Avatar

    Very nice kyu Version should be updated. Sorted doesnt work properly.

  • AlcalinoDev Avatar

    Test cases should be upgraded to require total accuracy. My code is usually off by a few decimals from the actual answer, which I 'solved' using the round function, test cases with floating point outputs should be added

  • Cloud Walker Avatar

    This comment has been hidden.

  • Cloud Walker Avatar

    //Language: JavaScript //Testing for '4d13 z44279 93y8 z792 1b54 5b34 2316b8 5290c7 8x84 76z60 b120 414c3' // Output on my computer: 359669281 //ERROR MESSAGE: It should work for random inputs too - Expected: 359669281, instead got: 733591213

    What is Expected is the same as the output on my computer. This error message is confusing me, how can my output be what is expected, yet still be wrong? I will post my code next.

  • Chrono79 Avatar

    Node v18 should be enabled.

  • saaseessfr12 Avatar

    You have the error "24z6 1z23 y369 89z 900b" that is 900+369-123*246/89 = 3168, and the test is waiting for the answer 1414

  • balu9 Avatar

    This should be a 4 or 5 kyu, not 6kyu!

  • gkucmierz Avatar

    So default sorting alghoritm in node v8.1.3 isn't stable?

  • alex.kiseleff Avatar

    An interesting map, but your tests are not working correctly. Writes: one was expected, and the other was received, but in all cases I get what was expected on my computer. It is unclear where the incorrect received data comes from. Sadly...

  • Maukan Avatar

    Awesome kata, I really enjoyed this one. Thank you!

  • user9644768 Avatar

    Ruby 3.0 should be enabled.

  • injectionsuccesfully Avatar

    I sent my solution but it didn’t work, everything works on my computer, checked all cases

  • scodek Avatar

    Hello, My Javascript code is failing for some random tests by the test set up here. However, this this giving correct answer in my personal compueter sublime editor. I am using eval function and for rounding to nearest integer I using Math.round().

    Ex: 586c5 9x7711 885y8 761z3 3b896 87b7 6x98 d86475 100a0 9327a1 9206z3 Codewar showing : It should work for random inputs too - Expected: -84271, instead got: -80447 my own test environment showing : Result = -84271

    Is there any idea what am I missing ?

    Sort Update : I was using "localeCompare" function for string compare and now changed to string.prototype.charCodeAt() function for the comparision. BUt nothing changed in codewar. I am still failing here but passing in my own system.

  • hksong Avatar

    Many people are using the built in Array.prototype.sort method. It is not necessarily stable, but the answer requires stability. Adding a couple of larger arrays in the test cases will probably cause some bad sorts.

  • perumalcsbe Avatar

    (javascript) random tests are failing. looks like test case has issue?

    for e.g. Testing for '4d84 c44569 496w9 871d9 90a5 870w9 71y7 68d825 c1486' It should work for random inputs too - Expected: 805283, instead got: 805285

    4d84 c44569 496w9 871d9 90a5 870w9 71y7 68d825 c1486 => 905 + 44569 - 1486 * 484 / 8719 + 68825 - 4969 * 8709 / 717

    each steps

    905 + 44569 = 45474 45474 - 1486 = 43988 43988 * 484 = 21290192 21290192 / 8719 = 2442 2442 + 68825 = 71267 71267 - 4969 = 66298 66298 * 8709 = 577389282 577389282 / 717 = 805285

  • soursock Avatar

    I am a little stuck on this. i got most of the code to work, but when i get to the test random cases i get this a lot

    Testing for '49d957 3300x4 5d76 46z895 134d4 92b8 670b14 97x7 28c8 a3559'
    ✘ It should work for random inputs too - Expected: 8774, instead got: 8775

    Testing for 'y245 30x5 80d7 4c12 809a6 7x28 34d791 42c4 4y14 19w5 4w92'
    ✘ It should work for random inputs too - Expected: -215, instead got: -214

    my code keeps being off by 1 number for a couple of the random test cases. right now i hover at about Passed: 33 Failed: 12

    any ideas why this happens?

  • KSA Avatar

    This comment has been hidden.

  • yavulan Avatar

    "In the case of duplicate alphabet letters, you have to arrange them according to the number that appeared first in the input string" - confused me. Blocks like "22y6" not a numbers, so that sounds like subsorting by first number occurance in block is needed.

  • myjinxin2015 Avatar

    @GiacomoSorbi:

    Can you explain what the order of the string should be?

    '22y6 a96 8b y8 d9 29y 6d7 y44 6z b4 393d x500'
    

    my order is:

    96, 8, 4, 9, 67, 393, 500, 226, 8, 29, 44, 6 
    

    I got an error:

    Expected: 4121755, instead got: -15950  
    

    My calculations:

    96+8-4*9/67+393-500*226/8+29-44*6 
    

    Is there a problem with my calculations?

  • GiacomoSorbi Avatar

    Ruby and JS translation submitted (both composed from Stansted Airport to two cities in Tuscany :D), if you want to approve them.

    Also, as usual keep me posted about your next katas!

  • smile67 Avatar

    Hi, the order of the sorting is not clear to me, for example your description of "24z6 1z23 y369 89z 900b = 900 + 369 - 246 * 123 / 89 = 1414"... Why not "900 + 369 - 123 * 246 / 89"? Ok, "b" < "y", so 900 and 369 is clear, but for same "z" for example str(123) is smaller than str(234) is smaller than str(89)? So what's the second step for the order (numbers couldn't be, because the order would be 89, 123, 246)?

  • zebulan Avatar

    I made a couple changes to your description:

    • Fixed spelling mistakes (hopefully all of them!)
    • Minor rewrite of a few parts

    I made a slight change to your solution to make this kata work for both versions of Python (2 & 3). Python division is slightly different in each version.

    • In Python 3, / uses true division and // uses floor division
    • In Python 2, / uses floor division. To get true division one of the numbers must be a float (or you can try: from __future__ import division)

    To get around that issue where you used /, I simply changed the second value from int() -> float(). Now your tests pass for both versions of Python and each user can pick whichever version they prefer!

    I didn't want to do a total rewrite of your solution code so I just made that tiny change. There are a few things that could be written differently to clean it up a bit and conform to PEP8. I thought it might be better to fork your solution to show you a few improvements instead.

  • zebulan Avatar

    This comment has been hidden.