4 kyu
Elemental Words
375 of 924dcsmith
Loading description...
Strings
Algorithms
Recursion
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.
It would be grat to have some of the link with all periodic table of elements.. In the internet in different places could same elements could be named differently (USA/Britain) and also in some places number of elements could be 118, in other 120...
In this task this tests is hidden and as a blackbox for developer, which list expected, because this is even missed in tests.
American chemical sosiety know just 118, but this task is not clear what exactly you are expecting here
This kata does not require you to actually know the periodic table and all its elements. They are provided for you. You can solve this without knowing a single element's name, theoretically.
Any nitpicks about scientific accuracy would pass by 99.9% of this platform's audience.
That is not correct, because tests passed and after pushing on "Sending" somewhere under the hood platform check something that is absent in the existing tests... And I have already spent 4 hours I am trying to figure out where to get these correct names and symbols..
I'm pretty sure you missed this line from the description:
Because the tests expect you to handle it using the given
ELEMENTS
object. And of course, in sample tests the author can't add all elements as examples. That's why you can't make your own object based on what is shown in the sample tests.Just add elements which required during test
Wich attempt generate different test scenarious...
This is random testing.
Nice... in test implementation withSorting and nothing mentioned that in solution that is should be also...
Just print the Dictionary to the Console and click on the Test button:
E.g in C#:
Rust translation ready for review.
Note: updates description.
Apprez.
Scala translation
Very fun Kata.
TypeError: Cannot read property 'sort' of undefined at mySort (test.js:28:14) at doTest (test.js:24:25) at tests.forEach.test (test.js:21:23) at Array.forEach () at Context.it (test.js:21:7)
Because the tests expect your code to return an array like the description says:
Why are you clicking
Test
orAttempt
if you hadn't written any code yet? Not a kata issue.Nickel Cerium Oxygen Neon! Thanks for the cool kata idea, and the implementation/description is great also.
This comment has been hidden.
The test case you failed on has a space in the middle of it which you seem to have ignored.
How i can import dictionary in VS?
RTFM...?
Print it...?
Nice kata
C# Translation ready for review.
After talking with Mauro, it seems the consensus is that the empty string as input should yield an empty array, so that is what I did too.
Approved by B4B ~~
This comment has been hidden.
Read the description carefully especially the last line.
Oh, my bad, sorry. Thanks for telling me!
np!
This comment has been hidden.
Initial solution in Python should explicitly import
ELEMENTS
.Fork with explicit import and tests with empty strings:
https://www.codewars.com/kumite/60c68c6be8f14f003d0bd043?sel=60ca5bd15a2143005526102f
Approved in fork to fix description conflict.
Python translation:
https://www.codewars.com/kumite/60c68c6be8f14f003d0bd043?sel=60c68c6be8f14f003d0bd043
What to do with empty strings (see issue)?
[]
(as in javascript)[[]]
(more coherent)Cool! I made this so long ago I always forget it's still here haha. Your translation looks solid. My thinking with the empty strings was that if a word (whether it's empty or not) has no "elemental forms", then an array containing no forms (i.e. an empty array) would be the natural return value. I do understand that the "empty" combination could form the empty string though. Maybe I will update the description so that an elemental word is defined by being able to be formed with a non-empty combination of symbols.
Approved by someone
(Javascript) From log on stderr:
Updated tests to use assertDeepEquals
The tests expect
[]
forelementalForms('')
, but there's nothing about this case in the description and "is not an elemental word" is defined as "no combination of element symbols can formword
" without any mention of empty words, so it isn't the case that a word can't be empty.I realized that in the start of the description I defined an elemental word as "any string of letters formed by the concatenation of one or more element symbols" (key words being "one ore more"). I have updated the description to include this wording in the guidelines. I think, taking this definition into account,
[]
would be the natural return value forelementalForms('')
.Hi, I think it's time for me to call for help. My solution passes 147 tests and times out on "floccinaucinihilipilification". I'm pretty sure the problem lies in my recursive approach to get possible combinations of 1-2-3 chars from the given word to match against ELEMENTS. So, the question is whether my recursive approach makes any sense and can be sped up (any ideas how?) or should be abandoned altogether. Thank you
Recursion is definitely a possible solution, and probably the more common one. I would check if you're unnecesarily recursively calling your function too many times. You don't only need to use recursion ;)
Thank you, dcsmith. I'd appreciate that. I would definitely prefer to solve it through recursion, it's actually the reason I chose your kata.
I am stuck on 147 tests too, any tips? I added a condition for breaking out of my recursive function early but still not passing more than 147.
Nice one and refreshing :)
Hi. I've just completed this kata. I get passes on all the sample tests and then when I hit "ATTEMPT" I get passes on (all?) 353 tests with no errors or failures reported. Runtime is typically 450ms. However, I do not get the "SUBMIT" button coming up. Is there an element of the test that I am missing (eg a performance requirement)? Any ideas why I am not able to submit?
@dcsmith Instructive exercise, by the way.
Hmm... Sounds like an issue with Codewars itself. Is this happening on other katas, or just this one?
You can also try
Ctrl + S
-- iirc that submits your solution. On my phone rn but I'll check if it happens to me too when I get the chance.Currently Codewars platform is experiencing issues.
https://github.com/Codewars/codewars.com/issues/893
Thanks for responses. @Voile Thanks for pointing this out. I shall await intervention from the gods of CodeWars...
It's a shame that such a good katas are in beta for so long. Will try to convince some people to solve this :) Thank you for your hard work!
Thanks !! I sometimes forget about this one haha. There does seem to be a focus these days on approving quickly solvable kata rather than ones that take a little more thought. But I dont blame the community, it's probably just inevitable given the platform.
Nice kata, @dcsmith. checked it out on @gabbek's recommendation. Looks like it's ready for moderator review and approval.
Thank you very much @docgunthrop. Kata approved. Looking forward to recommendations of beta katas to solve on gitter channel.
Good kata!
Thanks!