6 kyu
Roman Numerals Encoder
16,026 of 56,641jhoffner
Loading description...
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
There is an issue in Haskell's sample test (L16)
when you report an issue, you have to give more details as to what the issue is.
MDCCCLXXXIX
is the correct translation for1889
, so i'm closing this. feel free to provide more details. also, it looks like you solved the kata, but did not come back to close your issue, please don't do thatmismatched message & test, it seems
ah sorry, I did not notice. fixed. (that's a strong case against hardcoding the assertion messages...)
This comment has been hidden.
Fixed for Typescript.
a new issue should be opened if the problem exists in other languages
This kata is duplicated. See:
https://www.codewars.com/kata/51b66044bce5799a7f000003
it was extremely difficult for a haskell beginner >:(, did it tho.
My solutiom is what I consider to be the most hilarious code I ever wrote. It is 2 years old. And the funniest part about it, is that it gets the job done flawlessly...
this test makes me realize i'm so dumb af
Test Results: Kata Fixed_Test Random_Test Expected: equal to "MDCCXL" Actual: "MDCCХL" why didn't the test pass?
No idea. Your code is most probably wrong.
To know exactly, we would have to see your code.
Skill issue /j
C fork
Merged.
With Ruby, MRI 3.0.0, all random tests are failing with the error
All basic tests are passing.
This comment has been hidden.
Should be fixed.
Thank you!
My javascript solution is working in VS Code, also works in browser console. (First I used split method to break roman numerals into an array of strings).
When clicking 'Test' here I get this error: "TypeError: roman.split is not a function"
Looks like you figured it out. What was the issue?
really nicely calibrated
This comment has been hidden.
Compiler is not working properly when writing in Swift.
I just managed to create a solution in swift, ranked me up to
6 kyu
in that language (hooray). Doesn't seem to be any problem, though.Your code runs into a
fatalError
because of its own issues, and you can read all about them in the error message feedback.Это была очень интересная задача, которую я смог решить!
Currently getting a pass on all normal Ruby tests, but keep failing random random tests. I idependently test the failed random tests and get the currect response every time, and when I run again to submit, I fail between 1-6 other random tests (passing the ones that failed on the previous run). Could this be an issue with the current tests in Ruby?
/runner/frameworks/ruby/cw-2.rb:60:in
block in describe': Expected: "MCMXCIII", instead got: "MXMIII" (Test::Error) from /runner/frameworks/ruby/cw-2.rb:46:in
measure' from /runner/frameworks/ruby/cw-2.rb:51:indescribe' from /runner/frameworks/ruby/cw-2.rb:202:in
describe' from main.rb:47:in `"MXMIII" is not a valid Roman number. There is a bug in your code.
I would definitely agree. The concern I am having is that I will run the code again and pass that one instance, but fail a completely random other one. Any pointers on this?
If a random test fails, and you can trace back the input that resulted in it, paste that test case into sample test cases. Makes it simpler to debug, as you don't have to run the full suite.
Traceback (most recent call last): File "/workspace/default/tests.py", line 1, in from solution import solution ImportError: cannot import name 'solution' from 'solution' (/workspace/default/solution.py) What should I do with this error?
Don't change the function's name, change it back to solution.
I created a solution that is working in another site that lets me test (https://pythontutor.com/visualize.html#mode=edit) a really useful website that lets you see what your code is doing step by step.
But I'm getting this reference error and don't know what it means. Usually it will say "expected 3 to be III" or something like that so I can find and resolve the issue, but I've not clue what is happening here. Help would be appreciated.
ReferenceError: solution is not defined at Context. (test.js:25:12) at process.processImmediate (node:internal/timers:471:21)
See the initial code for javascript:
You changed the name of the function and that's why the tests don't find it.
Thank you! Appreciate you helping me. :D
Nasm translation
There seems to be some issue with the test cases. I tested my solution earlier and it passed all test cases successfully. But I didn't submit it because I wanted to improve my code. I ended up submitting the same solution (after a couple of day or a week maybe) because I wasn't able to improve my code. But that exact solution is not passing some test cases now.
I'm using JavaScript by the way.
Not a kata issue, the code I can see from you is for this other kata: https://www.codewars.com/kata/51b66044bce5799a7f000003
Here you only need to encode and the function's name is
solution
.Javascript tests are fine.
thanks for clearing my confustion :)
Is this 6kuy kata?
Definitely. As long as you know where to start.
I don't think its a 6kyu kata, as its very easy to get stuck. Unless you know the 'trick' to consider '4' and '9' numbers as roman number symbols as well. Yes, when you think of that, it becomes a simple implementation. But if you don't its very easy to go down a rabbit hole of counting repeats, borrowing, post processing, ...
I'm doing it in JavaScript. It works as expected outside the page, but when I try to pass it here I get a message like this:
Any ideas? Thanks.
Read this: https://docs.codewars.com/training/troubleshooting/#works-but-no
I have same problem
@PavelChernikovUA no, you don't. Your problem is with returning
console.log(result)
, removeconsole.log
and simply return the result.@pabloparma1982 don't use global vars, they keep their value between tests. It's there in the link I gave you.
Seems like that there is an issue with the testcases?
Like what? Which language?
No answer after a month, closing. Open another one stating the language and what the problem is.
As a suggestion, I recommend added the other cases, in between 1-1000, to the variable you set up to store the roman numeral symbol and its value. (for example, add 4, 9, 40, etc.)
Once I did this, it became a lot easier to code out what I wanted to do so I did not have to have a lot of non-sense code trying to replace symbols.
Hello everyone,
I'm coding on python and I noticed a big mistake in the kata. I was trying to make the kata and I was pretty confident about how my code would work.
After veryfing my code in the website, it says that my code is wrong and give me some numbers that my code return and what they should return instead.
However, I can tell that the verifying code is wrong because it says that we can't have 3 consecutive letters that are the same which is true.
But when the veryfing code tell me that 89 that is 'XXCIX' is supposed to be 'LXXXIX' we easily see that the mistake in the verifying code is about how they write the number 8, 80 or 800.
Sorry for my bad english and I hope it will help some people.
89 is not 'XXCIX', that's not a valid roman numeral. Not a kata issue.
Hey @Mouthieu and first of all welcome to Codewars, and happy new year!
To answer your question(s) - and I would like to clarify that I am not an expert in Roman numerals - the kata does not say "we can't have 3 consecutive letters", it in fact says "there can't be more than 3 identical symbols".
From memory, 13 = XIII and 8 = VIII so it seems that in real Roman numerals this rule is indeed respected, and that you can indeed have up to 3 (but not 4,5...) consecutive identical symbols.
I note also by googling "89 in Roman numerals" that the results all seem to give
LXXXIX
as the correct answer, so it seems the kata algorithm is OK.-edit beaten by @Chrono79 because I type so much :<
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Done.
Am I just in the unknown or do all these solution cheat the test system of the kata?
nope just read in wikipedia or you can watch in youtube an easy solution
Don't cheat or else you will get banned sooner or later. Maybe starting off from white katas (8 and 7kyus) will be a wiser approach. Also, read this Happy coding !!! ^^
Isn't this a duplicate of this kata by the same author as well?
Update to Scala 3
.
Although, my code is longer than the others, it passed.
Happy coding!
In javascript parameter is not correct.
Please elaborate.
This comment has been hidden.
same
This comment has been hidden.
This comment has been hidden.
Please read this: https://docs.codewars.com/training/troubleshooting/#post-discourse
Not a kata issue, that's your code's problem, you're using global vars that carry values across different tests. Read this too: https://docs.codewars.com/training/troubleshooting/#works-but-no
This comment has been hidden.
Really liked this Kata. Also I really liked to see how different the solutions are. It was a nice challange. Thanks!
This comment has been hidden.
Не является вопросом + просьба воздержаться от публикации готовых решений в комментариях, тем более что они всё равно помечаются как спойлеры.
Not a question + please don't publish solution in the comments, especially when they're marked as spoilers.
In Swift, can you use extensions? I have an extension on Int in my code. It complies correctly in Xcode, but not on Codewars. Thanks!
This comment has been hidden.
All those tests are fine. Why do you say they're wrong?
I say there wrong because solutions the test want don't follow Roman Numerals structure. XCI, CMLXXXIV and MCMLXXXIX, The apparent solutions are in the same order as I listed them in my first comment.
You can see in the kata's description: 90 = XC, so 91 = XCI, and all the others are also fine.
My JavaScript solution works correctly on my system, when pasting it in here it breaks?
Don't use global vars, they keep their value between tests.
COBOL translation.
Approved by someone
Hello, please add some numbers like 5005, 6789, 7963, 8143 to the test. Now you can pass the test even with the output 5005→MV but the correct one is 5005→MMMMMV
Roman numerals are said to not go to 4000 or above. Large numbers used additional elements of notation.
This comment has been hidden.
Not a kata issue, you're using a global var there, read this: https://docs.codewars.com/training/troubleshooting/#works-but-no
Omg. thanks! Still such a noob... :)
This comment has been hidden.
A problem with your code is not a kata issue, please read this: https://docs.codewars.com/training/troubleshooting/. Try your code in devc++ with the input your code is failing here: 5, 1000, etc.
But i have been tried 5 , 1000 and also 2091 all returns correct answer from devc++ but here not. Even i couln't find why it returns false result here.
Logs in random test in Haskell are not informative enough:
Falsified (after 17 tests): 2488
Hey,
There is a similar kata to this one, which is ranked 4 kyu, which asks for a harder task to convert back from the roman to the arabic dates. It might be worth adding link to it. Thanks.
how to deal with those questions,which it seems so many forks need to write,i may write 10 if to deal with the case,when i see that bro finish it with a great 语句,that impressed me.
I don't get your question, did you mean to ask on how to handle cases with multiple if statements? 我不了解你在说啥,你是在指怎样应对多个判断式的特殊条件吗?
yesyes,multiple if statements,how to handle cases,
You can always google on
if statement
syntaxes and what language are you talking about?about c,the if statement has too many judgments, is complicated and easy to make mistakest,sorry,but i'm not talking about syntaxes.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
I am trying the F# version. When I click on "Test", everything passes (green). But when I click on "Attempt" I'm getting a couple of warnings about wrong indentation, and an error: /home/codewarrior/program.fsx(42,17): error FS0039: The value or constructor 'Dictionary' is not defined. Maybe you want one of the following: dict
I am not using a Dictionary in my code. FYI
This comment has been hidden.
Julia translation
This comment has been hidden.
Your 'buff' is declared way outside any function, and is going to have incorrect results when you run the function many times (move it inside solution). Also, it's allocated on stack, but it should be done on the heap (with some alloc function).
thanks :o)
Why I cannot execute
"M".repeat(5)
?You can't repeat a letter more than 3 time in roman numerals
What do we return if an integer is not in [1,3999] range?
There should be no such cases.
Then this should be specified in the instructions
Done.
This comment has been hidden.
Kotlin translation waiting for approval
Approved
The numeral cannot be repeated 3 times. What happens if we ever get to the 10,000 years? Current solution returns "MMMMMMMMMM" for the year 10,000.
What if we don't?
Do you want Y10K? This is how we get Y10K
For Java, the compiler seems to be skipping some operations. I cannot get my functions to work in this environment, but I get the correct answers in an Online Java Compiler and also in Eclipse.
???
You must have some constraint for a segment of code which you've not anticipated, you can post your code here with markdown formatting and spoiler flag, and perhaps give it little bit of readbility.
Same. Wasted an hour+ on this only to find that my solution works in other compilers, but isn't accepted here. The end result is that I return a string "IV" (according to Online Java Compiler) which the system compares to "I[]V", but my "IV" string is interpreted as being "I[I]V" for some reason.
@CheTranqui I get the feeling you simply didn't carry out the same test when you tried it locally. You're probably returning "IIV" which has an extra "I" in it which is what you're being shown. Find out what the input was and then you can get to figuring out what happened. If your code is failing on the example tests, then you can run that exact code locally to reproduce it, or otherwise debug using printing in codewars' environment. Compilers being different enough to affect your result is ... unlikely. This is a really poor explanation and not one you should be so quick to adopt. A possibility, perhaps, but without having actually shown it to be so? No, probably not. The big unstable factor here is yourself, this is the the explanation that you should always be considering because it's always a very likely one. A decent way to rule out that factor is to run the exact same code on both platform - including the exact same tests. If on the other hand you have one set of tests here, and you have your own different tests over there ... not great.
The brackets you see are JUnit's helpful (yeah, right) way of pointing you out the diff in expected and actual values. Something like
expected |[]V but got I[I]V
means that your answer differs from expected one having one additionalI
on the second position.It's not a fault of the compiler, it's not a fault of Codewars. Your solution is probably incorrect. The fact it works in other compilers despite of being incorrect is not surprising, this is what often happens when tests are also recreated incorrectly :)
This comment has been hidden.
What language?
C.
I'm having the same issue. I printf my array prior to returning it to the test and the output IS the ëxpected. And, the error is intermittent.
If it's indeed C, then my bet is on some UB caused by invalid memory management. It's difficult to tell without seeing the code though. The buffer looks valid-ish before the return, but causes problems when returned to caller.
Closing.
Thanks for this. Really enjoyed it. It was tricky to work out intially how to solve it. Loved the many different solution types people had. Great.
This comment has been hidden.
No.
This comment has been hidden.
i flagged this comment as spoiler be cause some one could think this is a solution och might get an idea. Iknow it does not reveal the full answer, but could give a hinch to where to start. If im exaggerating then of course im sorry for exaggerating :)
This comment has been hidden.
hi i've been trying to do it, but don't you need all the numbers between 1 - 1000 and so in the romans? becouse every time i am trying to run it, it gives me an eror that a number i didn't define does not work
not a kata suggestion ~~
System says my code failed at 3,4 and 2004.But when I try my code with GCC, it works properly and it yields right values.Test codes are wrong.
Prove it.
I don't think so...
This comment has been hidden.
What's the largest number that will be tested? 3999?
Clojure Translation ready for review.
Approved by someone
Sql Translation Kumited - please review and approve
This comment has been hidden.
Surely this is impossible for large numbers because you need to use M more than 3 times in a row unless you do something like MMMDMMMDMMMDMMMD.... which doesn't seem right...
Am I missinhg something?
With standard form the largest number that can be represented is 3,999.
Maybe because 4 repetitive letters never occur since 4 isn't IIII rather IV and 9 isn't VIIII rather IX?
If the entered integer is equal to or greater than the key in the roman numeral map, we deduct the key from the entered integer after the value for that key has been extracted and added to our empty roman variable which is the results. Why do we have to deduct the key from the entered integer? Can someone explain this
Help!
Error: Argument of type '"M"' is not assignable to parameter of type 'void'
Any pointers? What should I be looking at? TIA
This comment has been hidden.
This comment has been hidden.
Probably because you tested it passing a string there instead of a number.
Hello!I wrote code that passed "TEST" but cannot pass "ATTEMPT". A piece of code appears in the errors that is not in mine. I have screenshots in which everything is clearly visible. Please, help!))
Same here, using F#.
what is the problem of this code?
This comment has been hidden.
Use question label next time, read this
This comment has been hidden.
I passed the test. But fails in random test when attempting. Always fails on one case.
'The expression (as strings) (actual) == (expected) is false. '
I am not sure which one is wrong. I want to know that case. Help me.
This comment has been hidden.
the tests stop around 4000.
hello, im new here. could anyone review this https://www.codewars.com/kata/reviews/56257ae727e918467e00016c/groups/5e74a93d76b67f0001005054 ?
This comment has been hidden.
You have to choose the right version for that code to work, it's about how dictionaries are ordered (or not). In 3.6.0 it works fine.
This comment has been hidden.
It does work, but the function is expected to be called
solution
here, notromeValue
.I don't understand why it can't be return by StringBuffer.toString(). It just can be return by String. When I return by StringBuffer.toString(), it shows failed with <..[]...>(true) <..[..]...>(false).
oh i knew that because i used StringBuffer as field variable. Put it in method and successed.
My code passes with the 3.6 version of python. However, it fails with the 3.4.3 any idea why?
because all dicts are
OrderedDict
starting from python 3.6, while they aren't beforeThank you :D
-deleted-
This comment has been hidden.
Not a kata issue, in a row means next to each other, not in the whole string. Also, why 80 coudln't be LXXX if it says no more than 3 and there are only 3 X there?
This comment has been hidden.
C++ random tests, there are numbers larger than 4000, and even negative numbers...
Fixed.
This comment has been hidden.
Memory not allocated. Maybe other issues are present too.
Not a kata issue.
It's not a memory allocation problem,
buff
isstatic
. (Although now it's not reentrant, please don't do that.) The problem is that you don't terminate your string. Add a'\0'
at the end.My test are passed, but I get an "Exit code 139". Why is this?
Most probably run-time error or buffer overflow (if you're printing too much to the console).
This comment has been hidden.
Hey, first this is a great kata and I enjoy solving it!
However it would might be better for understanding the purpose of this exercise if the description would contain that the maximum of the input is 3999, with regards to "Remember that there can't be more than 3 identical symbols in a row."
This comment has been hidden.
Me aparece que esta mal pero no lo creo yo ya lo probe con mi compilador y le hice barias pruebas y todo correcto. Este es el mensaje de erro en la prueba aleatoria: MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM...CMXXIX Actual: DCCMXXIX
Lua translation kummited - please review and approve
Thank you very much for the translation, @konkath! I just started learning Lua, and your translation helps tremendously!
This comment has been hidden.
Not enough information.
I got the "All tests passed" message but I am not able to submit the code. Help?
Not enough information.
This comment has been hidden.
Flawed test case in Elixir:
Correct result is CDLXX for 470, NOT CCCCLXX.
So, I must have submitted my solution some 50+ times (hoping the generated number won't wrongly fail in Codewars tests).
The random tests are not actually random at all:
Exercism is currently down as they're upgrading to a new version, so I thought I will give Codewars a try in the meantime.
How can I submit this issue to Codewars to fix it ? Is posting it here enough ?
Normally yes, but you'll have to wait for the translation author or some power user who's fluent in elixir to fix it.
Same here..
Fixed.
Hello,
In the C language, I can confirm that my code returns the right string for 1991 and the tests after, strangely the tests return false
The expression (as strings) (solution(1991)) == ("MCMXCI") is false.
Any idea of the problem here?
No without seeing your code, paste it and mark your post as having spoiler content. Use proper markdown
This comment has been hidden.
I am also facing the same issue. Did you resolve it ? what was the solution you tried.
Not enough information.
This comment has been hidden.
I have this issue as well.
my test Scripts worked fine in my environment, however the simple test cases seemed to fail for solution 4. my result ovbiously return a string "IV", but I received the following error when running through this testing interface: solution(4) should equal to IV expected:I[]V but was:I[I]V.
That error says your code returned
IIV
instead ofIV
(if actual and expected are in their right place, and they are).the issue was that in my test cases, I was creating a new instance of the object each time, where this system was using one instance. I never tore down the string buffer after it was completed, therefore it was appending the next asnwer onto the previous. It is resolved now. thanks for pointing that out.
C++, issue with random test:
Expected: equal to MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM...CXXIX
678824 'M' total. If I change my code in such a way that the answer can have more than 3 identical symbols then I (obviously) get
Execution Timed Out
.The 678824 shouldn't be right at all, I don't know who made this but he clearly didn't test it out. Random tests shouldn't have more than 3 numbers if we aren't allowed to use the rest of the Roman numerals. Sad thing is that this is the first exercise I have done and it has given me a bad first impression of CodeWars. I hope they fix it one day.
Anyway, if you want I can send you the solution in C++, as I am not sure I have the right to post it here. The C++ code doesn't get timed out.
I'd say the biggest number you could represent using regular roman numerals and without using more than 3 of the same symbol in a row, is 3999. It's up to the translator (and the people who approves the translation) to respect the original kata spirit (and the range/values of the input). Sometimes things like this happens, be patient and wait, it's not like the issue was reported one year ago, it's been only one week.
Fixed.
Random test calls for negative int values (used std::cerr to see it). If I change an argument as unsigned int, it's no enough memory to write Roman representation. Very sad.
Test cases are flawed for numbers between 5000 to 9999 and need a workaround to make them work.
Either they should be 4999 max, either symbols for 5000 and 10000 should be given (apparently it's a V and X with an overline or vinculum).
For example?
7000 is MMMMMMM in the tests, it breaks the rule "Remember that there can't be more than 3 identical symbols in a row." According to various wikis, 7000 should be written VMM (V with an overline).
If the tests are passing in number greater than
3888
, the tests are wrong as they're passing in inputs greater than the range where the problem is well-defined.Fixed some language versions. Still fixing the rest because some translations are cough very poorly written.
Finally, all fixed ;-)
I also added random tests and fix all the
Test.expect
in every language.In C
The test cr_assert_str_eq(solution(2843), "MMDCCCXLIII"); fails. But by debugging manually with gcc my code generates exactly this solution. What is wrong? Possibly the test?
Kind regards
Sven
Should either take out the sentence "Remember that there can't be more than 3 identical symbols in a row." or take out examples that go over 3999. Would be helpful to mention how to handle nums over 3999 in description since actual roman numeral systems to express larger numbers do not just spam M until the desired number is reached.
Fixed
In PHP Rules state no more than 3 identical symbols.
Failed asserting that two strings are equal. Expected: 'MMMMMMMMMMMMMMMMMMMMMMMMLXXXVIII' Actual : 'MMMMLXXXVIII'
I have the same problem :/
Fixed
In C language: If I add a test
cr_assert_str_eq(solution(1992), "MCMXCII");
it passes. However, when I submit, it tells me:The expression (as strings) (solution(1992)) == ("MCMXCII") is false.
What's going on?I've put all the fixed tests in the actual tests into the sample tests, which should help with this.
try changing the compiler. it worked for me
The elixir sample tests expect a string result, but when you run the actual solution, it expects a charlist.
Should be fixed
In Python, text sent to console using print() don't show up in the Output section.
It seems fine to me. You could post you code here as a spoiler and I could have a look if you want.
Not an issue. Also should be fixed.
This comment has been hidden.
This comment has been hidden.
I keep getting an error in one of the random tests. Is there a way to know what input number caused that error? So that I can debug my code
You could use console.log() to print the variable to the screen :-)
Given he only trained in javascript, I think the previous comment answers the question.
C Translation Kumited - please carefully review and approve :D
This comment has been hidden.
I get this message (2008 should == "MMVIII") but 'MMVIII' is exactly the output of my Ruby solution. All other test cases until this are ok.
check for spaces or other invisible chars?
Ok, I checked it and found that my local Ruby version (2.4) has a different output for the "object.class" method. This was causing a bug in my solution. Thank you!
Solidity Translation Kumited - please carefully review and approve :D
R Translation kumited
Excessively commented reference solution at the top of the test suite :)
This comment has been hidden.
hi,
why don't you do it yourself? I saw you saying that you didn't want to go to the edit panel and so discard your % of progression in other languages, but if you already solved the kata you wont get anymore % of progression to your overall score, only to the specific language, so you could go to the edit panel and won't get % at all in any language, that won't affect your global progression on CW, actually... ;)
Sure, I've actually completed this Kata in all language versions so I won't lose any potential rank progress gains by editing the Kata myself but I actually don't really know Rust (I spent about an hour looking up at the Docs and Googling up stuff in general) so I'm not 100% confident that I can carry out the fix and not introduce new bugs. But since this should be a simple copy/paste, there's little room for mistakes so I guess I'll fix the Kata soon. Cheers :D
Fixed. Looks like the main tests and sample tests got swapped.
I'm not fluent in Elixir but I'm 99.9% sure that the Elixir translation to this Kata is seriously flawed (I did complete the Elixir version after all in case you're suspecting):
0
is tested as an edge case in both the Sample Tests and the Test Cases although there is no mention of it whatsoever in the Kata Description (or even in 10+ other language versions that I've completed this Kata in). Furthermore, the Roman numerals were not defined for0
anyway so this "edge case" should NOT be tested at all.If someone fluent in Elixir (or the Elixir translator himself/herself) could go ahead and fix the Issues I mentioned above that would be great. Thanks a lot :D
Fixed
Codewars Forums - Kata Best Practices - Have Full Code Coverage
[CoffeeScript] Having only five fixed assertions in total is far from full code coverage and will easily allow logically flawed and/or cheap-cheat solutions to pass. Please (1) either increase the total number of fixed assertions to at least 20 (with edge cases as well) or (2) even better, write 100+ random tests as per standard Codewars practice.
Fixed
Fun Kata but IMHO a bit overrated; I would personally consider this to be
6 kyu
tops.Kind of user dependant. I personally struggled very hard with the "Squares in a Rectangle" 6 kyu, and would consider that MUCH harder than this. BUT, I'm sure there are plenty who feel the exact opposite.
The Haskell template is misleading. It tells us
solution :: Int -> String
while in the test it actually expects anInteger
parameter.Fixed
This comment has been hidden.
The random test cases in Javascript expect results such as "MMMMMMMMCDLXIII" despite the description claiming that "there can't be more than 3 identical symbols in a row."
bump for this as still seeing it. A limit of three consecutive characters implies a number no greater than 4999 so the tests should reflect this.
Still true, I could only pass by adding an extra "M" for every digit higher in thousands place. Otherwise 6 cases failed consistently.
Still an issue! As per classic convention highest number for this kata should be <3999
Because if you allow entering 4 symbols of the same type, why "4" is not equal to "IIII" ?
Max number should be 3888. But yes,still expecting 'LXXXIX', more than 3 same chars
Fixed
There is a minor bug in elixir version of kata. On the first tests (also in the instruction), there is used String type as a result. On the other hand, after "attempting" tests, there is a char. I think it should be corrected :)
I have the same issue. I've tried to use String.to_charlist\1 without success. Any hint ?
String.to_char_list\1 should do the tirck. I've used it in my solution, also remember that 0 should return '' instead of "".
Yes indeed, elixir version messed up. The tests are not checking against a string
This issue hasn't been resolved. The Elixir version should be bumped to something 1.4.x, and the tests should all expect strings. Can we ping @jhoffner, who is sensei for the kata? How do I get involved fixing it?
Fixed
Haskell
Ran into the same problem as others:
I was irritated at first. But then discovered it was my bad! I enjoyed it after all.
I encountered the same issue as @deadwater. Some of the JavaScript random test cases use input values that exceed the
n < 4000
condition. Iterative solutions are not affected by these cases -- "M" is just repeated -- but digit-based solutions are. Marking this as an issue.When testing the javascript version, it will sometimes pass randoms numbers that actually exceed the parameter condition indicated (n < 4000). That is, I get "expected" answers that look like MMMMMMMMM when they pass something like 8000.
Badly needs random test cases, otherwise it's very simple to hardcode the solution... for a 4 kyu kata.
Added some time ago
This comment has been hidden.
This comment has been hidden.
Just a suggestion - You might put in the details what the upper limit of the argument should be. The roman numeral for 10,000 is an X with a line over it, but I don't think the users need to worry about something that high.
There's also a V with a line above it for 5000. I guess 4,999 or MMMMDCDXCIX would be the upper limit if sticking to the no-bar system.
This comment has been hidden.
I have just written this kata in C++. Can I somehow contribute my code to this kata, extending it to C++?
Thanks for the explanation. I had to finish this kata in a different language to obtain the right to add a new language. Beforehand, the drop down menu did not offer "Add New" for me.
In Typescript, i get the following error when trying to execute my code.
../home/codewarrior/spec.ts(1,1): error TS1084: Invalid 'reference' directive syntax. ../home/codewarrior/spec.ts(2,1): error TS1084: Invalid 'reference' directive syntax. STDERR: Error: Command failed: tsc --module commonjs /home/codewarrior/spec.ts
Not an issue
TypeScript translation
this was cool but wouldn't it be better if it prohibited memoizing everything except 1,5,10,50,100,500,1000?
The javascript version does not have tests to fully test all numbers, I can submit my solution without covering number 5, 100, 10 and many other numbers
This comment has been hidden.
A single line solution is possible :-)
Share it? :)
This comment has been hidden.
This comment has been hidden.
Passed all tests, when trying to submit the final solution, I am getting "There was an issue submitting your final solution". However kata appearing as completed, but solutions are not available.
At the moment this error appears on different katas It's a codewars problem, i have same errors for other katas too... So wait and see what happens here...
I'm trying to submit my solution in JavaScript. Tested in jsbin, seems to work well. Submit button rejects it with no message. I'm not even able to see output of my test cases. Am I doing something wrong? Thank you
In haskell, I am experiencing some problems when submitting my solution
/tmp/haskell116317-19-1p9qj5l/Main.hs:28:58: Couldn't match expected type
Integer' with actual type
Int' In the first argument ofabs', namely
x' In the first argument ofreferenceSolution', namely
(abs x)' In the second argument of(==)', namely
referenceSolution (abs x)'My guess is that some test cases are expecting an Integer->String signature when the kata solution has Int->String. Did anybody manage to submit the kata in Haskell ? Shame, it was a fun kata.
Change the type of the function to solution :: Integer -> String
Fixed
This comment has been hidden.
Thanks. Fixed
nice kata...
This comment has been hidden.
Test should be more exhaustive. I have sseen some aldgorithms in the solutions which would not do the job for numbers like 888.
In java. The test do not compile. A '}' character is missing.
Thanks. I'll update the java example testcases.
This comment has been hidden.
I've translated into Java. Please check and approve. :-D
When I run testcases, even with the solution's skeleton, I get the following error: /ConversionTest.java:13: error: reached end of file while parsing } ^ 1 error
java.lang.RuntimeException: /ConversionTest.java:13: error: reached end of file while parsing } ^ 1 error at codewars.runners.java$compile_and_load.doInvoke(java.clj:85) at clojure.lang.RestFn.invoke(RestFn.java:439) at codewars.runners.java$fn__572.invoke(java.clj:110) at clojure.lang.MultiFn.invoke(MultiFn.java:227) at codewars.runners$run.invoke(runners.clj:22) at codewars.core$_main$fn__634.invoke(core.clj:40) at clojure.lang.AFn.call(AFn.java:18) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.lang.Thread.run(Thread.java:745)
Hi, Sorry for the late reply. Could you send me your code so that I can revise?
Thanks! :)
You're missing a '}' in the test cases. It wasn't obvious at first, because I thought it came from my solution code. But other than that thanks for the translation. I had fun :)
Thanks. That's exactly where things went wrong. The real testcases are fine, but I miss the '}' in the end of the example testcases.
I'll update asap, whereas needed to contact the original author first. THanks for your comment.
I've added a translation to C#. Please check and approve. :)
This comment has been hidden.
for
50
, your code will returnXXXXX
(5X
s, each representing a value of10
) whilst the correct output should beL
. The same also applies for other interval checking points greater than 10.same issue with the tests
/tmp/haskell115119-7-49etmg/Main.hs:28:58: Couldn't match expected type
Integer' with actual type
Int' In the first argument ofabs', namely
x' In the first argument ofreferenceSolution', namely
(abs x)' In the second argument of(==)', namely
referenceSolution (abs x)'In Haskell, the type checking freaks out because the solution has type of
Int -> String
, but it getsInteger
as input for test cases.So, the type of solution should be either:
solution :: Integer -> String
or more generally:
solution :: Integral a => a -> String
Fixed
You should add what you want returned in the event that number is outside the range of Roman Numerals
This comment has been hidden.
This comment has been hidden.
The 'standard' modern form is, to my understanding, essentially a decimal system so it typically treats each digit of the number individually, which means 1990 is treated as 1000 + 900 + 90 + 0(ignored) as the author has indicated.
Further abbreviations are possible, sure, but I've seen no source that would indicate that they're widely accepted (unless you count Microsoft Excel's fairly unique willingness to display all sorts of weird variants). Do you have a source which suggests that Roman numerals correctly use the shortest possible variant? This would surprise me, given that the original numeric system was even more verbose than our modern one, with subtractive notation being infrequently used, leading to long strings of additive symbols to represent large numbers.
You're forced to use shorter even with the modern, unless you accept IIII for 4. But the other said no 3 consecutive symbols.
This comment has been hidden.
Not a suggestion
I don't think the description sufficiently describes how modern Roman numerals are expressed, namely using the following values, listed in increasing order:
Numbers are expressed via the sum of additive terms and subtractive terms.
Additive terms are the addition of terms, listed in decreasing value.
I, X, C, and M can be repeated up to 3 times in a term, but V, L and D cannot be repeated.
When a number calls for a 4th repetition of a value, instead use a subtractive term by following it with one of the two terms larger than it:
In this manner, all numbers from 1 to 3999 can be represented.
Should maybe consider added the 1666 test case as I was looking over my solution and I noticed I would of failed if that was one of the test thou I have now fixed it. Might be the case for some other solutions as well.
Yes, me too, but as this is a "valuable" Kata I won't complain - getting higher and higher!
And even though that I wrote 3 different algorithms, I still don't know what would be the best way to solve the problem, so perhaps a 4th Kata would be great ;)
Is this a duplicate of another kata? I've already done one like this, seen one for the other direction and seen one which includes both directions.