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.
I'd like to chime in on this one. I was mislead in my initial solution assuming that x ran horizontal and y vertical, despite the picture showing the origin in the upper left. Sure I could of easily read this as a cartesian plane rotated 90 degrees, but then the navigational directions oriented with north up further lead me to think it was not rotated. Nothing in the description said otherwise. Making matters worse, the example and the first test case only use switches on points where x == y ([1,1], [4,4], etc) so there's nothing in there to tip the reader off.
So I solved it for all the example cases only to have it blow up on the real cases. It took awhile for me to figure out why, and then to refactor for the rotated coordinates.
I suggest you make it abundantly clear by labeling the coords in the picture. A second option would be to use a non=symmetrical example.
All that said, I really enjoyed working this one and the colorful description!
Those examples are much clearer, thanks! I was about to say if it's so hard to explain, then maybe lose the requirement :-) But then that would make it somewhat easier to solve.
99
is Wayne Gretzky's retired number. It's ALWAYS appropriate to include :)But really, I added it just to give a case where the first index isn't 0. Good feedback that it muddies more than helps though.
Thanks much for all the help. Went with most of what you changed and cleaned up more.
Fixed
Fixed
This would be inaccurate. It's any element must be lower indexed than any element from other triplets. Or the second lowest indexed element in the case of a tie for the first. Words are hard! That's why I put these two specific examples in the text:
Are those not clarifying enough?
Well played sir!
I didn't mean to imply that sorted couldn't work, since it takes extra effort to find all possible solutions and then reevaluate those against their original indexes.
The question for me is if this then leads to higher performance, as gained from the ability to walk a sorted list.
Actually it's technically O((n-2)(n-1)n/6), which is slightyl less than n^3 / 6
Still not as good as n^2 once you get above about 8 members, but I gotta defend my solution :-)
Great feedback, thanks! I got away from JS for a year or so while having fun with Go and now Python.
let
vsvar
is indeed good form!I'll also look into your fork and learn the superior test methods and provided features (didn't know randomize was a thing!)
I think you are correct on my wording being misleading or plain wrong. What I meant to say was that moving from left to right through the array, priorty is on elements of the solution array found first -- not specific of the order in the final array. So in the referenced case above, 825 is part of the answer and is the leftmost element of any in a valid solution.
Would changing the wording to below help clarify?
such that the first located member of the sequence will have the lowest indexed first member from the array
This comment is hidden because it contains spoiler information about the solution
You make a lot of good points. It would be trivial to add the loop and bang out 100 or so random.
As for why I care, by profession I'm usually heading engineering orgs and like to think big picture. Part of that is to challenge the status quo and ask questions if an existing practice still makes sense, especially when multiplied by some large number due to scale. I get that optimizing CW is not my concern, but old habits die hard :-)
FYI -- the above it part of why I'm here. After too many years managing I'm trying to get back some of my coding chops and also learning the languages that all the cool kids are coding in these days.
Agreed on that. I replaced the word set with either group or array depending on the context. That should be less misleading for the Python version specifically. I haven't tried porting to another language yet but assume that you only get one description to rule them all, so will need to keep it language agnostic.
FYI - I plan to add JS and Go next. I'm pretty rusty in most of the other language options here.
From my point of view, the role of the random test is to prevent hardcoding answers to the tests that can be discovered through failures. So in theory just one should do the trick. What's the point of having 100? I'd rather preserve cycles on the servers if it's not adding real value.
I chose the few that I added to cover a couple different sized lists with and without an expected sequence to be found. I would think that's sufficient coverage unless I'm missing something.
Loading more items...