4 kyu
RoboScript #3 - Implement the RS2 Specification
77 of 860donaldsebleung
Loading description...
Esoteric Languages
Interpreters
Regular Expressions
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.
This series is amazing!
Ruby translation added
anyone could check & approve it? https://www.codewars.com/kumite/5ef69878d4a55a002491ceca?sel=5ef69878d4a55a002491ceca
Haskell translation
Perhaps you could make it clearer in the description that having a 0 postfix would also be tested or add an example test case, as I assumed that non-negative meant greater than 0.
C# Translation added.Please review and approve~
Kotlin translation, would someone mind reviewing this please.
my solution failed on a random test but then I submitted it successfully without any changes
is there a possibility for me to know the test that caused failure?
use the fork panel of your solution and run the tests as much as you need
Python Translation
Approved :D
Very fun series. Any intentions of extending it further? Maybe add new commands to do something else?
Thanks for the encouraging words :D I have thought about it before, perhaps adding a "pattern syntax" which would allow RoboScript "programmers" to define and reuse certain patterns of movement, much like a watered-down version of functions/methods in other programming languages; however, I currently do not have the time to do so and I am not sure whether I can ensure that such a Kata would not be buggy :p After all, despite the rank shown on my profile, I usually struggle quite badly with Kata that are
5kyu
and above.That being said, the fact that you've mentioned it has made me reconsider whether I should continue this Series in the near future (after my A-Level exams, that is). Thanks for your precious feedback!
@hufftheweevil,
I'm glad to announce that the 4th Kata in this series is now available in PHP :D The link to RoboScript #4 can be found at the bottom of the "Kata in this Series" section. If PHP is not your language, don't worry - I will publish a JavaScript translation soon. Stay tuned :)
Cheers, @donaldsebleung
And ... it is now available in JavaScript!
Wow that was fast! I'll check it out later today. Thanks!
One more suggestion, and I don't know if this is a good one. The output of the random test is, of course, useless. It's just too big to debug. Also, it prevents more random testing because it would overflow the console window.
Is it an idea to use
Test.expect
for the random tests? That way you don't get allllll the output, and can do more testing. Downside, of course, is .. you don't get the output. :PI don't know what the best option is. Random testing is more useful if (within reason) there's more of it - look at my zero postfix problem, my solution should never have passed, but try a few times and you might get a random test that doesn't trigger your bug if there's too little random testing and there is no fixed test for it.
Maybe
console.log
the expanded code (but that can still be ~20k characters! maybe expanded, without parentheses, but (re)compressed with postfixes? even that might not help enough ..), but no actual test output?This makes a zoomed out (smaller font) and scrollable message on failure. I also changed the color so it's easier to find the "Expected" and "Actual" lines.
The code above only writes the generated program on failure so it should be possible to increase the number of tests by stopping at first failure.
Nice! That might just work. :]
Thanks @JohanWiltink for the suggestion and thanks @kazk for the improved random tests, your requested suggestion has been made :D
@donaldsebleung, remove these 3 lines.
I think
// Test.assertEquals(actual, expected);
from my code confused you, sorry.Thanks, just realised my random tests were computing the same thing twice, removed :)
One more fix, replace
console.log(...)
with:Added
line-height: 1;
and increasedfont-size
a bit, so it appears more square. I think it looks much better :)I think there should be a fixed test for a zero postfix.
My solution treats zeroes as ones (because it treats empties as ones - I simply hadn't considered zeroes), so I was (in hindsight) only passing the random test when it did not include a zero postfix. I was wondering what and where the problem was .. but I hadn't looked at the comments yet. And I had not read the instructions that carefully. The description might explicitly state non-negative includes zero, but I think the better option is just an explicit error message with the fixed test.
It's a valid design decision, but it's easy to miss and randomly it isn't always tested.
Thank you for your suggestion, I will add it in my spare time :)
2 fixed tests added for this edge case; feel free to inform me if you think more are needed :D
Actually, yes, we need more. :]
You're testing
(..)0
but notR0
.I almost managed to squeeze by with another bug (caught in further testing this time :).
Just added a whole bunch of
F0
s,L0
s andR0
s in my zero postfix edge cases; feel free to inform me of any more holes in the test fixtures :)Is postfixing with
0
valid?0
is non-negative integer, but it doesn't help simplifying and useless :(True, postfixing with
0
(or1
for that matter) is technically useless as they do not actually simplify anything. Nevertheless, your solution should treat postfixing with0
or1
as valid and handle them accordingly. The description says exactly what it means when it says your solution should work for all non-negative integers.I was just making sure if it's intentional (not an error of random number generator) and wanted to clarify. Sorry if it bothered you. I had already solved, upvoted and ranked before above post. Thanks for this series and answering my question :)
You're welcome :) I apologise if my last sentence sounded a bit angry - I did not mean it at all :)
No problem :] Sometimes it's just hard to tell the tone :(
@donaldsebleung, can you view my solution? I have this kata marked solved and "Solutions" tab on my profile lists it, but I only see your and @smile67's solutions when I visit this kata's "Solutions".
I had this problem before on another kata. After a few hours or a day my solution was suddenly visible...
@Ablinne, thanks for the info. I just submitted again removing a blank line and that's visible now :|
edit: Now "Solutions" tab on my profile has one from "2 hours ago" and "3 minutes ago". Only difference is a single blank line between function declarations. Maybe I should've waited more patiently :(