7 kyu
Printer Errors
48,597 of 163,169g964
Loading description...
Fundamentals
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.
the description can write how many letters are not in a-m directly;
mira que estoy aprendiendo ingles a la par y ya sentia yo q algo raro habia con esa descripcion
I don't understand the description
Absolutely disgusted on how bad this description is.
You just need to count how many times chars not in interval a to m appear, no matter how many times.
I am baffled on how bad this was written by op.
I do agree with you, but it's also fun to have a little story along with the practice problem.
I don't know how I got this error: Test Crashed Caught unexpected signal: SIGSEGV (11). Invalid memory access.
It could be I try to return a pointer. But I did the same thing in previous questions and never get an error
This comment has been hidden.
I don't understand what is causing this error: Traceback (most recent call last): File "/workspace/default/.venv/lib/python3.11/site-packages/codewars_test/test_framework.py", line 112, in wrapper func() File "/workspace/default/tests.py", line 47, in tests test.assert_equals(printer_error(s), exp) ^^^^^^^^^^^^^^^^ File "/workspace/default/solution.py", line 34, in printer_error if alphabet.get(letter) > 13: ^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: '>' not supported between instances of 'NoneType' and 'int'
all of the normal test cases pass just fine. The instructions state that the string will always be greater or equal to 1 in length, I covered every letter of the alphabet, and the instructions state the string will only include letters from a to z, so what could I possibly be missing?
Without seeing your code, we do not understand what is causing the error either.
nothing's stopping you from using print to observe what is happening there.
Check your alphabet, you have a typo there.
deleted
why i cant use array methods in here?, im using C#.
Maybe you're missing some
using
there?u mean using System its there but for some reason its not detecting the array Methods
Not that one, maybe it's
using System.Linq
the one you missed.thank you very much.
On C++, it's a class instead of a function?
this kasa it very easy to understand, i just couldn't understand that
it's very poorly written, I had to check it several times.
In C# I'm getting this error using System.Text.RegularExpressions and Regex.Count?
error CS0117: 'Regex' does not contain a definition for 'Count'
This code works in VS Code. Why doesn't it work here?
This comment has been hidden.
Thank you!
The instructions were really confusing and although the question was easy, I had difficulty understanding the question.
This comment has been hidden.
Not a kata issue.
Who ever made this please don't do this, Just make your instractions clearer.
As funny as I think it is to find a comment like this on a g964 kata, I see no issue here. Part of solving a problem is identifying what the problem is. There's no obligation to describe the problem in as simple terms as possible.
Almost chocked on this kata just because of how unclear the instructions were.
alphabets_a_to_m = 4 alphabets_n_to_z = 10
result = 10/4 <<<< This is what I thought the instruction was
but instead it was "alphabets_n_to_z/alphabets_a_to_m + alphabets_n_to_z" in this case result = 10/4+10 = 10/14
Anyway Thank you for all the effort you guys put into making these kata, they greatly help in improving my craft... Abashwe!
I didn’t understand anything, thank you for the detailed description
C fork
const
-qualifiedApproved!
This comment has been hidden.
There is no problem with the C version.
you must return a heap-allocated string (
malloc()
&co), your code crashes because you return a static stringThe swift version has no basic tests implemented, it's still the default template that returns true ever time
fixed
Why it doesn't accept formatted String?!!
it probably doesn't care in the slightest how you created it, a string doesn't remember how it is created. instead of considering how your string is created, you should look at whether it represents the correct text.
This comment has been hidden.
This comment has been hidden.
I pass the first test though, but not the Random Tests. It seems that whenever the string is >= 100 characters, the code fails..
The exec function only returns one match. It can't be used to get all matches at once.
This comment has been hidden.
Kata's suggestions are about improving the kata itself, not about its solutions.
This comment has been hidden.
This is not an issue. You're simply getting basic programming concepts wrong (not distinguishing what
return
andprint
does).How myopic of me, thank you for the insight.
The description was wrong. I though that the result should be with the strings... and not only the Number/Number. So I would change the description of what is to be the outcome to something more understandable..
s="kkkwwwaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbmmmmmmmmmmmmmmmmmmmxyz" printer_error(s) => 6/60
See the last example in the description, what's the difference with what you propose there?
printerError("auhszfkeus") // should return 5/10
It's not "wrong"; you're just reading it improperly.
Grantly, there are also the test cases, and if you don't even glance at the tests for a bit before blindly writing code, it's kinda your fault.
I knew in my head how to do it. I just missed one variable that my brain forgot. Was such a relaxing feeling to finally get it.
Interesting kata. A little complex but at the same time not that much. Don't overthink it.
<Expected: "z/56" But was: "3/56"> What? P.S. Initial test.
Mention the language too when reporting a problem, please.
Sorry, didn't think of it. It's C#.
Are you sure you didn't edit the sample tests? Click reset and try again, I don't see any error in the tests.
This comment has been hidden.
I am getting 3/56 as output but failing all tests and getting the same error. What am i doing wrong. What should i be returning? Is it a number or string? Help :-(
ReferenceError: printerError is not defined at Context. (test.js:22:10) at process.processImmediate (node:internal/timers:471:21)
See the initial code for javascript:
You're using
printer_error
instead ofprinterError
in your code.ahhh thank you! ;-)
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Does this help?
@Chrono79. thanks for the reference comment.
love this kata, thanks <3
I don't able to think about the logic to solve a problem, how can I can I improve to write logics?
Start off with 8kyu katas. Then practice on katas based on topics (
mathematics
,array
,string
etc.) Also, always ensure you have an official documentation of your trained language open at anytime ^^ (Seems like you've solved this one too, kudos ^^)Actual and expected are swapped in PHP
fixed
This Kata lacks the proper spec suit! Newbies will probably type all the valid chars one by one and, probably, they will make a mistake - miss one valid char. In my case it was the "e" char. The default tests do not cover this case. So I ended up looking at a confusing error message from the random specs that didn't give me a clue of my mistake. It's not human for newbies
There must be a default spec like:
This comment has been hidden.
I have "You have passed all of the tests! :)" but can't passed 'ATTEMPT'
Print the input: https://docs.codewars.com/training/troubleshooting/#print-input and read the docs about the methods you use and what they return. Read the error message too, it tells you what's wrong with your code.
Most likely you haven't protected against edge cases where there are no errors.
It's a madness for beginner..that really 7 kyu? Regular test passed, but random test generate x2-x3 wrong sum. It seems the problem is that the strings exceed some length and this breaks the algorithm, but where to dig ...
You're missing one letter in your
allowed_chars
, that's why your code fails. And no, it's not that hard.it's a madness, lost one char, that not in basic test, so imperceptible. You're right, it's easy exercise, just need more attention and focus. Thanks for help, i was ready to break my PC
How to return so that it does not share (3, '/', 56) should equal '3/56'
You were returning a tuple instead of a string there.
This is the most overcomplicated description I have ever seen
And where is the suggestion?
My python code works fine in the standard "test", but I get issues in the randomized tests. It would be helpfull if I could see how the random tests were generated, so I could see where it's failing.
as it stands, I have no clue what's wrong.
Print the input yourself: https://docs.codewars.com/training/troubleshooting/#print-input
Your code is wrong. Not a kata issue.
I found the issue, my mistake Yet I stand by my point that not seeing what the test is doing, does not help in finding the bug.
This comment has been hidden.
omfg what is wrong with you. What a tasks
This comment has been hidden.
.
This comment has been hidden.
Readable description:
Find the number of chars in the string which does not exist within the range a-m.
Return this number in the format "number/string_length"
Thank you
THANK YOU ! after 20min of trying to understand the description
String.fold_left Since 4.13.0 !! Update pls veriso
Mention the language you're talking about, so others can understand what you want.
it's OCaml and yeah, the codewars version is ancient ...
Request the language update here: https://github.com/codewars/runner/issues but note that OCaml is in beta in CW so don't get your hopes high for a fast update.
This comment has been hidden.
Please write in English, what is your function returning?
This comment has been hidden.
Read this: https://docs.codewars.com/training/troubleshooting#.print-vs-return
Thank you so much! Now everything has passed the test))
OP solved it, closing
This comment has been hidden.
Read this: https://docs.codewars.com/training/troubleshooting/#post-discourse and this: https://docs.codewars.com/training/troubleshooting/#c-c-signal-6---sigabrt
Not a kata issue.
This comment has been hidden.
Update to Scala 3
.
Can this not be solved using regex??? I keep getting 1-3 failed every time i attempt. Very frustrating i wish it would show me what strings it fails.
Yes, it can be solved with regex. Print the input yourself: https://docs.codewars.com/training/troubleshooting/#print-input
Read the docs about the methods you use and what they return.
This comment has been hidden.
done
Some confusing kata
This comment has been hidden.
This comment has been hidden.
Read about the methods you use, and what they return. Print the input too, it helps.
This comment has been hidden.
You need to allocate memory for your output (use
malloc / calloc
). You are not doing in the right way. I'm not sure this is the only problem with your code, it seems you are doing weird things...I'm doing weird thing cause i'm having trouble to understand char* related stuff
Search for C documentation:
calloc/malloc
and c-strings.thx i'll try my best
This comment has been hidden.
Basically, there is no difference between string and String in C#. "string" is just an alias of System. Both are compiled in the same manner. String stands for System.String and it is a .NET Framework type. "string" is an alias in the C# language for System.String. Both of them are compiled to System.String in IL (Intermediate Language), so there is no difference.
nice kata
Test Failed Expected string length 4 but was 56. Strings differ at index 0. Expected: "3/56" But was: "aaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbmmmmmmmmmmmmmmmmmmmxyz" -----------^
I don't know what to do
Return the right answer, in the expected format, it seems you're returning the original string there.
I get this error at Random tests: "TypeError: Cannot read property 'length' of null"
Someone with the same problem? I undestand that the given string is null, am i wright?
null
is not a string. And has notlength
. And no given string isnull
. That's the actual problem.thanks for answering akar-0. So, i have to deal with null inputs and with inputs that have no "mistakes"(so the length will be zero). more studying is the solution i guess..
No mistakes, probably, null inputs, no. Tests always generate a string for input.
This comment has been hidden.
Please use a spoiler flag and format correctly your code when you post code, see there: https://docs.codewars.com/training/troubleshooting/
null
has notlength
property. That means your code has a bug somewhere.COBOL translation.
Approved.
Dealing with the length of null error is the painy in my ass.. Anyone knows how deal with it?
write the example, please
This comment has been hidden.
Not a kata suggestion, please don't post solutions in Discourse.
This comment has been hidden.
Your code being wrong is not a kata issue, use
question
label for that. Read this, please: https://docs.codewars.com/training/troubleshooting/#print-input and debug your code. As a hint, the problem is in your if.This comment has been hidden.
Hello, it will be necessary to better specify the return of the function. Because I thought it had to return "printer_error (s) =>" 2/10 "". Whereas it should just return "2/10".
I see that you are very new at CW. "printer_error (s) => "2/10" means that the function printer_error return 2/10 for the string s. Furthermore the "Sample Tests" show the result, for example (C++):
Yes I'm a new kid, thanks for answering
This comment has been hidden.
And invalidate almost 83k solutions? No, too late.
Based on the description:
... a "bad" control string is produced e.g. aaaxbbbbyyhwawiwjjjwwm with letters not from a to m.
Then a test case with input
"aaabbbAAABBBcccCCC"
should expect"9/18"
, and fits with the existing description.Maybe the description should specify
... with lowercase letters not from a to m.
?Otherwise, a truly valid soltion should be able to handle uppercase letters being in the control string as well.
That means the input consists of only lowercase letters.
This comment has been hidden.
Read about what match returns on MDN for instance.
Haskell submit tests have warnings about tabs instead of spaces.
A cleaned up version is available here.
Approved, thanks!
Trying it in c, and alway get "fixture.c:22:100: error: function definition is not allowed here s = "kkkwwwaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbmmmmmmmmmmmmmmmmmmmxyz";char* printerError(char *s) {" as an error
Sorry, not a kata issue.
Ruby 3.0 should be enabled (Refer this & this for more detail)
Typescript 3.3 or above should be enabled
.
This comment has been hidden.
Please keep your posts (when they're about the same problem) in the same thread. I see two errors there, you missed a letter in
colores
and the parameter of the function iss
nota
.thank,
This comment has been hidden.
Please read this: https://docs.codewars.com/training/troubleshooting/ the tests are fine, your code must be wrong. Without seeing it we can't help you, only guess.
This comment has been hidden.
This comment has been hidden.
That's not PHP, that's javascript template literals
And about OP problem, check what happens when you test your function with
"abc"
. And read the error message: "TypeError: Cannot read property 'length' of null".
Wow I really liked this kata!
Thanks!
I suggest you clarify the kata description - specifically, make absolutely clear what it is EXACTLY that you want the function to return. At the moment the instructions show this:
printer_error(s) => "0/14"
as the expected return, - while what is REALLY expected is this:
0/14
Make it clear that you want JUST THE RATIO, not the whole thing including the words "printer_error(s)", etc.
printer_error(s)
is the call to the function. => is a shorthand of returns.That means
"0/14"
in the example. If you have any doubt, look at the sample tests.This comment has been hidden.
Read this: https://docs.codewars.com/training/troubleshooting/#expected-the-same
OP solved it, closing
This comment has been hidden.
your function isnt returning anything, you should return your
test_one
variableThere should be fixed tests with all letters in range
"a" - "m"
, and all letters in range"n" - "z"
.This comment has been hidden.
Your "definitely correct" code fails for the simplest inputs, e.g.
printerError("a")
. Not an issue.This is the code that I copied from the first answer that appears for Javascript tho. Yet it still fails even tho apparently it was correct when someone else did it. Is there a possible reason why that you could tell me?
Edit for context: the code in the above comment is the top answer for JS. Yet when i press attempt, it returns 196 correct answers and 5 errors.
Somebody submitted that code when the tests were too weak to catch such wrong solutions.
This comment has been hidden.
This comment has been hidden.
since Julia suports rational number type it could be fun if the solution accept it. Example:
1//2
Julia is coherent with other languages that don't have rationals...
And in my opinion it would be better if it wasn't :)
Pleased to pass all of tests in 1st attempt !!! Love the concept!
can someone help me when the test is being done for an empty string my program returns 0/0 but the expected answer is 3/56 isnt this an error in the code?
I am not aware of tests featuring empty inputs. Double check that you are reading the input correctly and not mutating it (although strings typically are immutable; I don't know what language you are training in).
This comment has been hidden.
Read this: https://docs.codewars.com/training/troubleshooting/
For whatever reason, the tests are failing for JavaScript. My code is correct, this is an easy question, which I've verified outsie the codewars environment with the same test inputs.
Read this please: https://docs.codewars.com/training/troubleshooting/
It ended up actually being my mistake, I had for(const char in s) instead of the correct for(const char of s)
This comment has been hidden.
Based on the test cases, you must allocate a new string and return a pointer to it. You shouldn't change the input string.
This comment has been hidden.
OP solved it, closing
This comment has been hidden.
In Python the template solution is 'def printer_error(s): # your code'
In the description it is an 'Example' for all the languages of the kata.
Why so many long-winded and confusing descriptions for simple katas? Could have said something like this: 'A valid string will only contain letters from a-m. Write a function that returns the number of invalid characters in the string over the number of all characters in the string. E.g., 3/56 where 3 is the number of invalid characters and 56 is the number of all characters.'
Will be skipping g964 katas in future.
Too much letters for you?
Yes, too "much" letters for me. Well done for oversimplifying it into something you can understand.
THANK YOU VERY MUCH!!!!
This comment has been hidden.
Please read this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution#how-do-i-post-to-a-kata-discourse And then this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution#appendix-a-exit-codes-signals-and-other-strange-numbers
This was the easy one please add some difficulty for beginners.
Are you saying it's too easy for you? Click over Kata in the left menu, and choose a higher Kyu (smaller number is harder). There are plenty of harder katas. Nobody is going to change this kata after more than 64k solutions without a very good reason. Not all katas have different difficulty level about similar tasks, only a few ones and only an even smaller number of them are well implemented. Maybe I misunderstood you, but with only a single sentence it's hard to tell what you really meant.
I struggled so much understanding the prompt. I first thought you wanted to know how many characters were out of alphabetical order. Then I thought you wanted to know the biggest sequential letters after m were in the string. Then I thought you wanted to know how many groups of letters after m were in the string. I coded a functional response for each of those irrellevant prompts to come to two very important realizations:
Dont code at 2am
&&
Read the prompt more carefully
Iam a total beginner, and I have no idea how to complete this so called beginner challenge Need something easier to start with
If you need some help, let me know!
This comment has been hidden.
That's not a kata issue, read in MDN about the string method you used, the error tells you exactly it returned
null
and you're trying to read the length ofnull
.This comment has been hidden.
You're still trying to get length of null there before even checking the value. There is no
null
as input value in the tests.Read this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution#print-input
This comment has been hidden.
Really liked the concept! But when I go to attempt I am getting this error:
Traceback (most recent call last):
File "main.py", line 3, in <module>
import codewars_test as test
ModuleNotFoundError: No module named 'codewars_test'
seems to happen for 3.6 but not 3.8
I believe removing the import from the test code would fix it? (codewars adds the import, it's already there)
I commented out the import, and that made 3.6 unavailable, only 3.8 available now, I see no problem with that.
What determines that? Automatically set on update? Or did that break? Shouldn't break... But yeah, no problem in dropping 3.6, obviously.
Python: Random tests section is not grouped apart with
test.it
. Currently it's in the sample tests section.fixed
Thanks!
This comment has been hidden.
Didn't understand, the line should contain letters from a to z or from a to m?
Any letter not in a to m is an error. Read the description again.
I have passed all of the tests! :)
The description says: "... which given a string will output the error rate of the printer as a string ..."
The problem is to return the error rate, not to output it. I think "output" should be "return" in the above sentence.
This has caused confusion for at least one person working on the problem (Clonewarrior).
Modified.
This comment has been hidden.
This comment has been hidden.
ohh thanks it worked...i thought it was "a" through "z"...
This comment has been hidden.
Try typing this into a Python interpreter: ('a' or 'b' or 'c')
Hopefully the result isn't what you expect. I think your "if" statement is the problem.
This comment has been hidden.
This comment has been hidden.
Not a suggestion.
It would be good to specify in the description that the result does not need a newline character.
Why would you add a newline to the output when it's not mentioned anywhere?
Cause generally it's good practice to add a newline when you've finished printing something in the terminal.
Actually both of you are correct - the problem description is wrong: "which given a string will output the error rate of the printer as a string"
I simply assumed the problem meant returning the string, but the description says "output".
Can the c version be solved w/o a static variable (has concurrency issues) or leaking (doing a local malloc) or returning a pointer to a local array, which will likely work most of the time, but is undefined behaviour? I would assume, that the function also takes a preallocated buffer to write the output into.
(I program in C++ usually)
Many C kata lack any description of required memory management, that's true :( This particular task requires you to return a pointer to a freeable buffer. It won't leak, because test suite calls
free
on returned pointer. It's usually the case with C kata on Codewars - when in doubt, assume you have tomalloc
.OP solved it, closing
This comment has been hidden.
Read this, especially 6th bullet point.
matchAll
is not supported in Node 10, which is used by Codewars.Above "solution" window i see Node v8.1.3. Thanks for link
Anyway, it's available since Node 12, so unfortunately it's not on Codewars at the moment :(
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll
THX! You are right! console.log(String.prototype.matchAll) returns undefined
Add a couple fixed tests:
Some invalid solutions are passing without them (being no errors the most important of those two)
Hint: If you do not know what to do, read carefully description parts with
letters from
andwith letters NOT from
. Great Kata.Thanks!
This comment has been hidden.
Template literals work just fine for me.
Yeah I'm not sure what happened with it. The test result showed my returned value as an identical value to the expected result, but showed as failed unless I assigned it to a string instead of using a template literal.
the poorest description I've ever seen smfh...
This comment has been hidden.
This comment has been hidden.
replaceAll
is a java String method, I don't know how it works in your console. Then there is some problem with the logic in your code.This comment has been hidden.
You can see there it doesn't work in Node. You misunderstood what to return:
This comment has been hidden.
This comment has been hidden.
Your function should return, not print the result.
C test has an error on line 15, freeing memory that hasn't been allocated. It's causing the test to crash on submission.
You can't allocate the string on the stack: "... you can’t return a string defined as a local variable from a C function, because the variable will be automatically destroyed (released) when the function finished execution, and as such it will not be available". You have to malloc it or use something else. When you have a problem, look at the top of the page: 991 guys passed the C kata. If there were problems somebody would have seen it long before and so first thing to do: verify your code. Cheers.
What about returning a pointer to static char array? You should explicitly state in the kata description, that the returned pointer must be alloc-ed using the C standard library.
This comment has been hidden.
What is the signature of the function? What are you returning?
I tried to search up how to return a string but the results are inconsistent and I tried a lot of options but I really can't figure out how to add the strings together (numerator, "/", "denominator"), how does one do that in C?
I think powershell is broken right now, I'm getting this error when doing test: Cannot find the PowerShell data file 'RSpec.psd1' in directory '/usr/local/share/powershell/Modules/Pester/4.1.1', or in any parent culture directories. The term 'Get-WmiObject' is not recognized as the name of a cmdlet, function, script file, or operable program.\nCheck the spelling of the name, or if a path was included, verify that the path is correct and try again. The term 'Get-CimInstance' is not recognized as the name of a cmdlet, function, script file, or operable program.\nCheck the spelling of the name, or if a path was included, verify that the path is correct and try again./56
Not a kata problem; your code is wrong somewhere and "Pester" the tests used by CW is not very smart. Look at the top of the page : 39 people passed the PS kata. When this number is not small, please search errors in your code rather in the kata:-) Cheers.
Thanks, it was my mistake. I named one variable $error and it is not proper variable name.
I saw that: "$err" and then "$error" ... Morality: don't post issue too fast:-)
Initial code snippet has a typo "cude" instead of "code":
Thanks!
f-strings are not supported by kata?
Switch to version 3.6
How do you switch versions?
In the trainer, beside the language selector, there is a version selector.
This comment has been hidden.
first, please don't post any code without the spoiler tag (I have added). second, you have to select python 3.6 to use this syntax. third, you have to fix your syntax. cheers!
I could create something in c shell that does what this program is supposed to do, but if I copy and paste my result (which I know works because Ive tested it) onto the solutions, it gives me error messages
You really should not use char maths in production for this kind of problems. Bad "colors" are an arbitrary human-defined list, so you should clearly define it as a const/var for later corrections. If they suddenly start using
z
orΩ
or🍆
the code should still work.This comment has been hidden.
return
the result, don't print it. ;)This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
It has to deal with the order of operations. The first one will only return true if both conditions are false (so the value has to be greater than 'm' and smaller than 'a'). The second one return true if the value is greater then 'm' or the value is less than 'a'.
As for solutions using [^a-m], they are using it as part of a regular expression (REGEX) to test if the characters in the evalutad string are not between a and m.
Hopefully this helps, I know I am a few months late.
Dart translation btw, there is also a swift translation sitting around.
Approved. I don't know Dart so I trust you:-) Approved your other Dart translations too. I willsee later the Swift one.
Test is Passet, but I see this Error: *** Error in `./test': double free or corruption (out): 0x00007fffaa149d20 ***
What is it???
I think this corruption is happend because you'd stepped out of memory.
This comment has been hidden.
You missed a comma in your
range
var.Thanks! Two as it turned out. How annoying, no points for me because I already looked at the solutions! Ah well ...
This comment has been hidden.
Don't post solutions!
My random test count m as an invalid letter but the other test does not. Breaks the code
When reporting an issue, state the language you're having problems with. If it is C#, the control function (used in random tests) returns the same expected values as the ones of the fixed tests. Neither of them count m as an invalid letter.
Read again the description: m is a valid letter. The reference solution is the same for fixed tests and random tests. Moreover note at the top of the page that 3028 guys passed the C# kata. If there were errors somebody would have seen them since long. Cheers.
Scala translation available for review.
I have approved all your translations.
Thanks!
Some C functions that have string output allocate memory, and others return a pointer to a static buffer. The former is required by the tests in this case, but that requirement is not written in the prompt.
Swift version for review
Yet another example of bad kata design, tons of reading of some vogue abstract bs to just write a oneliner. It should be the other way, you should give me a simple task that makes me writing code like a crazy, not just staring at screen struggling to understand wtf do you want from me and then solving it in seconds.
Exactly...
This comment has been hidden.
Users are not allowed to share their solutions anywhere.
Rust translation
This comment has been hidden.
Because in CW your function should return the result, not print it.
This comment has been hidden.
easy boi
its not very clear what is a valid string or an invalid string/character... should clarify letters after m are considered errors
This comment has been hidden.
You forgot to initialize
nError
.I've completed my code, but when i attempt i'll get a couple come back saying "Cannot read property .length of 'null'". If i click attempt again. i'll get 6 wrong, if i click again 5 were wrong, etc. Problem is, i can't see what the test was so no idea how to correct it. My code is correct but it decides different tests come back wrong every time i click attempt. Can someone help?
My guess is you're using
match
, read the docs then. You can always useconsole.log()
to check the input values.You legend, thank you! You helped me realise using string.match returns null if there are 0 matches.
This just saved me. Thanks
I believe the
Golang
signature should be modified to contain the return type:Currently the signature doesn't expect any return values, and can mislead others to test printing.
Small change, but I feel it is necessary for good direction.
I'm not the Go translater but fixed. Thanks.
why can't we see the rest of the test? When i attempt to upload my solution i suck at the fixed test exactly here: expected:<[6]/60> but was:<[4]/60> and the another one is expected:<[12]/828> but was:<[7]/828>. I clearly do something wrong, so the test could be a nice help to figure out where is my mistake... cheers
You can always print arguments yourself if tests don't show them.
ok, but the code seems okay and still missing something some argument and yet i do not want to have a look at others solutions, so happy to have mine... anyhow thanks for ur respond...
He didn't say look at others solution, looking at the input values you can check why your code fails.
okaym i clearly understand what he said, but there is only one input values, that is what i'm exactly moaning about...
hi. i think there is a problem on basic tests. because my code pass the sample tests and ramdom test. but then i cant trace whats the problem on basic test its give "expected '0/32' to equal '1/32'"
im using typescript
"expected '0/32' to equal '1/32'"
Your function returned
'0/32'
instead of'1/32'
. Useconsole.log(s);
to see why. AFAIK the kata tests works fine in TS.sorry can u know why "ijacfcmkedbgefaierflkijalbdckfci" this suppose to return 0/32 right? but then the correct is 1/32?why?
Read carefully the given string.
i think there is a problem ith kata tho
This comment has been hidden.
Kotlin Translation
Please, review and approve/comment
Something seems to be not working right with the interpreter. My code is 10 lines long (a for loop with an if inside) but when I run the sample test it generates this stack trace: /home/codewarrior/index.js:22 })})f; ^
SyntaxError: Unexpected identifier at createScript (vm.js:80:10) at Object.runInThisContext (vm.js:139:10) at Module._compile (module.js:616:28) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at [eval]:1:1
I have no idea where it's getting "})})f" from. What the heck is going on?
Make sure you're closing you curly braces and parentheses right. AFAIK the js tests are working fine.
I am not sure I understand the question correctly. The code to be written is only supposed to check when there is a bad control string and return the ratio, correct?
You have to calculate how many characters of the string are not in
"abcdefghijklm"
.Okay. But, I am recieving this error:
'0.05357142857142857' should equal '3/56'
why is the numerator 3 when all characters are not in "abcdefghijklm" and the length of the string is 19?
That's not the input value, you're returning the result of dividing 3 by 56 (the error message is:
your function output
should beexpected value
) instead of returning the fraction.Oh, I see. Thank you!
I cant seem to figure what my problem is...any help would be nice
Question not specified.
Can you please look at my solution and tell me what is wrong.
No, unless your solution works, no other user can see it. For cases like that, paste your code using proper markdown and mark your post as having spoiler content.
This comment has been hidden.
This comment has been hidden.
Enclose your code in triple backticks as shown here (second example). It seems some of the symbols in your comment don't show up without proper formatting.
Also, give an example of the error messages you receive, I don't see any serious problems with your code.
This comment has been hidden.
read the description again, all the needed information is in there.
I think my program is right for the most part, but im getting this error.
expected:<[]3/56> but was:<[5]3/56>
I don't see what's wrong. A little help would be nice. Thanks
Your solution returns
53/56
instead of3/56
. You might have mixed up which characters come from "errors" and which do not.This comment has been hidden.
The most popular solution has a problem when there is no error in the given string but it seems it has passed the random tests because by luck there were always errors in the given string. I will add a test for that.
This comment has been hidden.
Perhaps I'm misunderstanding the problem but I keep getting this error when running the sample test. My output is 3/56, which seems to be the correct result? Test Results: printer_error Basic tests Log 3/56 None should equal '3/56'
You're not returning anything.
Thanks very much for the quick reply. I got it now.
Hi, I made a NASM translation for this Kata, please review and approve.
Approved, thanks!
Hi,
My code actually works but the program don't detect it. Can you help me please.
Thanks
This comment has been hidden.
Because you're returning nothing.
Haha, agh! Thank you. blushes forever
This comment has been hidden.
You're not returning anything.
This comment has been hidden.
Why are you posting solutions where they're visible to anyone? Please, don't. Also I don't know why you marked your post as a suggestion.
If string undefined or empty you must return '' (empty string).
I keep failing 2 tests and I can't complete this kata because I cannot see why the test is failing. I've even made sure that the code took into consideration if it was passed an empty string or nothing at all. (javascript)
You can print the input and calculate it yourself.
This comment has been hidden.
I don't understand the Kata. What should be considered and error an what not? It's not clear to me.
Error = each character from
n
toz
in the input string.This comment has been hidden.
Why are you returning a call to the function without an argument? That's the reason for the error message you get. Your function should return a string as you can see in the instructions. The function's name is language dependant (in javascript
camelCase
is used,snake_case
for other languages like Python and Ruby). Mark your posts as having spoiler content when they do. A last advice, match could returnnull
if there is no match, so calling length on that will also throw an error.Thanks. Sorted the return info to make sense. As you said i'm getting the 2 errors re null values. I'll make sure to use the spoiler flag in future.
This kata needs one more basic test that verifies the case where string doesn't contain any errors.
Already raised above
This comment has been hidden.
ALTAS IDEIA. DAZUMBANHO.
This comment has been hidden.
Groovy translation: https://www.codewars.com/kumite/5a5798decadebf233d0000ef/
Trying to Solve this kata in Javascript. Keep getting error message
STDERR [eval]:75 }); ^ SyntaxError: Unexpected token ) at createScript (vm.js:56:10) at Object.runInThisContext (vm.js:97:10) at Object. ([eval]-wrapper:6:22) at at evalScript (bootstrap_node.js:353:27) at run (bootstrap_node.js:122:11) at run (bootstrap_node.js:389:7) at startup (bootstrap_node.js:121:9) at bootstrap_node.js:504:3
The problem is probably in the test code, and not in your code. However, it probably is caused by your code. You need to check all your brackets and braces and see if they match.
You're missing a
}
in your code.return str(m) + "/" + len(s) raises TypeError: Can't convert 'int' object to str implicitly
you need to convert 'len(s)' to string 'str(len(s))'
As toledoal said. You need to call len(s) explicitly as a string.
The argument type should be
const char*
in C.char*
suggests that input can be modified while in fact it can't.If I change this will invalidate all C solutions?
It shouldn't, I already used
const
in mine. It's most likely illegal but in the real world I can't imagine it failing even with Clang's ability to spread the consequences of any subtle mistake across the whole compiled program.I'm not going to tempt the devil. I'll try to think of it if - one day - I translate to C. Thanks for your posts!
This comment has been hidden.
OP solved it, closing
This comment has been hidden.
I am sorry: I verified the tests and tried several solutions; all is fine. No problem with the kata.
how about supporting lodash for this one?
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
my question for each test sample string and to be tested string are different.
are we supposed to take two string variables and compare them, if yes how will they receive values
This comment has been hidden.
This Kata description has a typo. In line 2, it reads
I think the letter a should be changed to be h to avoid confusion.
I don't see where a confusion could be. Moreover 9176 guys passed the kata as you can see at the top of the page.
Of course it is easily solvable since this problem is not that complicated. I mean, there is a typo in description, so I recommend you to correct it for perfectness. Sorry if you felt uncomfortable.
Oh, sorry! Now I see the mistake.
I don't believe that was a typo, characters can appear in any order as long as they are in the valid character range
One of the ruby test case has 53 legal characters but it expected 56. Can someone fix those testcases.
Nothing to fix, 707 guys passed the Ruby kata.
My answer passes all the test but I still get a red box and its not letting me thru, what do I do?
Currently Codewars platform is experiencing issues.
Same issue...
This comment has been hidden.
Only letters from
a
tom
are valid. Any other ones are errorsInstructions could be a litte clearer. I was under the impression that you had to exclude duplicates. I had the actual problem solved in a matter of minutes but spent hours trying to exlcude duplicates.
expected:<[]3/56> but was:<[5]3/56>
This is a failed test case. I didnt understand what was the mistake.
The brackets say where there is a mistake.
This comment has been hidden.
The "Examples" are generic for all languages but when you train for Java the template for solution is:
Hope you saw that:-)
Oh yes. I replaced it with printer_error because I thought it was a trick.
"One kind of boxes" -- it should be "one kind of box."
Maybe a look at http://english.stackexchange.com/questions/111666/some-kind-of-singular-or-plural... I am not sure about that!
In "Printer Errors" I have a strange behavior at Random test at string: 'kmhebkaeamhmjaimmadjfijlhlaibfmelfmbdagbchjmjmhkcdffilhjghcjembfihjahmjhcmhabcbeajdijllaahlhkdhjdcgjghjkefbjdldlalaiajmhdgahafkkjbfchhbffmdljjjgjkhemmjlakjajdldehchffebebdejfbgeidgefhkhhbdjcmmcblfkgaebagihmkhllebflcaaghiacbhdfjfbahiecjchikahajekllhiffafhjyhicfjijeliaeehlcvmmghfmahlmmicmgiramfababdjgehcjebtchihikiekkafafmaogjdiaeglbjejelbevdibekmchegehcjlmucgggdallcjbbcjdhtbdldmkkfgimeibckvgkkggdclhhjgkdkgoekgfjcgcdjjmlbcczlgfdgmgijbalckdcqjgmcgebgchdlibjfslgalejlgabafbglfnmkgbdkacemeeabgfzkjaehegjdageck'
i fountd 14 unlegal characters: ['y', 'v', 'r', 't', 'o', 'v', 'u', 't', 'v', 'o', 'z', 'q', 's', 'z'] but test says : '14/508' should equal '15/508' all other are Passed where i do wrong?
First please tell which language? When you post a question don't post an issue... Issues are for problems of the kata not for problems in your code. The tests are the same in all languages and 5397 guys passed them (as you could have seen at the top of the page; 630 with C#) so we can be pretty sure there are no errors in the tests. Maybe you didn't find all the non legal chars?
sorry ) I try to do it on Puthon. I understand what you mean. But i parsed it with regex with help of notepad++ and it show me only 14 entries. Could you tell me, what symbol is missed?
Oh! I Found the problem))) i missed Letter from english alphabet. Thank for your answer. I next time I will be more attentive.
I have sterr when run Attempt:
/tmp/haskell1161126-18-1edhqlb.py900pmn29/Codewars/G964/Printer/Test.hs:11:1: Warning: Tab character
/tmp/haskell1161126-18-1edhqlb.py900pmn29/Codewars/G964/Printer/Test.hs:12:1: Warning: Tab character
/tmp/haskell1161126-18-1edhqlb.py900pmn29/Codewars/G964/Printer/Test.hs:26:1: Warning: Tab character
/tmp/haskell1161126-18-1edhqlb.py900pmn29/Codewars/G964/Printer/Test.hs:27:1: Warning: Tab character
/tmp/haskell1161126-18-1edhqlb.py900pmn29/Codewars/G964/Printer/Test.hs:28:1: Warning: Tab character
/tmp/haskell1161126-18-1edhqlb.py900pmn29/Codewars/G964/Printer/Test.hs:29:1: Warning: Tab character
/tmp/haskell1161126-18-1edhqlb.py900pmn29/Codewars/G964/Printer/Test.hs:30:1: Warning: Tab character
/tmp/haskell1161126-18-1edhqlb.py900pmn29/Codewars/G964/Printer/Test.hs:31:1: Warning: Tab character
/tmp/haskell1161126-18-1edhqlb.py900pmn29/Codewars/G964/Printer/Test.hs:32:1: Warning: Tab character
/tmp/haskell1161126-18-1edhqlb.py900pmn29/Codewars/G964/Printer/Test.hs:33:1: Warning: Tab character
/tmp/haskell1161126-18-1edhqlb.py900pmn29/Codewars/G964/Printer/Test.hs:34:1: Warning: Tab character
For a long time this kata worked without problem. CW changed something and I reported the bug long ago but it seems that nothing was made... I just fixed it with a pragma and it works now. PS: not useful to report so many outputs:-) Cheers!
Sorry! I will no longer do it :) Thank you for help!
I'm doing this kata in C++. The code compiles, executes and passes, but a popup message says the server has problems or something like that, and I can't submit the solution.
First time answering a question on this site... are we able to bring in any standard namespace? Not being able to use Linq will kill me.
I am doing this in Python and I've solved it correctly, but if I submit I get this error:
I also has green arrows arrows next to "printer_error" and "Basic tests" so I'm guessing that I got the actual challenge right. Thanks in advance.
578 guys passed the Python kata as you can see at the top of the page, I just tried a few solutions and everything worked fine.
This comment has been hidden.
For the F# version I get this when I try to submit:
Are you using "Regex"? If so include in your code
open System.Text.RegularExpressions
and it should work.I'm not at all. I figured one of the tests is.
Is it working now?
No, it isn't. I've got this error too.
In the reference solution for the "SUBMIT" tests I'm using a "Regex" so now I have included in the "SUBMIT" tests
open System.Text.RegularExpressions
and hopefully it should work. When I try it works...All is good now! Thanks!
Lots of thanks for your posts!
This comment has been hidden.
s.match can return a null value. In that case, you will be trying to reference .length of null.
This comment has been hidden.
Good idea but the description says:
Fair enough. I've done enough real-world coding to never trust an error condition to be 'valid' for a particular state, however ;)
There are capital letters in the PHP test case, presumably unintended?
Fixed, thanks!
My code is failing the tests but the actual and expected match, for example: ✘ Expected: equal to 3/56 Actual: 3/56
I'm coding in c++ and definitely returning a string, so not sure what's going on.
I just tried and it worked fine.
I'm pretty new to codewars, but I'm assuming you can see my attempted solution.
If it works for you but not for me, what would cause that?
I can't see your solution unless you succeed:-(
I figured out where I went wrong, I was appending an endl onto the end of the string I was returning. So the strings looked identical when printed. Thanks for taking the time to reply anyways. :-)
For a description of the problem and the examples it is not clear under what set of letters will be mistakes. Tell me in detail an error in what cases? Thank you!
The description says: "For one kind of boxes the printer has to use colors which, for the sake of simplicity, are named with letters from a to m." So these are the good letters, other letters are mistakes.
Thanks for the answer! Now it is clear.
Yes I was confused about this because at the end it said something like the string containing letters a - z I was very confused about what was being asked
The test cases are failing with syntax error: File "", line 12 test.describe("printer_error") ^ SyntaxError: invalid syntax
am I missing something here ?
Please which language?
python
I tried it with a few different solutions and saw no errors, no problem. It works fine.
Fixed now. Was missing a parenthesis in my solution. The error from the test case was misleading. Led me to beleive something was wrong in the way the 'test' module was being used
Wow! Always look at your solution before posting:-)
My code passes the first test but for the second round it fails for both cases. My problem is that the denominator is correct which is the summation of correct and erroneous letters but the numerator is wrong!(less than what it should be!) Can you help me figure out mmy problem?
The denominator should just be the length of the string. The numerator will be incremented by 1 each time you see a character that is greater than 'n'. Hopefully that helps enough for you to solve this one!
Thanks for your reply. The thing is I am calculating this fractoin as (number of erroneous letters)/(number of erroneous letters+number of correct letters). So if the test shows that my denominator is right, so number of erroneous letters and number of correct letters should be correct, right? So why is my numerator wrong???!!!!
Erroneous letters are from
n
inclusive toz
inclusive.Not necessarily, one error on erroneous ones can compensate one corresponding error on correct ones...