8 kyu
Welcome!
24,224 of 53,044lucymonie
Loading description...
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
This comment has been hidden.
Java:
The website has a large audience in Scandinavia, yet swedish is wrong and both norwegian written languages are missing. 🙃
This kata was published long time ago, back then the userbase was not known... Also the author published the kata, not CodeWars official, so they would not know how the audience distribution would look like, statistically speaking ~~
I guess 8kyu for the long way, but right way is definitely at least 7kyu
This comment has been hidden.
the code also works fine in visual studio code, but does not work on when i test it on codewars
to clarify it is saying "found" has no value
this is a common expression but almost always seems to mean that you didn't do the same thing locally. use the same test case as what failed, make sure it's called correctly, or failing that, debug it in the codewars environment instead
don't paraphrase error messages, because when you do then you can only relay the things you noticed about it which doesn't help when you're missing something about it. and "it is saying" - what entity is "it"?
I'm guessing you mean:
UnboundLocalError: cannot access local variable 'x' where it is not associated with a value
here's a simple program with an obvious problem in it that produces that error message:
Good practice for an extremely useful feature, especially if you dig deeper into why.
This comment has been hidden.
Goed dag, flemish is similar to dutch (holland) welcom it is welkom then:) thaks anyway for the exe
Actually for Lithuanian it's "Sveiki atvykę" or just "Sveiki" =)
key value pairs (language and greeting) could be pre-loaded.
This would require to update all languages, so not ideal. Also, users can train on how to write their own dictionary or hashmap that way!
This comment has been hidden.
There are no restrictions on how a problem can be solved, unless the author explictly establishes tests for such cases.
This comment has been hidden.
Thanks! That was an inteesting one.
The only thing that confused this type of database list or dict. The author does not give a direct indication of the database typing.
This comment has been hidden.
If you cannot prove that the kata has flawed code, do not post as an
issue
, post as aquestion
. "It works on my machine" is not enough of a basis.The reason your code fails is because you copied descriptions of invalid tests and thought they were meant to be the result, but the instructions say:
So, your foreign environment pass your code because it has been given incorrect results. The correct expected results are in place correctly here on this site, so you must base your code on that.
If it's just for practice, I don't think it's necessary to list so many key-value pairs, copying and paste is really annoying
PHP translation
Approved
TypeScript translation
Approved
C Fork
tester
function now applied to and visible within sample testsrand()
not called repeatedly anymoreapproved
I can't find in list Russian or Ukrainian language. These are some of the most popular languages in Eastern Europe, with a total over 200 million speakers. What happened? Why they were not included in the list?
The purpose of this exercise is not to include every possible language found on earth. These are just examples so the task has some basis to work with. It feels silly that I have to explain this; if your focus is on solving the challenge, then chances are you will not even know which languages are or aren't in the list (because it doesn't matter to the implementation)
Another reason why Ukranian is not there, is because it's not a neighboring country to Finland, Sweden or Norway.
Just Yandex Translate it, its accurate enough. But to be completely honest, English first - then coding. Otherwise you woudn't be able to find needed info, Runet is lacking.
you can include them and still pass...
Because all of languages are only examples, and they don't mean anything special here.
Chinese are 1.5 billion and Indians 1.4 billion. But noone actually asked why they are not included unlike some imperialists.
This comment has been hidden.
Constants cannot be defined in methods in Ruby.
This comment has been hidden.
it's not your fault - C has a test with
NULL
, which is not mentioned in the descriptionI have added a thorough comment to the solution set-up.
the test with NULL should rather be removed, it's not present in other languages as far as i can see
Done, along with many other improvements in this fork. Please take a look if you have a moment, thank you.
This comment has been hidden.
that's why we removed that test ._.
Oh, wow, first I didn't get this right so I went to see the solution, it's clean as hell)))
My solution works perfectly fine in my editor but it's not been accepted on here. I used a switch statement.
You're not testing it properly there.
My code is working on example test. But My code does not completed. It giving error. What's the problem?
This comment has been hidden.
.index()
without any argument - that's an error.language
.try enumerating:
anyway, it would be better that you generate a dictionary like {'language' : 'greet'}, so you can call the language and get the greet directly
This comment has been hidden.
Great Kata. Suggestion: the description should note that not only are there invalid strings, but also
NULL
pointers in the test cases. Given the nature of the scenario, being a website and all, it stands to reason that you'd always be passed a valid pointer, even if it's an empty string. I kept getting memory errors inC
, which sadly don't show any debugging text you may be producing to aid in your solution. I had to create a global counter, manually count which test was causing the memory problem and hardcode a condition for that test in order to see what the input parameter was. I'm no expert by any means, but that was incredibly frustrating and unnecessary, in my opinion. Otherwise, as I said, great kata!NULL
test removedYour function should have returned 'Welcome'. its displaying 'Try again' everytime. The expected output is undefined tohat should have been equal to 'Welcome' wth is going on?
It seems you already solved the kata, see other solutions to see how you could improve your code.
Thanks buddy, it took me a lot of minutes to figure out a minor mistake i was making everytime.
I suggested an edit for Latvian translation. 'latvian': 'Gaidits' is wrong. 'Welcome' in Latvian is 'Sveicināti'
Changing that would break all solutions. I think it's not worth it, given that Gaidits translates as Welcome, at least here: http://translation.sensagent.com/gaidits/lv-en/
"Scandinavia and surrounding countries"
galaxy_brain_meme.jpg
"Hear me out... technically all countries are surrounding"
Scala translation
approved by someone
Jesus... This is so easy, but i was so confused. I spent like 20 mins on this.. xD
This comment has been hidden.
OP solved it, closing
This comment has been hidden.
Because the nullish coalescing operator needs Node v14 at least.
Watch out for any nulls!
I think two pairs of countries is pretty enough. There is no need to make students include all those countries to their code just only to pass unit tests.
While you do have a good point, I personally think this is a good Kata to train your data manipulation skills. Precisely, finding and replacing string. Be as creative as you can to write the database without typing them all one by one.
Hi So I am supper new here, this is my first ever Kata. I have a few questions about how these Kata actually work, becuase the solutions do not seem to meet the requirements for the task. How do you know which requirements are actually required? It seems like many people just understood that you did not need to do the following things to pass.
default to English if the language is not in the database, or in the event of an invalid input.
Possible invalid inputs include:
IP_ADDRESS_INVALID - not a valid ipv4 or ipv6 ip address IP_ADDRESS_NOT_FOUND - ip address not in the database IP_ADDRESS_REQUIRED - no ip address was supplied
I dont think this should be spoiler content. I think the question should specifiy what is required. So if you read this and now know exactly how to do it and your mad I am sorry!
Best-i
what if the pointer language was never initialized? That is, it contains "garbage". Is there a way to test for this?
No, there's no way in C to test whether a pointer is valid or not. The only thing you can reliably test for is
NULL
.Thanks for the reply - What about a way to test if the pointer points to a string?
In the case of this kata that should be sufficient since that is the only valid input type, right?
You cannot reliably check for this either. In C, you have to hope that the caller did their work right.
Understood, thanks again!
Please use new python test framework.
Done.
C | Getting a SIGSEGV (11) fault. Not sure why. Any hints?
EDIT: Nevermind, got it. Check language == NULL.
This comment has been hidden.
agreed
agreed, nastiest kata in 8kyu so far
haha I thought the same... I was confused at maybe this being mislabeled or else the strange coincidence between this being my first kata after ranking up to 6kyu, yet in all the 7kyu and 8kyu katas I've done I've only been asked to manipulate arrays.
Description ask you to create a welcome function but the function won't work unless the name of the function is 'greet'. Might want to be something you update. It was easy to figure out after a few fails but since it is 8kyu it would better to make that known from the start.
This comment has been hidden.
Read this
You have some commas
,
there, remove them all.Whoops, I did not notice it before...It works now, thanks a lot for your help!
created 70 liner switch solution, and now feeling guilty about, but it works, which is fine
This comment has been hidden.
hey all plz reply to me if you have completed this
4698 persons completed this kata in Python, are you expecting all of them to reply?
This comment has been hidden.
If I understand you correctly, you should
return result
instead ofreturn String.format(""Your function should have returned '%s'. Try again.", "%s"", result, result);
Hi, Thank you so much for your reply.
Test assert statement is as below, so returnned whole thing: assertEquals("Your function should have returned 'Welcome'. Try again.","Welcome", Welcome.greet("english"));
Thank you so much for your reply, I was getting error because I was missing Map import statement. I will blame intelliJ which automatically add that for me.
This comment has been hidden.
It means your solution is somehow invalid, and when test expected it to return value of
"Welcome"
it returnedNone
, and instead of expected value of"Welkom"
it returnedNone
, etc. In general, your solution seems to returnNone
in every case instead of expected welcome string.it means you you probably have an extra return somewhere
Sam where are you ?
yo
what's wrong with mine : test Results: Log Welcome Welcome Welkom Welcome Welcome Welcome
it works in my visual studio, but i still confused why i can't surpass this problem in codewars's console
Basic tests Log Welcome None should equal 'Welcome' Log Welkom None should equal 'Welkom' Log Welcome None should equal 'Welcome' Log Welcome None should equal 'Welcome' Log Welcome None should equal 'Welcome'
Return the result, not print it.
That means you returned nothing, but 'Welcome' was expected.
thanks a lot :)
This comment has been hidden.
This comment has been hidden.
Just read the error messages :P You misstyped some words. 'Velkmost' should be 'Velkomst' and 'Luakiamas' should be 'Laukiamas'.
oh damn, so it is spelling mistakes. let me try that and I will update here lol thank you
Hi, gays. I don't undestant, why my code not valide... In console worked. Kata wrote: Test Passed: Value == 'Welcome' Test Passed: Value == 'Welkom' ?'Your function should have returned 'Welcome'. Try again. - Expected: 'Welcome', instead got: undefined' But first test, returned 'Welcome'. I will be grateful for the help!
You're failing the 3rd test with language "IP_ADDRESS_INVALID" - it should return
'Welcome'
if language is not in the list, but you returnedundefined
.Thanks:)
I am getting error Test Crashed Caught unexpected signal: SIGSEGV (11). Invalid memory access. while executing it can some one help how to resolve it !!!
This comment has been hidden.
This comment has been hidden.
Your code probably fails a test case for
greet(NULL)
. Whether such test case is valid or not is another question.Description says it should default to 'English' while tests are expecting default 'Welcome'
It says "default to English" - no quotes, meaning it should default to English as a language.
As the result is always the greeting that matches the language when we say English means its greeting which is 'Welcome'
Rust translation.
This comment has been hidden.
This comment has been hidden.
I see there are indeed, click reset and see if they don't appear.
Indeed, there are sample tests in ruby.
thank you!
This comment has been hidden.
what about it???
No response, closing.
C translation kumited
please review carefully
domo!
.
I think this should be a 7 Kata. I've done 6 kata easier than this. IMO
dang fr? can you say which 6 kata were easy? i can complete 8s easily and 7s kinda, but 6s are really hard for me
This comment has been hidden.
This comment has been hidden.
||
is not a statement, it's an operator.dict[language]
evaluates toundefined
for non-existinglanguage
.Finally,
String
s do have a truthiness value.Not kata-related.
You can use
||
and&&
for assignment and return statements.For example,
return a || b
will returna
ifa
contains a truthy value (anything besides0
,''
,null
,undefined
and probably a few others), if not, it returnsb
. Andreturn a && b
will returna
ifa
contains a falsey value (0
,''
,null
,undefined
...) andb
if it has a truthy value.Much like an if statement using the
||
and&&
operators, javascript stops evaluating a statement with||
as soon as it finds a truthy statement (because it only needs one truthy value to evaluate totrue
) and similarly stops evaluating a statement with&&
as soon as it finds a falsey statement (because one falsey value will make&&
evaluate tofalse
).I am curious how literally one should take the suggestion/hint in the project details where it says "think of a way to store the languages as a database (eg an object)." Since all C# types inherit from system.object (whether directly or indirectly), is the suggestion supposed to steer people in a specific direction? If so, would it count against the programmer if they used something like a List, Tuple, Array, KeyValuePair, etc. to achieve the same result, even if it wasn't what the designer of the sample had in mind?
Latvian should be "Laipni lūdzam!". Cheers!
I am struggling with this simple task. I have created the database object but I am stumped by the "write a function that takes a parameter and returns a greeting". I understand that I must use greet(french) to get the bienvenue, is it as simple as a console.log()? I tried in Brackets and of course I didn't get anywhere. I don't seem to have a clue, is it so simple that I am looking past the solution? Thanks.
Yes, it is so simple. :]
You should write a
function
thatreturn
s a greeting.The function's return value is what is tested.
Note that you must use
greet("french")
.I'm keep getting an error from:
Greeting(SolutionTest)
expected: <[Welcome]> but was: <[]>
Which part am I missing?
By the way, it's java.
This comment has been hidden.
My guess is that 'lan' is not defined in the scope.
i have changed the parameter name as lan.it is working fine in external compilers.
This comment has been hidden.
Change
languages.values()
tolanguages.keys()
or simplylanguages
. dictionaries are laid out {key:value}, .values() will get all the values. The language is the key and the word is the value; this meaning that the language will never be the value, leading to your if statement always being true - returning "Welcome".I answered it too, it worked great on eclipse-java-mars on all languages , but here it gives an error output. I think there is an error with the checking program.
so i answer it, works perfect in my idle. kata wont have it says entering none doesnt print or return welcome. when it does.
You might be printing the output to the console instead of returning it. "None" is the default value when nothing is returned. All Katas on this website by returning the final answer so that the testcases can check for equality.
If this is not the case, can you post your code using Markdown formatting.
ah so i return "Welcome" then?
Yes
thanks man!
This comment has been hidden.
It might be to do with your use of constants - I don't think you're supposed to modify them. However, I am far from a Ruby expert. 10XL do you know what's going on here?
CoffeeScript translation kumited! Please Accept :smile:
This comment has been hidden.
CW is different from most other programming sites: you should return the value, not printing the value to stdout.
This comment has been hidden.
This comment has been hidden.
Your code also fails. I tested my & your code in Chrome & it works 100% right. I think sth is wrong with this Kata, not our code.
This comment has been hidden.
Yep, I meant in Chrome's console. I didn't try it in other browser. Do you have any idea why my & your previous code did fail in codewars? Not for the sake of completing a challenge, I'm just curious :)
This comment has been hidden.
This comment has been hidden.
Sorry @Kaiyou - we're on it! In the meantime, here's the list if you want to copy and paste: english: 'Welcome', czech: 'Vitejte', danish: 'Velkomst', dutch: 'Welkom', estonian: 'Tere tulemast', finnish: 'Tervetuloa', flemish: 'Welgekomen', french: 'Bienvenue', german: 'Willkommen', irish: 'Failte', italian: 'Benvenuto', latvian: 'Gaidits', lithuanian: 'Laukiamas', polish: 'Witamy', spanish: 'Bienvenido', swedish: 'Valkommen', welsh: 'Croeso'
c# database is now there to copy/paste in a dictionary.
Great! Thanks.
For students just starting to learn about objects, this is quite possibly the best kata to start with!
I think a new user should know how to create an object before they copy and paste one it, but this inspires me to make some Kata about objects. : ) Actually, looking at it again, it's just the key: value pairs that were given.
C# translation submited. please approve :)
Thanks!
Hey @aryan-firouzian, could you please add the database of languages to the C# translation? I'm not sure what format it should take.
Done, sorry I had missed it.
I'm new to C#. Where do you call the function (what line?) i.e. ConsoleWriteLine(Greet("swedish")); I'm running it on Visual Studio 2017 and I am getting error -> "the name Console.WriteLine does not exist in the current context. Please let me know how I can print answer to screen. Thanks
Console
belongs to theSystem
namespace, so you either need to useSystem.Console.WriteLine
or do ausing System
first.This comment has been hidden.
It didn't take much to create your own object parsing a copy&paste string, but I just edited the description, so to help a bit both Python and Ruby users :)
Ha yeah, actually it was a really good practice exercise for a shell one-liner...
:)
It was clear to me that I needed to create an object.
Python translation submitted, enjoy!
Thanks!
This comment has been hidden.
This comment has been hidden.
Sorry @petegarvin - I seem to be behind on discussion points! Glad you got it. And now I know too :-)
No problem, sometimes better to work it out on your own! Just popped into my head as I was walking home
Ruby translation submitted. (:
For some reason I don't seem to be able to see your translation 10XL. Are you able to re-post it?
I've forked the original translation.
Here is a link to my translation, if that helps.
Thanks!
I assume the "database" is an object. If so, we need to know what it's called to complete the kata.
You're absolutely right - that is a bit unclear. It's actually up to the person solving the kata to set the database as they would like, whether it's an object or a switch statement. I will clarify this in the description.
Perhaps creating an object is one task of this simple kata;-)... (sorry, same time for an answer:-))
Thanks so much for the suggestions - I have have updated the kata description.
OK, I misunderstood. Some katas have a reference object pre-defined, and I jumped to the conclusion that's what was going on here. Thanks.