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.
Not allowed to use #rotate or #reverse for my upcoming interview assessment, so I'm doing all method manually.
warning, your current random tests are completely wrong. ;)
I temporarily forgot we were talking ruby, here... (was thinking about python). So:
and you catch it that way in the fixed tests:
for the random tests it's a bit more cumbersome. You could use somehting like this:
mmh... I'd say two things, here:
Okay! So would some code that would catch the
ValueError
be (in Ruby):raise ValueError if int > arr.size
In my coding program there's a huge emphasis on understanding the whole problem before attemping it, instead of hack/slash coding. My problem isn't super complex, it's closer to 7 kyu than 6, really. The more problems cause people to go back and re-read after they've completed a solution to implement some fix, the more that people will slow down and really think about each step of the problem before tearing into it.
Okay, I'll republish the kata once it's all corrected and hope for the best. :)
nothing is returned, the code send an actual exception, just like
ValueError
or something equivalent. Meaning that you have to catch the exception in the tests and chack that it happens only when neededStill not following, sorry. x)
well, once all has been corrected here, you can try to republish in a new kata. But there is no guarantee about how some power user will react about that. If you try, be sure to get it absolutely right, first.
Okay! That's clear on what I should ask from them, but what value is being returned when they raise an Exception?
I meant that just that for people at or near my level of problem solving ability (6 to 5 kyu), I think we may rush into solving a problem if we can see a probable solution right off the bat. Adding another layer of complexity, like returning the middle value of the new array, may add just a little more challenge and cause us to slow down and think about the problem harder. In hindsight, the different return value of this one seems a little contrived.
I'm making a random test case method now, but since this is already retired can it be re-published with all the corrections I'm making?
no, you keep the current behavior, but you ask for
raise Exception(...)
instead ofreturn string
when the index isn't usable.I'm not following what you mean, here.
You make some great points, especially about if the array is holding the string
'Integer is too large'
.Thank you for the feedback! I'm editing now.
Since I'm new to this, what would be considered a good practice exception? Just returning the middle integer as it is, no reversing, if the integer is larger than the size of array?
I moreso put the requirement to return the middle value from the array just as a reading comprehension check, to make sure that people read the problem well in creating pseudocode.
;-)
The real issue is that for some reason if the "reversing-index" is out of bounds, we choose to ignore the whole purpose of the function, and return an arbitrary value which in turn could be the central element of the array itself...
then it's garbage code XD
More "seriously", you don't have the hand on the content of the array, so on that point, that'd be the responsibility of the user of the function, not the implementer of the function. But the implementer has two options:
so the point still stands.
edit: and what if the array is holding strings like
"Integer is too large."
? So the string option is really inappropriate.But what if the array consists of values of different data types?
Thank you for pointing this out. Currently looking up how to make random tests. If you have any guides to pass along, I'd love any help.
Thank you for the feedback. I think I'll remove that part from the problem. No need to restrain people!
Loading more items...