5 kyu
Hello W... wait what?
1,923MentalAtom
Loading description...
Puzzles
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 bloody love this Kata!
suggested tag:
restricted
This comment has been hidden.
Very funny kata.. thanks:)
Thank you for making this Kata. I really enjoyed it.
This comment has been hidden.
Okay, fine, I added a check for it.
Note that test cases are locked so the existing solutions won't be invalidated or whatever.
I fixed the kata because the site change that has just been made at https://github.com/Codewars/codewars.com/issues/1010 allows such fixes now.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This Kata is currently broken as it gives false negatives by automatically returning "Strings are not allowed". Other comments have stated this below.
Your code is perfectly fine and hopefully this Kata gets fixed soon so you resubmit it later :)
Fixed
Hi (just to keep the issue alive and to have a fix),
I'm facing the same problem, no matter what I write I always get:
@MentalAtom is this an issue or we are doing something wrong?
Tnx.
Fixed
Whatever I write the "strings are not allowed" issues comes up. Even when I reset the kata and submit it I get this... Also I don't quite understand why I can't use this or the global object? Tnx!
Same issue. I even tried making both the code and the tests
return true;
Still the error. It looks like the kata framework itself is using toString(). (You can see this if you make the tests box empty.)In fact, I even unlocked the existing solutions and copied one. The test still fails with this error.
I've tried this kata again and still, after three months I'm getting the same issue... The worst thing is that I find this kata interesting and want to solve it :P
Fixed
review the solution list and saw my solution again. I would to say: nice!!!
^_^
This comment has been hidden.
(spoiler flags!! ;) )
Every time I submit my solution or even when I submit default/empty solution the test throws the error:
Even the following code throws the error:
Maybe the issue is that Babel transpiles the code with the string
"use strict"
that is being identified as "prohibited" string by the kata?Could you please check if this is the case?
The issue is not related to Babel or "use strict" (test won't even run in strict mode). Testing the solution code by
checkCode(arguments.callee.toString());
causes false positives like above because it's testing the solution and some internal setup code inserted by Codewars to run the test. The solution should be validated by reading/home/codewarrior/solution.txt
. See How To: Read the user's solution within your test.'global was reassigned'
is fromthrow new Error('global was reassigned')
I added (#298) for #259.Thank you for your answer.
So I guess this is something that should be fixed by Kata authors.
Fixed
This comment has been hidden.
Thanks for this creative kata. Great to see the diversity of solutions.
I fucking love this Kata; one of my favourite on this website. It turns a very simple premise into a very challenging and thought-provoking task. It's great to see to many crazy and unique solutions people can come up with and really tests your thought process. Thanks!
A really good funny kata! Thanks!
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
any use of numbers will cause it to fail, not an issue.
I wrote code to print hello world with the given restrictions.
However if I leave the original function I get the following error:
Error: Functions named Hello, World, or a combination of the above are not allowed. Found function helloWorld() at dontTryAndCheat
If I rename it i get:
ReferenceError: helloWorld is not defined
Please advise how can i get to the actual tests!
This comment has been hidden.
This kata can't work now! I copy the solutions but also throw Error: Error: Functions named Hello, World, or a combination of the above are not allowed. Found function helloWorld() at dontTryAndCheat
This comment has been hidden.
Firstly, right after a few minutes and got the first error: Error: Functions named Hello, World, or a combination of the above are not allowed. Found function helloWorld() at dontTryAndCheat
I want to point your attention that var a = function(){} isn't function a(){} !!! Assertion isn't a named function in JavaScript! (Yes, i already know how to solve this step, but you should edit the Description)
Now that I've completed the Kata, I have a few remarks
Great kata, though. I hope to never do it again.
Thanks for tHe feedback! I do plan on going some tweats at some point. The kata was written before ES6 support (Babel) was introduced, and as I can't turn it off it broke quite a few things that were perfectly valid before (like anonymous functions, they now get auto named).
I didn't realize that anonymous functions were getting autonamed. That could be frustrating.
This really was one of the most chalenging Katas I've ever tried, though. I think if maybe the description was a little more explicit on what would or wouldn't work, that would make it more fun.
This comment has been hidden.
I don't know what I'm doing wrong here, but...
If I submit this:
I get:
Error: Functions named Hello, World, or a combination of the above are not allowed. Found function helloWorld() at dontTryAndCheat
.If I rename the function to something else, I get this:
ReferenceError: helloWorld is not defined
.Also, my tests cases seem to be failing just because the function is named
helloWorld
and the assertion string isHello World
.Is all this correct and I should still be able to solve the problem like this?
It's broken, even past solutions won't work here. Just wasted an hour.
Babel (which is used to allow the usage of ES2015 stuff) implements the ES2015 rule that assigning a function to a variable defines the function's name as the variable name. You can work around this by assigning the function to a differently named variable, and then assign that variable to a variable called helloWorld.
It's definitely not broken, I just did it as of 12/17/2015
I get the same result. I just have the thing return itself and I get an error, making me think that the name of the variable is a problem.
This comment has been hidden.
There was a change in the precompiler for running the code when es6 support was added so the default solution now fails. I raised a ticket but never got a response. I'm going to change the default solution to avoid this, but otherwise it's very easy to work around.
Oh, I thought it was made on purpose, and got angry for not mentioning that in the description. Anyway, nice kata!
It's really nice kata but c'mon - whole description is inconsistent (not even mention that tests are failing and boiler code is wrong). You are saying that there should be no literal hello world but putting it into comment also doesn't work. Probably it uses regex magic internally but it would be better to use some JS parser like Esprima or whatever and parse user source code.
I don't see how people have the default
var helloWorld = function(){...}
It was failing for me just because of that.I feel like if you should change the boilerplate if it's going to prevent a "pass"
Please check your test, even If I compare true = true it fails
This comment has been hidden.
I think the description needs to make clear that it is instances of literal 'strings',digits, or regular expressions in the source code which are disallowed.
Use of String and Number types during execution is allowed.
Also the function naming checks need to be stricter.
alr added some time ago
Expected: Hello World!, instead got: Helo World!
Couldn't pass the test. What does it mean?
You misspelled "Hello".
Any hint ? I'm stuck, I always got
Error: Strings are not allowed.
even if I return a numberSo it's not just what you return - it's using any Strings full stop in the script. If that helps...
IT looks like there is an issue with this kata that the author needs to fix...
how do you prevent some functionality in solution?
Which functionalittle would that be?
like preventing the use of
String
,Number
, and any others? are you just using regex to match any form of those, or is there any spesificTest
method to do so?Regular expressions and a little bit of wizardry to get what was entered :)
Not quite sure how your supposed to solve this when the test case once submitted looks for a function called helloWorld. I solved it but since you updated the test cases it doesn't seem as though you can submit it?
I'd guess this is because ES2015 makes a function defined
var helloWorld = function()
also have the name "helloWorld". And on codeewars babel makes this happen.this issue is not reproducible - the kata is currently solvable. this is likely due to changes in the Node.JS environment / code runner setup for JS on Codewars (perhaps because Babel is no longer used - though I cannot replicate the issue even with the old
Node v8.1.3/Babel
version. But it would still be solvable even without that specific feature.That was a fun challenge. Kept catching myself using a stray 0 or ''.
I passed the test (finally), but got unknown error when I submit.
If my function isn't named "helloWorld", I get a reference error. If it is, I can't post the solution, because the function is called, well, "helloWorld".
...
Is this also a part of the puzzle? LOL
There's a bug... but it's a platform bug not mine - waiting for a respone. Without giving it away, use the pre-set solution with 1 tweak and it'll pass without that issue.
Nice kata!
I find it laughable that any of these solutions have been voted "Best Practice". There are no best practices here!
This comment has been hidden.
Because part of the challenge is figuring out how to have a function call to helloWorld() activate something that's not explicitly declared as a function.
One of the Author's replies implies this is not the case?
"They'll probably still work mostly, just change function helloWorld() to var helloWorld = function()"
Something said in the comments during beta doesn't hold weight as far as the final spec is concerned.
Hold your horses everyone, taking a look now! I haven't changed it since it went live though...
Seems to be a weird codewars issue itself, let me see if I can work out who to raise it with!
If you do "var helloWorld = function() {}" it becomes "var helloWorld = function helloWorld()" when you run the tests... but I have no idea why.
Raised on the support system... I'll comment here when I get an update. You can get around it though ;)
you can do "var hw = function() {...}; var helloWorld = hw;"
this issue is not reproducible.
works fine for this kata
This comment has been hidden.
Nice kata. Green light!
Wow! Really interesting kata!
Since the Kata disabled Strings, Numbers and Regex, why add those tags?
Originally, not all of those things were disabled so I included the tags as this was a challenge to use them. Now that they're disabled I seem to have forgottent to remove them from the tags. I'll do it now.
It's still possible to use a named function as template. (See my latest solution.)
I think I caused you enough additional difficulty to allow that though... Still had to form some strings in crazy ways which was kinda my point :)
Muhahaha !
Haha yes, that's why I changed how it starts! Too strict for it to actually work otherwise!
Are you sure it works? I still get this error even with the default starting template.
I am getting this error as well.
I just noticed that due to a change I made disallowing function names I disallowed every previous solution...
They'll probably still work mostly, just change
function helloWorld()
tovar helloWorld = function()
Sorry!
I think I'm done making it harder now :)
This comment has been hidden.
Good suggestion, implemented! And it doesnt break single or multiline comments either :)
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Do you think also disallowing the "String" constructor would be a good idea? It allows for some answers which are very simple so it's a bit more challenging without.
Test.expect
just tests whether the value isn't falsy, so evenreturn true;
solves the kata.Instead, you want to use
Test.assertEquals
.Ah, newbie error! First time I've made a kata you see... I'll correct it shortly!
All fixed! Thanks :)
This comment has been hidden.
This is fixed.
Whaa--?! That's amazing! I've never seen that done on CW--didn't think you could read the whole solution code! Very well done, mate!
This comment has been hidden.
Unfortunately, I think the way you hacked it is causing my dumb solution to pass.
This comment has been hidden.