5 kyu
Readability is King
234 of 1,004matstc
Loading description...
Mathematics
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.
I don't know why, but this is ranked as a 5 kyu kata, for which you're supposed to win 21 points, but I only won 8 points initially, which turned to 9 points when I refreshed my profile. Weird.
See this paragraph.
great thanks, clears it up
Fixed 0.01 rounding errors in python by using 11.80 instead of 11.8
( JS, possibly others )
" ."
These things make counting words difficult, because they are not normal syllables, words, and sentences. The reference solution counts
"lbl"
as 1 word and 0 syllables. This may strictly comply with the specs, but I'd say it's not in the spirit of it.python new test framework is required. updated in this fork
Approved.
Heads off to the creator for this brain-teasing challenge, diving into katas is very enlightening, kudos...
I got a weird error for the random tests but could not figure out why.
We cannot help since you provide no information.
Same issue in ALL kata with floats:
Don't round float results!
https://docs.codewars.com/authoring/kata/floating-point/
The link is bronken, I found this one:
https://docs.codewars.com/authoring/recipes/floating-point/
needs random tests
Fixed
At least in Javascript: The tests don't require rounding to two places simply because they all happen to be at two digits of precision. The description mentions ignoring dashes, hyphens, apostrophes, ellipses and abbreviations, but none of those appear anywhere.
I am getting this error TypeError: fleschKincaid(...).toFixed is not a function. how to deal with it?
Either the function returned something that is not a number, or the function did not return anything.
This comment has been hidden.
Fixed the problem with
?
; as far as I am told, they
is not always considered a vowel, so I opted to keep it out; now it is made explicit in the code template. Thanksfor your feed :)I have strange problems with Random tests in Python version. Some of them pass, while some not.
For example, let's take the test
Cuddles a cute cuddles sleeps fun pippi? Cover cover hyperactive? Ubercuteness soft cuddles? Pippi sweet chair cute pippi.
My solution sees 4 sentences, 18 words and 35 syllables in it, so the result should be 0.39 * 18 / 4 + 11.8 * 35 / 18 - 15.59 = 9.11, however I get the following error:
It should work for random inputs too: 9.11 should equal 14.37
However, my solution produces 14.37 if the number of sentences in this test is supposed to be 1.
So my guess is that random test checker doesn't count
?
as end of sentence, as it probably should.I'm seeing the same problem, and can confirm that after reverse engineering the findall function, the regex being used to identify the end of sentences is
\.|!
rather than\.|!|\?
as you would expect.Yea.. Python version is totally broken..
I also made no use of findall, but was able to fix this with:
from re import findall
Still broken, but thanks to your tips (missing "?" in test cases and missing findall) is possible to solve.
Fixed this one as well, sorry for the trouble.
Thanks!
resolved
Bug in Python version. When I submit my solution, at the first Random test I get the following error:
NameError: global name 'findall' is not defined
I don't use global
findall
nor import it, so it looks like not my fault.I'm seeing the same problem!
I reverse engineered from the inputs and the response to various outputs that the code appears to be:
I got the same error please fix it
same error please fix it
Same error, is somebody fixing this?
Thanks to ChristianECooper for the workaround regarding findall, that was driving me crazy 😜
Fixed, sorry for the inconvenience.
Thanks!
Translated into Python, if you wish to approve it :)
Let me know if you may appreciate random test cases in both JS and Ruby and thanks for this kata :)
And again a broken translation...
Thanks for your comment, otherwise I would have never knew about the troubles.
Now it should all be fixed; a shame I was so careless back then.
This comment has been hidden.
I'm getting
TypeError: Object 3.67 has no method 'toFixed' at Array.forEach
But it works in node on my PC node v0.10.35This comment has been hidden.
Grade level should be -1.06 but was -2.75. The text was: A good book is hard to find.
That corresponds to what you would get if your code counted only 6 syllables instead of 7.
The test is correct.
Question answered. Not an issue.
lol, the test for my code says "Grade level should be 3.67 but was 3.67. The text was: The turtle is leaving. " , is 3.67 not equal to 3.67?
wrapped the result in a '.to_f' method, seemd to work
For the first two test-cases:
Grade level should be -1.06 but was -1.06. The text was: A good book is hard to find. - Expected: -1.06, instead got: -1.06
Grade level should be 3.67 but was 3.67. The text was: The turtle is leaving. - Expected: 3.67, instead got: 3.67
Also, for the third one , isn't the answer incorrect ? We have 10 words and the average no. of syllables is 1.1.
What am I missing here ?
As for the third case: it contains two sentences. You'll have to divide the number of words by 2.
And as for why you're getting the message "should be -1.06 but was -1.06", I'm not sure. Are you returning strings? You could try calling
toFixed(2)
on the returned value.This comment is hidden. Can you please rephrase this without any 'spolier' content ?
Done.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Now I have this issue for all the test-cases
Grade level should be 1.31 but was 1.31. The text was: Oh no! The lemming is falling. - Expected: 1.31, instead got: 1.31
Grade level should be -0.66 but was -0.66. The text was: To be or not to be. That is the question. - Expected: -0.66, instead got: -0.66
Grade level should be -1.06 but was -1.06. The text was: A good book is hard to find. - Expected: -1.06, instead got: -1.06
Grade level should be 3.67 but was 3.67. The text was: The turtle is leaving. - Expected: 3.67, instead got: 3.67
Grade level should be 4.19 but was 4.19. The text was: Do not cut your fingers as your katana is getting sharper! Be gentle. - Expected: 4.19, instead got: 4.19
Wrapped the return value in Number(gradeLevel) and it worked.
Great. I updated the kata so this won't happen to anyone else. Thanks!
You should add some randomness:
Or:
Yes, it's way better!
Enjoyed this one. Simple and straightforward.
I wish a margin of error was allowed what with float's innaccuracies and such, though. It seems we're forced to do a
+number.toFixed()
hack to pass the tests, but this should really be the job of the test.JS-translation kumited.
You could be a bit more detailed in your definition of a sentence. I'm guessing [.?!] is what you're looking for, but better to be explicit. E.g. […] (single char, by the way) could count too.
Nice kata, however the testing could be tightened up (see comments in my solution).
Thanks—though I actually quite like to see all the tests when I'm doing a kata. I find it frustrating when a test I cannot see is failing.
Seeing the ins, outs, and expected is great, as is having an established test base to examine. However, you've made it trivially easy to write a program that goes "If [turtle sentence] return 3.67, if [book] return -1.06 [etc.]" In addition to the tests you have, it's good to have randomized tests (perhaps built Mad Libs style, in this case, so the sentences/words aren't total garbage).