6 kyu
Interweave the Inequalities and the Integers
91 of 117benjaminzwhite
Loading description...
Fundamentals
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.
Pretty funny and challenging kata to practice optimization algorithms with.
Hi, @benjaminzwhite. Sorry to bother you, it's not a question about the kata but about codewars. I've seen that codewars provide services for adults, but does it provide any service for middle-school students? Thanks!
Hey @LS2008 - no worries! Well, just to be clear I'm not employed by Codewars or anything like that - I volunteer as a mender, which just means helping maintain some of the content.
To answer your question; Codewars is run by https://www.qualified.io/ who do indeed provide the kind of services for schools/educational institutions that you seem to be interested in.
Several of their senior employees are in the Codewars Discord (the link is in sidebar on the left of your screen), so your best bet is to contact them there - you will find that there is a channel called #codewars which is designed for this purpose - and you can explain your requirements/enquiry and get a direct answer or setup a Zoom call/email discussion.
Hope that helps!
Thanks @benjaminzwhite, that really helps! I will go and have a check.
C++ translation
Approved 23/10/2022 - Thanks!
Main Description modified to be as language-independent as possible.
Good task... And wrong tests, how I think. My solutions is right, if check it with hands and eyes. But not here. Check it yourself.
Hi @Jam14man - thank you for the kind words and for solving; you are right, there was a small problem with the data types used in the random tests, which made your approach fail.
Since you're the first person to try this kind of approach, thank you very much for noticing!
I have fixed it now and your approach should not cause the tests to fail due to
TypeError
.However, you may find that your approach times out as it is quite inefficient. So you may still need to find a new solution.
Ok, thanks. Then I will try again. :)
I loved this kata, interesting problem
@eloise_ Thanks for the feedback! Glad you liked it; it's my first submission, so it encourages me to make more.
Tests crash badly when an unexpected value is returned:
Following solution:
results in:
and
@benjaminzwhite: don't rely on eval, actually test the string by parsing it
@Blind4Basics : Thanks for the feedback, I've just started working through @hobovsky 's useful comments and will follow your advice! It's my first kata, I'm using it to understand the testing framework and following all the codewars documentation. T
wouldn't that be simpler if the output was just an array of integers in appropriate order to satisfy the "query"? That would be way simpler to test on your side, and avoid the string conversion hassle on the user side.
@Blind4Basics ah that's a really good idea; maybe for my first experience with kata testing it would be a nice simplification. I'm going to try a redesign and see if that's easier.
@Blind4Basics - Hi, I've redesigned the kata so it now asks for user to return an array of integers in order, as you suggested.
I've also reorganized the tests a bit more, and implemented fully random testing for the random tests.
However, can you help with the other issue: I still don't understand how to solve @hobovsky 's comment about returning unexpected values: how can I handle that with the test cases?
To see how other people resolve this issue, I tried on a few other peoples' katas to return deliberately incorrect values/types and I find that I get the same kind of error messages on their katas.
Also, am I allowed to mark Issues as resolved or is that only for mods while the kata is still in Beta?
Thanks for any help, and please let me know if I can do anything better (still a newbie).
The thing is that in dynamically typed languages, tests have to be realy thorough to detect and gracefully react to various mistakes, and generally kata authors and translators are not bothered with such lame practices - that's why you do not see it in most of kata. I am also not that picky to bother you with tests of, for example, type of returned value whether it's definitely an array and not a string or Person or something. I would have to write such test at work, but I can pass it for a kata.
However, what is good to handle, are things like
None
or size of an array, to make sure that solutions likepass
orreturn []
or some other WIP solutions still fail gracefuly and dont crash because tests do something likeHi @hobovsky @Blind4Basics -
Thanks again for your comments and help; I've returned to this as it was my first kata, and I now understand a lot better what you were both trying to explain to me:
Changed:
Sample tests should use proper organiztion with
@describe
and@it
Hi @hobovsky - thanks again for this, please see detailled reply in above comment, I've now fixed this and improved the kata generally.
Cheers,