6 kyu
Highest Scoring Word
32,787 of 104,482PG1
Loading description...
Fundamentals
Strings
Arrays
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.
Loved this kata, thank you!
Thanks :)
ebychaya kata vtoroy den reshay, bullshit!!!
iam new i dont know anything pls help
start with 8kyu , do fundamentals tagged questions so you get basic understanding, you will eventually get into the habbit
Groovy Translation
approved
This comment has been hidden.
All tests passed exept these: Expected: equal to "pizzsuh" Actual: "pizzsuhpete"
Expected: equal to "peenrasbrsoppfekslnasiprh" Actual: "peenrasbrsoppfekslnasiprhakbbtttpoitpeazdbey". I dont get it. What is the whole string?
https://docs.codewars.com/training/troubleshooting#print-input check that out.
Lua translation!
Approved, thanks
This comment has been hidden.
This comment has been hidden.
Hint != kata suggestion. See https://docs.codewars.com/training/troubleshooting#post-discourse.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
that easy too, but a little bit hard too!!
This comment has been hidden.
This comment has been hidden.
Your post was visible from the homepage, please don't post solution in the discourse page.
OK, i am sorry about that
This comment has been hidden.
that may be a typo, but I also think you wrote it
I didn't find any mention of the word
ubudlimbing
in the C# sample test & actual test, I think you might've accidentally modified & merged lines 14 and 15 in the sample tests (the bottom right box inside the editor).This comment has been hidden.
Read this: https://docs.codewars.com/training/troubleshooting#works-but-no your problem is explained in one of those points. Also read this: https://docs.codewars.com/training/troubleshooting#post-discourse
"All letters will be lowercase and all inputs will be valid"
Random Tests can lead to Kata.high(""), a warning would be appreciated.
This comment has been hidden.
This comment has been hidden.
You should refrain from posting solutions for every kata you solve in the Discourse. Discussion is not intended for this purpose.
Hello, I ran into a problem and i believe my code is correct but i was stuck when it came to test case of "what time are we climbing up the volcano". Now we all can safely assume that the correct output would be "climbing" but appearently the right answer according to this site is "volcano" which makes no sense because if we add the ascii value of every letter in each word it would be climbing: 837, volcano: 754. Please correct me if I am wrong so that I can complete this kata.
just start reading comments, you'll quickly find the reason for this
Or read the description again:
This comment has been hidden.
The test case "what time are we climbing up to the volcano" does not work for me. My code recognize volcano correctly, but it returns "vulcanog" instead. There is probably a memory issue, but I can not find it. Any Ideas?
This comment has been hidden.
Why the List class is showing errors?
Because you need to import the libraries first.
Yes!!! Thanks!!
This comment has been hidden.
volcano
is the correct answer to that testBut I've successfully passed this task and the correct answer was "climbing". Alright then, sorry.
This comment has been hidden.
You're using other values.
@_aslan17
No, your code returns
volcano
for the test in question.@supasebie, here are my calculations for the two words based on position in the alphabet:
This comment has been hidden.
Hi, I'm having trouble with the instructions "Given a string of words, you need to find the highest scoring word." ... do they mean actually "given an array of words"? What is a string of words?
A string containing words. See the sample tests. It's not an array of words, no.
This comment has been hidden.
Please read this: https://docs.codewars.com/training/troubleshooting and provide more info, language? Your code? Also read the post below, maybe it's the same problem.
This comment has been hidden.
Your code is doing out-of-bounds reads and thus has undefined behaviour. You are incrementing
string
until you read the NULL terminator in the inner loop and then incrementstring
again to check it in the outer loop --> out of bounds.Not a kata issue.
Hi all! I solve tasks in C. I ran into a problem while testing my code. As if in tests another line is substituted instead of the one that is displayed on the screen.
FixedTests for string: "a b" expected: "b" but got: "yz" Completed in 0.5829ms
RandomTests for string: "rqifoqs moxb" expected: "rqifoqs" but got: "qazeeqfjlqisgbgqammfpjlsn" Completed in 0.8304ms
Moreover, if you comment out all the tests and leave one, the program I wrote solves all the options.
That looks like you're using a global var and that's why your answers become wrong, the expected answers given the input is fine. Not a kata issue.
Try adding prints to your code, you'll see that your code is accessing string data beyond the input and reading in unrelated data.
Please use the 'issue' label for issues with the kata description or testing. Bugs in your code don't count.
Sorry for the tag 'issue'.
This comment has been hidden.
This comment has been hidden.
The expected answer for that test is "volcano", not "climbing". That's a problem in your code, not a kata issue.
Ohh really sorry, my bad. I read wrong error msg.
Wow I feel incredibly stupid after spending far too long on this one because I didn't simply follow the instructions :) Happy to see based on the comments that I am not the only one.
This comment has been hidden.
exatly!) thanks 🙏. I did not attach any importance to this. but on any latters it's+ 96))
Just curious if this kata has been updated lately? I seem to be able to return all of the correct strings in the test cases but I keep getting a key error with a random letter?
it looks something like this: KeyError: 'w'
Im pretty novice but I feel like Im at my wit's end trying to figure out what this error is complaining about.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This one is a little bit difficult.
C++ has a problem with these 2 cases
Expected: equal to "ya" Actual: "z"
and
pztepirngispcstpuzeapprtoatssuihthipspncrsthpino gotazepoptsttpinuueznostthgziaspzspnsisonzi
C++ tests are fine, your code is wrong. Not a kata issue.
This comment has been hidden.
Try with this input:
"a b c d e f g h i j k l m n o p q r s t u v w x ya z"
.ya
comesTried your code with that input here and in replit and in both I get
"z"
instead.in IDEA it works. The test check passed. But the final check does not pass and gives an error :randomTests expected:<> but was: null. I can't understand what could be the problem
C++ Getting this problem, after pushing "attempt" button: Edge_Cases: Expected: equal to "z" Actual: "" Another tests - OK!
I have the same issue? Have you found a solution?
why did the test add a space with the first character ?
Expected: {volcano} But was: { volcano}
It's not the test, it's your code that adds it.
You can see that test passes and in all others there is no space added.
Getting this error when trying to "attempt" solution in C# https://imgur.com/7O1AVD3
This comment has been hidden.
Very fun and challenging!
This comment has been hidden.
pleas example
Added an example about how to compute the score of a word.
Very nice kata and very fun to code
This comment has been hidden.
I had fun wiht this one, thanks!!
When testing code on CodeWars I get: "TypeError: Cannot read property '0' of undefined". At the same time, VSC does not see errors in my code and testing the function on various strings, I get the correct result.
How could I figure out what the test swears at?
Start by printing the input.
Here?
To debug your code. See what the input is, and then you can try the same input in VSC.
Sorry, but it seems I don't understand what you're talking about. (I'm very new to programming). I debug code by running it in VSC and looking in the terminal to see what different sections of code return. At the end of the story, I run the resulting function, offering it various variables (including from sample tests from the author of kata at CodeWars).
Please explain, what do you mean by "printing the input".
Add
console.log(x);
inside your function, make it the first line. See the output panel, the last line you see there is the input that makes your code fail. Once you know which input makes your code fail, you can analyze where in your code you're making a mistake.It's failing that one for instance.
Thank you very much!
OP solved it, closing
I'm looking for help (Python). I manage to create dictionary with key(first word) : value(of a word) but when the test is "aa b" and im looping through dict to find the highest value it points to second key for no reason. How do I pull the first key if values of the keys are the same?
in other words i have a problem with: "If two words score the same, return the word that appears earliest in the original string." I would be glad if someone would help me with implementation that functionality in my code
nvm
I'm passing the initial test but get an error in the sentence "what time are we climbing to the volcano". The word "climbing" is scoring higher than "volcano" based on the charCodeAt() unicode return value but the test expects "volcano" to be the returned word. Am I missing something on how we are supposed to be gathering a sum based on the word's total unicode value?
You're wrong, read the description again, not a kata issue.
gotcha, i think i understand now
In C i've get random tests passed, but only 1 line is breaking and i dont understand why...
same here.
" The expression (as strings) (res) == ("taxi") is false: actual=
taxi
expected=taxi
. "This is not an issue, this is a question ;-)
Your code is incorrect and you have to debug it I see several mistakes :
"a b"
malloc(256)
) without being sure it will be enough in the worst case scenariowords
is apointer to a char array of length len
you allocate the size of anarray of length word count of array of length len of char
also note that you forgot to add +1 for the nul terminatorYour approach is too complicated. You dont need to allocate a 2D array to store every word. You can solve this in only 1 pass of the input string, keeping track of the current longest word as you go
My code in my IDE is fine but in codewars I get an error, I don't know if I'm doing something wrong or it's from the page
That's a problem with your code, not a kata issue, read this: https://docs.codewars.com/training/troubleshooting
Don't use global vars, they keep their value between tests.
This comment has been hidden.
не пость код без спойлер флага
This comment has been hidden.
Hi - welcome to Codewars; you logic is basically correct but you are not "resetting" the value of
palabra
correctly. I recommend that you putprint(palabra)
after the linefor h in x:
and you will see that it is not behaving as it should.You just need to make a small modification based on the above observation and your code should work!
Because you don't reset
palabra
value properly. Read this too: https://docs.codewars.com/training/troubleshooting#post-discourseOh one small thing - it's much easier for people to assist you if you format your code properly; in future please read this doc:
https://docs.codewars.com/references/markdown/
which will tell you how to use the (easy) markdown format.
As a quick example - if you type:
```python
insert your code here - it will appear in a nice code block
```
it will be much easier to read.
This comment has been hidden.
Factor translation
Approved
I am having a problem I JS. It all goes smoothly. I always pass like ten random tests, and then one is incorrect. I counted the values of the strings, and my code returned the word with the highest value, and the test code wanted it to return the second largest value.
There is always one "sentence" like this, and the rest works as it should. I know that my code returns the right word because I counted the value of the phrase for multiple attempts by myself as well as logged out what the program counted.
As an example, there is one error massage I've got: "Testing for "krqrldygsavow arjmlluqyqlqr jsqsuntfthebi dlawvlcmovhaj": expected 'krqrldygsavow' to equal 'arjmlluqyqlqr'"
And this is what my program logged out as the values of the "words": "[ 211, 205, 179, 154 ]"
Not a kata issue, that's a problem with your code:
Check that again.
Edit: Thanks so much! I cannot believe I had such a dumb mistake. I am so sorry I bothered you.
This comment has been hidden.
This problem is not well described. I do not understand.
Update to Scala 3
Quick and dirty, just fixed the imports and privated a few vals/defs.
Approved, thanks
Wow. It took me 10 minutes to write code that (as I was thinking) solves the problem and 50 minutes to detect little trick I was missing.
first kata i've had to give up on.
Did you have problems with sorting by values and then by place in original string?
came back 5 months later and solved it, lol. I've actually improved... cool!
In Java the random test is failing because it expects the next to last highest scoring word.
Not true. Tested the control function against this test:
And the result is fine.
You're doing something wrong in your code:
Those scores are wrong.
This comment has been hidden.
Because:
But how are 1-26 and 97-122 not simply relative?
Because length can be different. Let's compare the result of
aa
andc
:You can spend less time than you think. For this, you should think again !!!
random test passed and basic test failed fffffuuuuuuu
It's now in your completed kata's list.
yes, i complete it after feuw time
Just to clarify, if letters are repeating in a single word from the string, then those should be counted as double or not?
ex. Bob => value of b*2?
It's
value of b + value of o + value of b
Right, it's clear now, Thanks for that!
D translation
approved, thanks
This comment has been hidden.
Try your code with this input:
"ppnelw bqqnap qahoqi yhwwal"
it returns'ppnelw'
instead of'yhwwal'
. You're doing some weird things in your code. Read this too: https://docs.codewars.com/training/troubleshooting#post-discourseThis comment has been hidden.
Tests must be broken or something: climbing is actually > volcano. On attempt it expects to return quotation marks as well: expected "this", actually got "this ... But i have seen this completed by more experienced programmer so it should be possible.
On C++.
The tests are fine, read the description again:
you right my bad !
Good question but the description is half baked, we have to look at the test cases to see what is going on!
This comment has been hidden.
Don't post solutions in Discourse.
I am sorry.
I just wanted to share my solution.
The place to share and comment solutions is the Solutions page, where all submitted solutions appear automatically.
This comment has been hidden.
Because your code doesn't do that.
This comment has been hidden.
Not an issue, please share your code in spoiler so we can help u!
This comment has been hidden.
I'm trying to solve these problems in Kotlin(begginer), and I'm unable to write solutions for the basic problems like these, any Blogs/Github repositories recommendation that I should follow?
Nobody will teach you how to think on problems solutions. You just have to get used to manipulating different data structures and applying this knowledge to solve problems. I was on your place. It took me two month to get comfortable with experimenting with code in order to solve such problems.
This comment has been hidden.
i'm not sure if it's in the scope of the kata. the description says:
I just added better messages to the C version and i saw that the reference solution cannot handle empty strings / strings consisting entirely of spaces
Though, there is some ambiguity, and one could argue that if there are no words, it is logical that the answer is empty. The description should state with clarity this and languages should be uniformized (either remove the possibility of an empty test, either make sure an empty test appears in a complete tests series.
i agree, the description should explain what "valid" means
COBOL translation.
Approved, thanks
Im kinda confused, not sure what im looking at here. I pass 18 basic tests and it fails here:
The expression (as strings) (res) == (sol_res) is false: actual=
uhgwaukeiexgqcfvwufqjfeuxmhyhcyqztlpnkivdeatwvdrpihnnahzmdwiviojbzyozfybzyvuhyawvhzxhfviyfgtoubesohqiehgrrpydpjywhusbdaz expected=
uhgwaukeiexgqcfvwufqjfeuxmhyhcyqztlpnkivdeatwvdrpihnnahzmdwiviojbzyozfybzyvuhyawvhzxhfviyfgtoubesohqiehgrrpydpjywhusbdazywglphewvlbcpiyfontrrbocyxuzpjmmetnipreksfbgcpbqrughvjjhvtvjrgkloxtddxcvrtathriykdvumtawavesrpceakxdxonnhdwdutrexlnydojeinlorcthme`.actual
is what your function returned;expected
is what it should have returned. The first part of the log just tells you your answer is incorrect.Thanks, totally forgot to allocate more memory.
Assert::That(highestScoringWord("what time are we climbing up the volcano"), Equals("volcano"));
Why does it want to return "volcano", when "climbing" is the highest scoring word? or am i wrong ?
This comment has been hidden.
This comment has been hidden.
Ya i'm getting the same thing..
That is my problem also. If letters in alphabet map to sequential numbers where a=1 ... z=24 climbing has more points when all the letters or point values are added together. I must be missing something because people are passing this.
@luukaunder: a = 1 ... z = 26, you should check that. And you're not using those values in your code.
multiverse
My NASM solution passes Sample and Basic tests, but fails with "Signal code: 11" on Random_Tests_1000_strings_of_65635_char
If I understand correctly these tests run various 65635-long strings 1000 times? How could I possibly test something like this by myself?
In general it's not possible to run random tests locally since they are not available until you solve the kata. Ideally tests logs should be more explicit and give you the input your code fails on. In this kata, NASM tests seem identical to C's tests (on Codewars, afaik NASM tests are always written in C), so if you solved them in the latter you may be able to do something useful locally.
OP solved it, closing
This comment has been hidden.
Actually volcano = 754 < climbing = 873 what is wrong here!!!????
Something is wrong with your code. volcano = 82 and climbing = 69.
Use that, it's in the instructions.
but still, 7+5+4 is less than 8+7+3. again, what's wrong here?
Come one... How do you find
climbing = 8+7+3
orvolcano = 7+5+4
?This comment has been hidden.
This comment has been hidden.
Same issue, I really don't see what I may be missing. Can someone help please? "Each letter of a word scores points according to its position in the alphabet: a = 1, b = 2, c = 3 etc.".
is not helpful because according to this instruction Climbing should be of higher value, in no small part because it has more letters, than volcano
Me wondering when I can finally tackle this 6 Kyu questions (T-T)
Hi guys,
I am having difficulty with completing these problems, and many of them are basic. What websites can I use to hone my skillset and come back to Code Wars? I have already gone through W3 schools.
What language?
python
I would advice you to solve a great number of very easy katas (8 kyu + 7 kyu). If you find one difficult, it's no use to spend a lot of time on it, you may come back to it once you are more comfortable with its requisite. By repeating the task of solving basic katas I bet you will really improve your skills and become more comfortable with many basic features. At least that worked for me. There may be other very good resources online, but I don't know them.
Thanks akar. I appreciate your feedback :).
This comment has been hidden.
this allocates only one byte. you need to allocate the length of your string, plus one byte for the nul terminator
This comment has been hidden.
This comment has been hidden.
Different node versions, not a kata issue. Sort wasn't always stable in javascript.
I am having a slight issue, I am using powershell and I have a working function but when I test it in the browser it is adding a leading space. The space doesnt appear when I test it outside the browser, and I verified by checking the length of the return string, I also tried adding trims in a few different places just to force it but it isnt catching it.
Your code not doing what you expect is not a kata issue. Please read this: https://docs.codewars.com/training/troubleshooting/
Are issues only kata specific? I guess this is more towards codewars in general? If the the in-browser ide acts differently compared to a desktop ide...like adding spaces to a return value that was not added when compiled in vscode, what would that be classified as?
Spaces don't appear out of nowhere, and compilers on CW aren't special either. Based on that, you'll have to make conclusions on your own.
I'd classify that as programmer's mistake, but that's just me. Of course, if you were able to reproduce this: by showing the input, your output, expected output, and the reason it's wrong - then it could become an actual issue. Given that powershell isn't that that popular, it's certainly possible, but there has to be proof and not just words.
This comment has been hidden.
Do these replies actually notify anyone?
Your solution works for me if I replace line 5 with following:
$bestWord = ''
I do not know PowerShell too well so I do not know whether it's a problem with your solution and some kind of uninitialized variable, or with Codewars setup.
That is explained in my response from 5 months ago, and the issue is the space is added in codewars but not in powershell ise as shown in the image in the same response?
What i mean is that I do not know exactly, but I really doubt that it's an issue with runner or Codewars environment. If it were Codewars fault, then the space would be added always, and not only when the variable is uninitlized, right? I was able to fix your solution just by adding three characters to it. I added
= ""
and it worked. Having to choose between some mysterious bug in Codewars and an error caused by an uninitialized variable, I'd bet on the latter, or maybe some other thing I dont understand yet, like some syntax clash or something.I checked some other solutions, and checked reference solution and checked your solution after my change, all of them work. Currently the only problem is with your solution, which contains some suspicious syntactic construct i dont exactly understand (because I'm too noob with Powershell), but seems to be a culprit and cause of your problems.
I thought it would be an issue if codewars did something the language's native environment did not do, which is why I flagged it. Restating the solution I posted 5 months ago and not addressing the difference I pointed out between the environments makes it seem like we are discussing different things. I am not asking for assistance with a solution, I am pointing out that codewars added a leading space to an unitilized variable where powershell ise did not.
how to solve a problem without using a dictionary?
This comment has been hidden.
This comment has been hidden.
Please don't spoil the kata. Users are supposed to solve a kata by themselves, not by looking at the discourse page. I marked both answers to this post with a spoiler flag.
std::sort
gives me different results for MSVC and Clang 8 Just because of this I have a failed test (Edge_Cases)Expected: equal to "ya" Actual: "z"
Clang8 = [z ya x w v u t s r q p o n m l k j i h g f e d c b a] MSVC = [ya z x w v u t s r q p o n m l k j i h g f e d c b a]
As of now CW uses Clang8 as the C++ compiler, and you have to write code which would work correctly with Clang8 regardless of what tools you're using locally. Also, it looks like you're trying to sort the array in reverse order - if my guess is correct, then it seems that MSVC is wrong because
"z" > "ya"
. Either way not a kata issue."Assert::That(highestScoringWord("what time are we climbing up the volcano"), Equals("volcano"));" this test passes in VSCode for me but fails on codewars. Using C++ and I don't know why this is happening.
my code works fine in IDEA, but here i pass only 2 from 3 tests, the 3rd one give me :
java.util.NoSuchElementException at java.base/java.util.Scanner.throwFor(Scanner.java:937) at java.base/java.util.Scanner.next(Scanner.java:1478) at Kata.high(Kata.java:12) at SolutionTest.randomTests(SolutionTest.java:42) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:40) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:80) at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:71) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) at io.qualified.junit5.RunTests.main(RunTests.java:25)
Can someone help me?
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Gotcha. Thanks!
The Sample Tests that run with the "Test" button in Golang are not working. I discovered that these tests just expect "aaa" in all of the cases
It is true, one can see by printing the arguments that basic tests always provide "aaa b". Something is broken here.
Fixed (maybe there was a better way to do it but it works).
This comment has been hidden.
A problem with your code is not an
ISSUE
with the kata! And yeah your code should handle random input shouldn't it? Maybe copy the input it fails for and debug it?This comment has been hidden.
This comment has been hidden.
Thank you! That was reallly helpful!
God please! Thank you!
Thank you! This helped me alot
Thanks, I got it because I did it by hand and got different results than using charCodeAt() and didn't understand because I just kept thinking "what is the difference, every letter is just +96" but when you break it down I understand the math better
This comment has been hidden.
never mind, just figured it out.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
That's not what the error says, it says:
Meaning your code returned
'up'
when it should have returned'taxi'
instead.This comment has been hidden.
That's why. If you don't use those values, then "aa" would have a higher score than "d" for instance.
I see, thank you!
This comment has been hidden.
Your code also fails in repl.it so you'll have to debug your code. Add some print statements to see where it is failing.
BTW how do I change my profile pic or is that detirmined by the web site?
iirc if you link your github it takes the picture from that account.
This comment has been hidden.
Honestly, I think that is self explanatory. In a football/soccer match, the highest scoring team is the team with the highest sum of individual goals. A goal is 1 point, so there is no other way to compare scores. How else would you interpret the question?
While that is very natural to sport games, there is another way that is more natural to words. 'bath' is smaller than 'cat' using letter order but larger using only the sum. The instructions don't specify which method to use.
I can't follow your logic; "scores" and "words" have no natural connection. That said, maybe your difficulty lies in the term "order", which you introduced but is not present in the description. "Bath" is 'smaller' than "Cat" only if you consider lexicographic ordering, which is not asked for.
Isn't that my point? words and scores have nothing to do with each other and these are words yet you compare them to scores.
I agree! Adding 'Score of a word is sum of scores of its letters' would definitely help.
good kata .not so easy as at first glance
No random tests in Rust
Added.
cool kata :))
Coffeescript translation
Julia translation
Approved, thanks. Why no triplet? :)
cuz Crystal was already done before :)
BTW you missed some of these Office III, Office IV, Office VI, Holiday VII
Thanks for that - very easy to miss some on here! All should be approved now
Excellent Kata. Thank you for your hardwork.
thank you
This comment has been hidden.
Looked at this two months ago and couldn't solve. Gave it some time before I came back and it wasn't too bad. As a beginner, it is nice to see progress. Great Kata!
Nice work, glad it helped
Functional solution in scala using recursion is not working with test runtime. In normal runtime returns de correct value. Maybe its a problem with scalatest.
I am beginner in programming and this might be a very easy kata but got to learn alot from it.
Glad it helped
This comment has been hidden.
First two tests pass but then:
Testing for 'byevrg dxukwzd jknpxwifj'
Failed asserting that two strings are equal. Expected: 'jknpxwifj' Actual : 'dxukwzd'
But...
Array ( [byevrg] => 76 [dxukwzd] => 109 [jknpxwifj] => 107 )
I'm getting the correct values for all the other test cases
Oh my gosh....
I exluded the letter 'n' in my alphabet string -_-....
Solved.
This comment has been hidden.
That is because when you use the ascii value (i.e., starting from 97+) the length of the word plays a bigger role than it should. Every extra letter would be a minimal addition of 97 instead of a minimal addition of 1. For instance, it would cause 'aaaa' (
4*97=388
) to score higher than 'zzz' (3*122=366
). Of course, when you use the actual alphabet index of the letters, 'aaaa' (4*1=4
) would score way lower than 'zzz' (3*26=78
)."expected:<[]brrtnmdttqmutezxgc> but was:<[rphbnsryttrfj]brrtnmdttqmutezxgc>"
that is, parentheses and other characters are also considered delimiters?
That's JUnit telling you where two strings are different, the brackets aren't part of the strings.
Some random tests may sometimes fail your solution. But sometimes almost perfect code will pass the random tests ^^
This comment has been hidden.
Yes.
No very helpful.... I submitted a few times and it passed finally... Don't see my mistake and 'Yes' isnt very condusive.
Your code is wrong, it's counting
a
as 0,b
as 1, etc.Edit: Nevermind, I missed the part where I return the first string if equal and shifted my array.... works now (DERP)
This comment has been hidden.
That's not a kata issue. That's issue with your code (question).
There's your feedback. For 2nd sample test, you're returning climbing, and not volcano. You're calculating score when there's a space, what if there isn't one at the end?
My bad
That's not php, I mean Spiro's code.
This comment has been hidden.
Not a kata issue, you forgot
using System;
This comment has been hidden.
I just checked and kata works OK in C. You probably have some error in your solution, so it's not a kata issue.
Maybe something here will be helpful: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution#c-c-signal-6---sigabrt
You're right. That github page was useful. I didn't allocate enough memory for the null byte.
How on earth volcano has more points than climbing ?
Because:
Can you please tell me how does one calculate the score of the word? What does the score of a word mean? I know that "Each letter of a word scores points according to its position in the ALPHABET" but how does the score add up?
Because the description and the test results don't match.
You add them all up. The description and the expected values are ok and match.
Yeah, I noticed the random tests had some errors. I manually added up the expected and it wasnt higher than my actual....
This comment has been hidden.
Expected: equal to taxi Actual: taxi
Expected: equal to ab Actual: ab
Expected: equal to facuesatasokbksatrttiem Actual: facuesatasokbksatrttiem
I was confused...
How did you solve this? I have the same..
This comment has been hidden.
apart from several smaller bugs (
sum
is not initialized with zeroes,string
is missing 1 byte for the nul-terminator), there is a more fundamental flaw in your approach: you split the strink into separate chunks withstrtok()
, and return one of those substrings. this means the returned pointer cannot be passed tofree()
, because it is no longer the original pointer that was allocated. this is why the code crashes.is undefined behavior, you must pass the original pointer
This comment has been hidden.
unclear issue, and 1,000+ Go completions
This comment has been hidden.
It matters when the strings have different size.
See?
I see, interesting.
This comment has been hidden.
Provide your code if you want more help, with only that we can't help you. Use markdown formatting and mark your post as having spoiler content.
This comment has been hidden.
You're using a global var, it keeps its value between tests.
ah ok thank you! It works now.
Same thing happened to me. How did you solve it?
I put count[] inside my function.
The edge case wants me to return multiple words which is impossible in this task. How do I pass the edge test?
Which language are you referring to?
C++. And it wants me to return "equal to z". That does not make any sense.
No, that's not what it expects, you're misunderstanding the error message, "equal to " isn't part of the expected result. I know it can be confusing, but it is like that and you can see it returning a fixed string in the sample tests.
So what is it expecting? And can I see the input for that case? Because otherwise how am I supposed to find the error?
In your case?
"z"
And you can always print the input yourself to see what it is. Another thing about C++ testing framework, it hides trailing spaces, so be aware of that.Ok thanks. That already helped. However the edge cases are "z" and " z". And noch I dont know which of them fails.
Also when I try it in Visual Studio it works just fine.
Try using this:
std::cout << "* Debug *" << "'" << str << "'" << std::endl;
when the tests pass, the input will show one after the other, the last one above the error message is the one your code is failing.Thank you for your answer. I already solved it. The test case wasnt "z" and " z" it was "z " and " z". Confusing. But now I got it.
What's wrong with C random tests? why I'm getting TIME OUT :(
Hi @EmperorMigx, over 400 coders have solved it in C ... sorry, but don't just assume the kata is wrong. Your code times out because it's inefficient or has an infinite loop.
yeah true 400 coders but I think it's a little bit unfair I tried to solve it in another language and it passed. Maybe test cases in C is harder? or has more random tests. I still couldn't figure it out I've revised my code 3 times in C. I'm just wondering. Thanks for noticing me.
Yes of course languages are different (to me, that's kinda the whole point of resoving a kata in multiple languages) but there's certainly nothing unfair about that.
okay thanks for your response @rowcased maybe I need more training and good algorithms. :D
@rowcased I've learned a valuable lesson. My codes are working super fine until I saw what caused me the time out. It is the reoccurence of strlen I have learned that the strlen condition reiterates again the whole length of the array. Waaaaaaaah. So next time I'll definitely store it in a variable.
[JS]
[ 367, 346, 370, 314 ] requires a word with score == 367 , not 370... 103 tests passed and only one fails.
This one was a bit tough. I needed to do a lot more googling than I usually do for a 6 kyu.
This comment has been hidden.
taxi
is the correct answer (it scores higher thanubud
). you have to calculate their scores differently.Thanks I thought its only concatination of numbers. :)
This comment has been hidden.
Did anyone know stephane777's reply about the volcano and climbing test? I couldn't find it.
Just scroll down???
This comment has been hidden.
Take a close look at your alphabet.
your alphabet has a
'c'
instead of'g'
Hi,
when pressing "attempt" I get a pass but stderr says
main.cpp:75:5: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers] const int getScore() const { return score; } ^~~~~~ main.cpp:76:5: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers] const bool isScoreGreaterThan(const TheWord &w) const { return score > w.getScore(); }
Guess this stderr output prevents from submitting the solution, which passes all tests ?
Both stderr functions are outside my scope. How can I fix that?
language C++ Clang 8 C++17
Actually, when I switch to C++14 the server stops at 12s execution C++17 requires 4s
This comment has been hidden.
Which language?
Oops. Javascript.
This comment has been hidden.
Fixed, and there were a couple of console.log there (both in the control function and in the author's solution) I commented both.
This comment has been hidden.
you are life saver!
Thank you!
This comment has been hidden.
x
andy
are uninitialized whereas they should be initialized to0
malloc()
, you are missing 1 byte for the nul-terminatoryour code passes when these are fixed.
This comment has been hidden.
Not a kata issue,
a = 1
, nota = 0
That, I did not see. Thanks alot @Chrono79.
Golang . -Could you try to give some examples of what is expected to do.
Expected : ebiwtainje //1058 appears first in the text, yet so "suxlvhzvlo" is supposed to be //the correct one to equal : suxlvhzvlo //1058
If I set suxlvhzvlo to be the selected word then in other tests, i get the same issue but the other way around. Expected : olserjevmr to equal : xokzqwcqyl Even tho in this case xokzqwcqyl appears before olserjevmr
"ofpjeypaeb jztxtsivsk"
why is jztxtsivsk the correct option if both have the same value. However ofpjeypaeb appears first in the string. This is an example of the failed tests.
They don't have the same value, read the instructions (or what FArekkusu's post) again.
The test are buggy.
Hi, I am using C++ for the coding challenge and I still get a fault with the advanced tests, although I made one of the advanced tests myself in the challenge were it passes. Expected: equal to z Actual: ya So I made a test with these words: Assert::That(highestScoringWord("abc f e d z ya"), Equals("z")); That one is successful. But in the advanced tests it still fails???
You're mixing some tests there, there is no test like that in the Edge Tests.
Well no but similar you have a string with words giving the same score like ya and z. The word first mentioned in the string has to be first in order. So as in the above Assert you have to print z. Which it does. But in the edge test I have a similar string with z being in an earlier position in the string than "ya", which has the same score as "z". This test fails, but I don't know why
The test that expects
"ya"
has"z"
too, but"ya"
is before and therefore is the right expected answer. Try using this:std::cout << "* Debug " << "'" << str << "'" << std::endl;
when the tests pass, the input will show one after the other, the last one above the error message is the one your code is failing.Go translation awaiting approval.
Approved, thanks
Expected: equal to ya Actual: atsa Why I cannot pass this test? "ya" is 25 + 1 = 26 "atsa" is 1 + 20 + 19 +1 = 41 please, help me)
If that test is one of the Edge cases in C++, then it's a problem with your code, because the input doesn't contain
'atsa'
. Print the input and check what it is. Also, when reporting an issue, state the language you're having the problem with.Never answered, closing.
There's a test with an empty string in Rust. I wouldn't consider words of length 0 valid by default.
Fixed for all languages
[ C ] Hi! I can't figure out why "volcano" is higher score than "climbing". I got the following result highestScoringWord("what time are we climbing up the volcano"); : "volcano" scores = 754 "climbing" scores = 837 So "climbing" should be the highest scores but the test expected is "volcano".
Halp :v
Read stephane777's post below, it's been explained several times before. Tests are ok. You're not following the instructions.
oooh! I see :v Thanks.
The same doubt for me ...anyone explain this if you know the answer
Because of number of letters. If you just sum ASCII numbers for each letter in a word "aa", you'll get "97 + 97" = "194", in the same time for word "w" you'll get "119", i.e. "194" > "119". It's a wrong answer. According to the task, you should consider letters position in the alphabet: a = 1, b = 2, c = 3 etc. : so you supposed to get for "aa" -> "1 + 1" ="2", and for "w" -> "23". "23" > "2". The correct answer is "w".
[Python3] The question states that the input will be lower case and valid input, however the randomly generated tests included upper case characters.
No, it can't generate capital letters. It uses a list with all lowercase letters to generate the random words.
I passed both the example_tests and the random_tests
For whatever reason I failed the Edge_cases it says: Expected: equal to z Actual: z
I'm not understanding - seems like it should be correct to me, anyone have this problem too?
Check MarinaS's post below. It seems to be the same case.
Thanks! Got it
This comment has been hidden.
After passing all the tests and submitting the code in Python, I get the information that my solution had been witheld and that I haven't completed the task.
Try again until it works.
When the scores are equal I return the "climbing" but the answer is "volcano" in python all equal tests are wrong.Can you handle this problem?
Read stephane777's post below, it's been explained several times before. Tests are ok.
I can´t figure it what is wrong with my program beacause it runs successfully the sampleTests but randomTests it breaks. I´m using java. Any way to know what the random tests are? The error is: java.lang.NullPointerException at Kata.high(Kata.java:27) at SolutionTest.randomTests(SolutionTest.java:33) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:40) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:80) at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:71) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) at io.qualified.junit5.RunTests.main(RunTests.java:25)
Thanks
Hard to say without seeing your code, but you seem to have an issue on line 27. What are you doing there?
and to know the input:
System.out.println(...);
This comment has been hidden.
Are there punctuation marks in the samples?
This comment has been hidden.
kata hint != kata suggestion
At least in Python: missing fixed tests with multiple words with equal scores and such random tests are often not generated. The following tests should be added:
Note that some incorrect solutions using
dict
s may randomly pass some of these tests due to hash function randomization; the subset of the 4 tests seems to provide acceptable reliability. These tests should also fix the issue opened below, but I'd suggest that a distinct test related to that issue should be added first.Added the suggested tests to 10 (more or less) of the available languages, I'll finish adding them some other time.
Added for all languages
This comment has been hidden.
It is an error on your part. The python tests are ok.
This comment has been hidden.
Have you printed the input? Depending on Python version, the keys of a dictionary aren't sorted the way you created it.
You're spot on.
After retesting I found the dict reordering to be the issue.
Thanks
This comment has been hidden.
My code runs fine on my compiler, when i compiled on this app it says this error on stacktrace in random test java.util.NoSuchElementException at java.base/java.util.ArrayList$Itr.next(ArrayList.java:999) at java.base/java.util.Collections.max(Collections.java:672) at Kata.high(Kata.java:30) at SolutionTest.randomTests(SolutionTest.java:33) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) and more......................................
This comment has been hidden.
The random tests for c++ are broken. The test will give as expected a string composed of a bunch of words glued together instead of an actual word in the string. Example: Input string: "stteie r oibtraeoeet i hoaseacrzake kaaoasutoc katidsb pepf uusprtorh rcietsp nps euc ootzpginasbnebkrd se bnhleay kiahpmaaprtkayaa" Expected: "bnhleaykiahpmaaprtkayaa"
The C++ version is working perfectly fine. Your code must be causing this.
I'm sorry but how can my code alter what the tests expects?
Edit: apparently by using const cast, now it works, thanks
mutation of the input? (or anything similar in C++)
Hello, I have all the tests passing except the last one which does not give any info if the expected result: The expression (as strings) (res) == (sol_res) is false.
This case has already been posted but I still don't understand why 754 is greater than 837 for the test below. It is the only test that didn't pass. Test.assertEquals(high('what time are we climbing up the volcano'), 'volcano'); c:99 l:108 i:105 m:109 b:98 i:105 n:110 g:103 total: 837
v:118 o:111 l:108 c:99 a:97 n:110 o:111 total: 754
The question is why 754 is greater than 837 ?
;)
thanks, it passed this test case now!
This comment has been hidden.
It said position of the alphabet not the ASCII value of the alphabet.
This comment has been hidden.
This comment has been hidden.
Next time mark your post as having spoiler content.
You're not using that score.
i gave ascii values as score instead, won't that work? do the scores add up (abc = 6) or (abc = 123)? how can my code pass more than half of the tests and fail a few?
Because of that. The score for
abc
as the instructions say should be 6.@Chrono79 thanks man
Throwing Error when comparing climbing= 837 to volcano= 754. Says Volcano is higher please correct
The test is ok, read the instructions again and use the proper value for each letter.
All the tests pass, only 1 base swears. The expression (as strings) (res) == ("z") is false. I tested as best I could with 'z', everything is correct. Check, please.
I don't do C, but maybe there is a problem with spaces?
Yes, you are right, there was a problem when 1 space was after a letter and the line ended with this.
This comment has been hidden.
Because you are using character code rather than alphabetical position for scoring. Check the description. There are many other comments about this below.
This comment has been hidden.
That.
The description is not clear enough. "You need to return the highest scoring word as a string." The score of the word "abc" could be "123" OR "6" (1+2+3) as it appeared afterwards.
The test cases didnt tip you off?
I absolutely agree with essenov. "You need to return the highest scoring word as a string." - can the author elaborate more on how to decide the string has the highest scoring word? "a = 1, b = 2, c = 3 etc" does not help at all. Needs examples with detailed explanation - I found out that most of the katas do have these problems to make the questions always so ambiguous!
I pass base and random tests, but i get an error for the edge_cases test:
Expected: equal to z Actual: z
So, I don't get why z is not z ^__^
Your code is failing some test where the input has spaces. To get the input value:
std::cout << "* Debug *" << str << "*" <<std::endl;
Thank you! :)
It would be good to have a test where there are two words with the same raking. For example I have adjusted one of the existing inputs to the following "what time are we climbing up the volcamp volcano"
If I understood the requirements correctly, then "volcamp" and "volcano" would have the same ranking and thus "volcamp" should be selected, because it comes first in the input.
I believe that current top voted solution would fail above test.
No, they wouldn't.
This comment has been hidden.
you increment
i
both in the loop construct and in the loop body, which results in the loop skipping past the nul terminator of the string. also, you do not allocate the right amount of memory (why always10
bytes ?) and you do not nul terminate the returned string eitherWhen making the attempt, the 'sampleTests' are executed successfully but the 'randomTests' (of which I have no reference) get an error "expected: <[mpvyiqwtojl]> but was: <[weycwlmauoit]>". What is this about?
It means you failed the random tests, that isn't an issue.
There are the both sample tests and then the final tests, you have to pass both.
If the output doesn't show the test you fail, just print out the function arguments.
Thank you! Showing on screen the content of the Strings of the 'randomTest' I was able to find out where I was making the mistake.
This comment has been hidden.
2nd line of the description.
When I ran the program it fails for "a" and "aa b". But when I checked the output in printf, values are "a" and "aa". Then why tests are failing.
FArekkusu(1 kyu)27 minutes ago
mumararshaikh(8 kyu)11 minutes ago1 edit But issue happen only when the answer is a like "aaa b", "aa b", "a". But it passed for "b aa". @FArekkusu Can you elaborate why printf function act funny.
This is NOT a kata issue. When your solution can't pass the tests
printf
starts outputting text in an "unexpected" way. Maybe your code is working correctly in these cases, but it's still wrong.When I ran the program it fails for "a" and "aa b". But when I checked the output in printf, values are "a" and "aa". Then why tests are failing.
printf
may act funny from time to time making it even harder to understand what's happening.But issue happen only when the answer is a like "aaa b", "aa b", "a". But it passed for "b aa". @FArekkusu Can you elaborate why printf function act funny.
Hi The random test cases are broken. expected: volcano actual: climbing correct : climbing
Please read one of the several other posts (go see jamielthompson29 post below for instance) wrongly claiming that and their answers before creating a new post saying that again. The test is ok.
This puzzled me at first. I then read the instructions carefully. I had made a mistaken assumption about plain 'ord' values. The test is, indeed, valid.
if(yourFinalResault =='climbing') { return 'volcano';} else {return yourFinalResault;}
Solves the problem :D
lmao 200 iq right here
All, who cannot passed random tests, try to pass this tests:
Assert::That(highestScoringWord("equal to z""), Equals("equal")); Assert::That(highestScoringWord(" equal to z"), Equals("equal"));
It was help me
Thanks!! It was driving me crazy ahah
Not a suggestion
i allways cannot passed in ramdon tests. and i actually do not know what is problem? remind me that "The expression (as strings) (res) == (sol_res) is false." please help.
Hi.
I think randomTest are broken.
i.e.: <expected:<[]> but was:<[yfyulrsywxymicxctognypg]> <expected:<[]> but was:<[vxwxqxdrgpnzcpimpqtygxgv]>
Hi,
Seems you're doing java. more than 1300 completions in java, so I'd rather guess the problem is on your side.
Seems too that you're "rather new" to cw, so here are some general guidelines about the comments:
Issue
: problem in the kata itself (description, wrong tests, wrong internal solution...)Suggestions
: well, I guess that part is clearQuestion
anything else that is related to you having a problem solving a kata -> that's you, currently.When you post issues:
When you post a question: well, most of the above apply too x)
When you post code, use proper github markdown, so that it's readable.
And for your current problem, did you check what are the inputs/outputs to try to debug your code on your own? Especially, check that you don't use any global/static variable that could mess up your code, if you recieve a string composed only from whitespaces (unlikely case, but... That's a beginning).
Cheers
This comment has been hidden.
Hmm, if I take -96 on my ascii value my tests pass. I don't get this at all, what's happening with these tests? I guess its not an issue then as the scoring becomes correct.
This comment has been hidden.
This comment has been hidden.
You can check in the solutions tab
I'm not asking for the answers. Just getting a consensus on if anyone else used my method.
I just mean you can see if people used your method yourself - all the solutions are shown
I hear ya, thanks.
The test in Ruby are all messed up. For example:
Expected: "tvuqkuur", instead got: "noxxrexue" Log "Testing for 'oewkkhwiz jblrxp afgdjuo jqzddoqf lnswna sidbmtxneqj nvlh goqculuiuon ovbnea znj ii mzzktfqvgx yoiqszkwvm wzumec'" "Expecting 'yoiqszkwvm'"
It says it expects two different words....
Are you sure you're not mixing the expected values from one test with the log of the next one?
All languages should have tests like
Test.assert_equals(high("aaa b"), "aaa")
to check that character scores are indeeda=1, b=2, ...
(and nota=0, b=1, ...
).Added for all languages
Hello! It would be nice to have the alphabet included in the kata, or to have a comment like "I will usee the USA alphabet". I'm from Uruguay and I included the "ñ" letter on alphabet, so a lot of tests crashes. When I realize the problem I corrected it , but There werent mistakes on the code, only in the alphabet variable
Is there a way in python where you can devise a coding system - where you set a series of variables to be worth a certain amount?
The statement of this kata needs to be a bit more clear about what the score for a word means. i.e Score for a word is the sum of points of its alphabets. Perhaps an example will help.
This comment has been hidden.
You have no
- 96
.Hi FArekkusu, it doesn't matter because 98 - 96 > 97 - 96 or 196 - 96 === 196 - 96.
Add
Test.assertEquals(high("aa, z"), "z")
to the sample tests, and tell me why your code doesn't pass it.It does matter when the strings haven't the same length.
Ty guys but I still don't get the problem with 1 == 1 === 1001 == 1001 I saw the top solution and there a = 0, b = 1 istead of a = 1, b = 2
Let's use the test FArekkusu gave you:
Test.assertEquals(high("aa, z"), "z")
First case (a: 1, z: 26), highest scoring word is "z" as expected. Second case (a: 1001, z: 1026) highest scoring word is "aa".
Do you see the difference now?
When the scores of two words are the same, sometimes there will be errors. It always return another one.
Hi, I made a NASM translation for this Kata.
Approved
Scala random tests sometimes crash:
Thanks for inform!
Fixed in kummited
closing
Concerning the Scala translation, I have been able to pass an attempt with a = 0, b = 1, ... before finding out it was a = 1, b = 2, ...
Maybe a fixed test such as
"zykqgp bjnb yrmjt i ucuzsw pdvfdrppn f dejctyhcdv"
could help fix thatThanks for the suggestion.
Update kummited
:)
Scala Translation
Please review! thks!!
Approved
Kotlin Translation
Please, review and approve/comment
There is no approval link... no idea why
Approved
This comment has been hidden.
This comment has been hidden.
It would produce inaccurate scoring per word, but as all scores will be affected the relative scoring remains correct, as does the solution.
Actually not, you should add a test like
high("aaa b")
for all languages to test ifa
value is 1 or 0.This comment has been hidden.
JS test expecting 'volcano' instead of 'climbing' is not correct
It is correct, read one of the many responses (look down for jamielthompson29's post) explaining it.
Please fix part of the kata's description:
Each letter of a word scores points according to it's position in the alphabet: a = 1, b = 2, c = 3 etc.
"it's" -> "its"
As a number of comments below, I have experienced a problem with a random test, although basic tests were successfully passed. I used R to solve the program and received: Test Failed invalid 'type' (list) of argument 1: replicate(95, { s <- character() for (i in seq_len(sample(5:24, 1))) s <- paste(s, paste(sample(letters, sample(10, 1)), collapse = ""), collapse = " ") expect_equal(high(s), pineapple_express(s)) }) at tests.R:20 2: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify) 3: lapply(X = X, FUN = FUN, ...) 4: FUN(X[[i]], ...) 5: expect_equal(high(s), pineapple_express(s)) at tests.R:29 6: quasi_label(enquo(object), label) 7: eval_bare(get_expr(quo), get_env(quo)) 8: high(s)
Any ideas why that happen? I also intentionally converted my output field into a single string.
This comment has been hidden.
Where are you changing the value of
mws
? Function's name is wrong too.Thanks, copied old code.
PHP translation please check and approve :-)
Approved :)
resolving suggestion