Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Much appreciated!
This comment is hidden because it contains spoiler information about the solution
Appreciated!
Rust sample tests do not compile. A few test cases do not compare to an
Option<usize>
as they should, and the case forNone
expects-1
.I would imagine this goes against the original idea of the kata, and additionally, this would invalidate a lot of solutions. It's a major change for a kata years old. This could be incorporated into a separate kata that expands on the idea of a PaginationHelper.
How should the expression
5 + abc 2 + 5 3
, whereabc
is a function with two parameters, be evaluated?This expression is permissible by the grammar, however the language spec lists
+
as a higher priority than functions. Intuitively, I'd want to just evaluate the function first, but that seems to go against what is explicitly stated, unless I'm misunderstanding how priority works.Edit: To anyone else wondering about how the priority properly works, function calls are the highest priority. Then, the operations in the table follow accordingly. Function assignment is the lowest priority.
Not a problem, I'm glad I could help :D
There's an issue with the Rust version of this kata. According to the problem description, "if you are given an array with multiple answers, return the lowest correct index".
This is not true in the Rust translation. Here is an example where it breaks:
This random test expected an answer of
Some(202)
which IS a valid answer, but my code returnedSome(199)
, which is ALSO a valid answer and has the lower index.This happens when the kata tries to generate a random test with a guaranteed answer but doesn't check that its answer is the lowest valid answer, instead just assuming it's the only answer. This is easy to fix -- just replace
dotest(&arr, Some(i))
withdotest(&arr, reference_solution(&arr))
(and probably do a slight refactor to get rid of the extraneouselse
block). I have a proposed fix here: https://www.codewars.com/kumite/649c7f7f0b00c8003ea81022?sel=649c7f7f0b00c8003ea81022Fixes a bug where the random test will sometimes have the incorrect expected response. The test where it inserts values to create a guaranteed midpoint does not check that it's the earliest midpoint possible.
It seemed to me after a bit of looking at the documentation that
Arrays.stream(a)
will return anIntStream
of an array of ints, and thatIntStream.of(a)
doesn't support returning anIntStream
from an array, but instead a list of parameters that you give it. Unless I'm misunderstanding the ellipsis in the documentation.Arrays.stream(int[] array)
: https://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#stream-int:A-IntStream.of(int... values)
:https://docs.oracle.com/javase/8/docs/api/java/util/stream/IntStream.html#of-int...-Looking at the solution now, I think that I am misunderstanding it. There doesn't seem to be anything there that says it works with an array of ints. My guess is no, it doesn't matter, unless it's something really finicky with how Java compiles.
Curse you, floating-point precision!
Well said. You are probably right in that it doesn't need to be stated twice, and I don't think it's NEEDED, but helpful. I kept the author's "left" and "right" rotation and just assumed that they were correct, but it might just be better overall if it's omitted. That would remove my concern of stating the return twice and remove information irrelevant to the problem. Anyways, I am off to sleep for tonight. I think what we have works well if the author looks at this and updates it.
I suppose if I'm going to argue that it is poor that I should offer a better solution. Here's what I propose then:
Write a function that takes as arguments two strings and returns positive (
True/true/1
) if one string is a rotation of the other or else returns negative (False/false/0
).A pair of strings are rotations of each other if they are the same string OR if you can take the letters from either end and move them (preserving their order) to the opposite end you took them from. Examples:
For example:
Keep in mind you only have to return
true
for rotations andfalse
for non-rotatations (or their equivalent boolean values in your language).I think that would do better as the kata description. A few more words, but I think they clear things up. Agreed? I'm open to hear what you have to say, you have more experience on this site than me.
Yes, it IS my wrong interpretation Chrono, but my point stands. You want to remove ambiguity. Yes, I'm wrong. My suggestion there was to have it to where less people will be wrong. Miscommunication goes both ways.
Glad I could help.
Loading more items...