7 kyu
Jumps in a cycle #1
228 of 323Donvito-911
Loading description...
Mathematics
Puzzles
Performance
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.
solved it after googling for some help. warning to all - this kata is basically a "trick" question. the answer isn't particularly interesting, and you won't learn anything, really. this is niche, pure computer science problem rooted in mathematics.
it is not necesary to iterate over the input array in any way. i literally del cycle_list and run my code. (python). even imported gc and did a garbage collect after deleting the input list.
i have my code passing fixed, random and both efficiency tests (2^20 and 2^30). so clearly the algo i've hit upon is valid.
however i get STDERR Execution Timed Out (12000 ms)
overall, a pretty crap exercise for a 7 kyu rating. this is a platform limitation.
From your complaint I cannot really figure out what is the problem here. Your solution does not pass tests, so it is not valid. It consistently fails the "Efficiency tests (up to 2^30)" group. It seems to be simply too slow.
So what is the problem here?
no problem. just a crappy kata with a single correct answer. there is no creativity involved in solving this. thanks for your response, i appreciate you volunteering your time to the community and responding to my complaint.
This comment has been hidden.
Some dissatisfied with the task, because in the tests there is a performance test for 7 kyu kata, with a very large number of items. Unlike the actual implementation of the algorithm, which is described in detail, you need to do the math. It takes away the ability to implement The algorithm.
Reading the discussion below, I think the description should use "index" instead of "element", because the whole "indistinguishable" only makes sense when you completely ignore the actual elements in the array.
This comment has been hidden.
This comment has been hidden.
Factor translation
Don't you mean indistinguishable? Elements being distinguishable would mean they are all unique, but you explicitely test arrays with duplicate elements (even labelled as "Distinguishable cycle"). I think you are getting words mixed up?
they are considering the duplicates are distinguishable, actually. "Acting like..."
(...iirc)
How are the duplicates distinguishable? If I have an array
[1, 1]
, and then give you one of the elements1
, can you tell me what position of the array it was from?I think the author means that the function should work even when the elements are potentially indistinguishable.
conceptually, yes, the array could be mapped to
[(v,index), ...]
. But yeah, if the values are supposed to be distinguishable, better to make them actually distinguishable.I don't mean indistinguishable, otherwise this list [1, 5, 1] with jump rate of 2 would give just 1 jump instead of 3. I didn't make it explicitely, but as Blind4Basics says, I was thinking as an element, index point of view without mentioning it. The example you gave ([1,1]) is not complete since Im not asking for the element 1. Instead, I'm always asking for the first position. That is element 1 at index 0 (Actually it is not necessarily the first element since it could be any position because its a cycle, but thats another story...)
What about saying they are distinguishable because they can be mapped as a v,index ? would that avoid confusion?
Ah ok, I see what you are saying. I was reading "Assumption" as "You can assume that inputs will follow this...", but it seems you meant something closer to "Just pretend that...".
With this in mind, wouldn't it be far simpler to just say "you must find the number of jumps you have to take in order to reach the same
elementindex."? Or is it intended that solvers should realise themselves that it will be the same index?Anyway, it was my misunderstanding, so I'll close the issue.
Rust:
The initial solution function should be
All test code should be defined inside the module
tests
(right now it is possible to call thegcd
function defined in tests and it is not possible to redefine it).And
1 ≤ k ≤ 2^40
, so it can't bei32
.Some random tests pass numpy arrays, which isn't mentioned anywhere. Regular lists should be passed instead.
Is it necessary to mantain the inputs as a regular lists? Because the size limit should be lower. I used np array since this problem can be solved with the same properties of a np.array as a regular list.
Another user complained that they couldn't use regular list functions like
.index()
, and rightfully so.This comment has been hidden.
This comment has been hidden.
Thanks for reply! however your answer is flaged as spoiler, so... =)
Please review: C++ Translation
Approved by someone