7 kyu
Caffeine Script
3,509 of 9,847mcclaskc
Loading description...
Fundamentals
Strings
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.
This comment has been hidden.
expect(caffeineBuzz(4)).to.equal("mocha_missing!")? 4%4=0 then expect Coffee
// This JavaScript sample tests may help you getting started:
const { expect } = require("chai");
describe('Example tests', () => {
it("returns correct values", () => {
});
});
Javascript needs random tests so that This doesn't work.
This comment has been hidden.
I spent too much time on this one. xD
Ruby 3.0 should be enabled.
fixed
No sample tests and random tests in
This Kata asks for something different than what it tests for.
Not fun :(
I get the right result on my console, but the test doesn't go through...
https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution#my-machine
thank you for the link! i fixed my code and now it works perfectly :D
disappointing and poorly written deciphering english rather than solving katas
Yeah, I was having a hard time understanding it too. I then updated the description, let me know if it's easier to understand.
test wasn't working. Response received but no data was written to STDOUT or STDERR.
But it did let me attempt to solve and those tests worked.
Python version should use snake_case.
No python sample test cases
added
I am having a problem with the tests in JavaScript. I keep receiving an error that no tests were provided preventing solution submission...any insight on why the tests below are not working?
At the moment there are server-problems at codewars for hours. Try again later.
Server error. I've tweeted them and sent an email as well.
Just submitted a solution (other kata, not this one), so some things work again, but the kata stays locked so not everything is ok;-)... perhaps on a good way...
@doutatsu: Great! @smile: I've had the same problem. By submitting again I can see the other solutions.
Did it three times now, but jumps directly to the "unlock site", so can't see other solutions... It's this one https://www.codewars.com/kata/sum-squares-of-numbers-in-list-that-may-contain-more-lists Perhaps my solution appears there, but i can't see any solution (the code is only in my "Past Solutions" list). But it's not so important, really easy kata, so only one line;-)...
okay, thanks @Steffen, @doutatsu and @smile. I'll try it again tomorrow
Hey guys, can someone help me with the "If the integer is one of the above and is even, add "Script" to the end of the string" part ? Don't really understand it.
If the integer is divisible by 3, return "Java" If the integer is divisible by 3 AND IS EVEN, return "JavaScript"
If the integer is divisible by 3 and 4, return "Coffee" If the integer is divisible by 3 and 4 AND IS EVEN, return "CoffeScript"
For each case, check if divisibility by 3 works then check if it is even, giving two strings separately that needs to be returned.
I have updated the description, let me know if it's easier to understand.
I have the following test cases that all pass in java
assertEquals("mocha_missing",CaffeineBuzz.caffeineBuzz(1)); assertEquals("JavaScript",CaffeineBuzz.caffeineBuzz(6)); assertEquals("CoffeeScript",CaffeineBuzz.caffeineBuzz(12)); assertEquals("CoffeeScript",CaffeineBuzz.caffeineBuzz(-12));
however when I go to submit I get the following in the output
test_caffeineBuzz(CaffeineBuzz_Test) expected: but was:
Any ideas on what to do?
EDIT: I added assertEquals("mocha_missing",CaffeineBuzz.caffeineBuzz(13)); and assertEquals("mocha_missing",CaffeineBuzz.caffeineBuzz(67)); both tests return true
NO code specification, closing, read this
This comment has been hidden.
I have problem too doing in Java. I thought i made mistake in my code and i unlocked solution. Then i copy/paste several solutions too see how i have to do but i get error massage again. What do i have to type in "Your Test Cases:"? I entered: 1 3 6 12
You dont need to type anything in the test cases. Those are for testing. There are test cases written for when you submit it.
I ocmpleted this challenge with no effort, using Java. So I know it's not broken.
Not an issue.
I keep getting the error: Expected: mocha_missing!, instead got: mocha_missing!Script when all the tests pass.. Test.assertEquals("JavaScript", caffeineBuzz(6)); Test.assertEquals("mocha_missing!", caffeineBuzz(67)); Test.assertEquals("Java", caffeineBuzz(3)); Test.assertEquals("mocha_missing!", caffeineBuzz(1)); Test.assertEquals("CoffeeScript", caffeineBuzz(12));
I've passed this in Python but it won't go through for JS
Seems this kata is missing its test case.
"Where test case go?"
You could write one. Or if you're good enough, don't use the test case, just submit once your code is logically correct.
Java needs some example tests ☺.
I'm having "Expected: CoffeeScript, instead got: JavaScript".
Any ideas ?
Could have included random tests if test cases could still be edited. Keep that in mind when making future Kata :)
Hello, Can anyone explain what the test cases are for, why they are needed and how to use them please.
The test case are just for testing your code before submitting.
If you build a calculator, a test case could test to ensure that 1+1 returns 2
A test case is NOT required for passing the challenge. They are for testing only. One does not need to test if you know what you're doing
Then why does it say no tests were provided ?
This comment has been hidden.
You misspelled Coffee.
expected: but was:
same mistake as 5 month ago.. It's still here?
I am experiencing it now, no idea what to do.
Edit: I am an idiot, I wrote 'Coffee' as 'Cofee', egh.
This comment has been hidden.
Python version is working correctly. The problem is with the user's code.
Translated it into Ruby, if you wish to approve it :)
Once done, let me know if you wish to add sample and random test cases to Python and JS versions too :)
missing python test cases
added
I'm passing the example test cases provided, but when I go to submit my solution it seems assertEquals in the Test Case is not being recognized.
/CaffeineBuzz_Test.java:9: error: cannot find symbol assertEquals("mocha_missing!", CaffeineBuzz.caffeineBuzz(mochaMissingArgs[i])); ^ symbol: variable CaffeineBuzz location: class CaffeineBuzz_Test
This comment has been hidden.
Cannot reproduce, closing ~~
"which takes a non-zero integer as it's one argument."
should be "its". Possibly also "single" or "only" instead of "one".
Fixed, thanks for reporting.
This kata is broken?
on my sourcecode i have this,
if(number % 3 != 0) result = "mocha_missing!"; else result = "Java";
but unfortunately this occur, on test case it means that number is divisible by 3 right but as you can see on my code it should return "Java" test_caffeineBuzz(CaffeineBuzz_Test) expected:<[Java]> but was:<[mocha_missing!]>
Theres more too it than that bud. Follow the logic. You're saying everything that's not 0 and divisable by 3 is Java.
What about Coffe, CoffeeScript, and Javascript?
The test class area is empty and i'm not sure how to write the test class like the other katas. Any help?
I created simple test cases.
import org.junit.Assert; import org.junit.Test;
public class TestCaffeineBuzz { @Test public void testOutputJava() { Assert.assertEquals("Java", CaffeineBuzz.caffeineBuzz(3)); }
}
This comment has been hidden.
Wrong spelling and code, read this
test_caffeineBuzz(CaffeineBuzz_Test) expected: but was:
i'm don't understand, what solution need in this task? What int n need for : "expected: but was:" Thanks.
No language specified, no code given, closing after 7 years ~~ ^^
This comment has been hidden.
Advice that seasoned developers have given me: Habitually write code that clearly expresses intent, rather than optimizing performance. The compiler and JVM often perform optimizations for you, and profiling tools can be used to expose bottlenecks. But more importantly, premature optimization leads to obscurification of intent, sometimes without any actual performance benefit.
https://stackoverflow.com/questions/20393373/performance-wise-how-fast-are-bitwise-operators-vs-normal-modulus
tried myself and got the same error as anyone else here in the forum. since i want to get points, i didn't took a look at the solution. but what is the problem with the tests? my testcases are running perfectly well!
This comment has been hidden.
The requirements say that the last return value is "mocha_missing!" (with exclamation point at the end).
RE:
expected: but was:
(Java)Many of you have reported seeing this failed test message in the Java version of this kata. I have done a little bit of investigating, but I still do not know why it is happening. I am using junit's
assertEquals
to compare the two strings (the first being what is expected, and the second being what you return).If the right does not equal the left, it prints out the empty error message and not the actual strings themselves, which is very frustrating. However, if I give it a literal string, it will print the desired error message:
Does anyone know why this is happening?
Well the root cause is extra 'e' in your assertion. When I run it outside codewars I get:
But I don't know, why it doesn't show the correct output here.
FYI: if you use assertThat notation, it works OK ;)
Yeah the single 'e' was me trying to test someone else's solution. Since you were able to run it successfully outside of codewars, I will try to check how to more properly implement Java tests here, maybe that's where the issue is, or maybe its a bug in codewars.
Thanks for the reply!
It's probably bug in codewars (or in some specific library version). You should report it.
Could you please change the assertion to this form, so we can submit our solutions:
Thanks
It says I can no longer edit the test cases o.O
I will submit a ticket.
afaik you can't edit test cases if 500+ warriors passed them.
Yeah I just found this out. I am talking to an admin right now. Hopefully we can get something working soon.
Any updates on this issue?
Hi, i also got an error like this. Can anybody please help out?
test_caffeineBuzz(CaffeineBuzz_Test) mocha_missing! expected: but was: 0 Passed 1 Failed 0 Errors
Process took 5200ms to complete
Hi, I'm getting a weird test results, please check
test_caffeineBuzz(CaffeineBuzz_Test)
expected: but was:
0 Passed
1 Failed
0 Errors
This test error message was also reported by another user, but I haven't been able to replicate it yet. Would you mind sharing what code you have? You can mark the comment as a spoiler and it will stay hidden.
This comment has been hidden.
Have you figured out the issue?
It seems the tests print out that message when you return an empty string. It's probably some string comparing issue, but I'm not sure. I'm not a java expert, and I am definitely not familiar with how junit works on codewars.
The reason your code is generating this error this error is because your code almost always returns an empty string. You might want to go back and debug a little more :)
There are no cases when I return empty string. You don't need to be an expert in Java to understand this simple logic. Could please you send your test cases, I will check them for you.
This comment has been hidden.
Double check the string you're returning on the last line. Is it the same as in the instructions?
Having trouble submitting Java solution. Getting weird empty test result:
When I add the debug output, the last call of my caffeineBuzz function before the error is with the
n = 12
.@mcclaskc could you please check your submission tests? This error is really strange.
That error IS strange. Unfortunately I have no idea what to debug. Can you please share your code? You can mark it as a spoiler and it should stay hidden.
This comment has been hidden.
FYI: I was able to submit my solution after commenting out my test method
Having trouble with 1 test case expecting Javascript and apparently only getting Java.
You need at least one negative test case that is even (e.g., 4).
Added
4
and-4
to the"mocha_missing!"
test cases. Thanks!I want to do a translation, but it seems so perfect as just the three caffeine languages together... such torment!
I know ha ha. It would be super easy to port to all the other languages, but the theme would be ruined!