@vaporeon_ "cycle" is not a technical concept it is a word i made up to describe what i was looking for
@vaporeon_ what i'm trying to do is find the length of a "cycle" in the array. a cycle is the number of "jumps" you can do in the array if you jump forward by a set number of indices before you return to where you started, assuming that you start back at the beginning of the array once you exceed its length
@vaporeon_ when i looked at other solutions people usually used a greatest common denominator algorithm which is O(sqrt(n)) in this step, but the reasons for it are due to Math I Don't Understand
@vaporeon_ im trying to think of a silly acronym but i cannot think of one, gorp is too weird
@vaporeon_ they have a terminal where you can write code in an online IDE and immediately check the result against test cases so it actually makes sense in this context
re: no image desc
@vaporeon_ specifically my solution is a linear time, O(1) space solution (O(1) space solution is really hard to come up with)
@wallhackio that’s epic
@vaporeon_ it's a solution to https://leetcode.com/problems/rotate-array/description/
(javascript warning)
@cam fraternal
@cam oh you aren't yet fully versed in glitchcat lore it seems
@monorail if you actually say "ack" in real life then i am reporting you
@cam aesc and i are twins and we are also gemini so i think astrology is real, sorry
@vaporeon_ what is gorp
@vaporeon_ i intentionally renamed variables to make it stupider
also, this was a difficult solution that is a little tricky explain. also, i dont fully understand how it works lol
re: uppercase
@vaporeon_ also my horrible legacy code backend at my recent job did so much bullshit in sql that it kind of scarred me
re: uppercase
@vaporeon_ it's fine. i just find it boring
@vaporeon_
The downside of doing that is that your code starts looking like this:
class Solution {
public:
int p(int i, int l, int s) {
return (s + i) % l;
}
int swap(vector<int>& a, int i, int j) {
int t = a[i];
a[i] = a[j];
a[j] = t;
return j;
}
void rotate(vector<int>& n, int k) {
int L = n.size();
k = k % L;
int c = 1;
while ((c * k) % L != 0) c++;
for (int i = 0; i < L / c; i++)
for (int j = 1, b = i, D = L - k; j < c; j++)
b = swap(n, b, p(b, L, D));
}
};
re: uppercase
@vaporeon_ oh does vaporeon like sql?
the clodvestigator
i answer to Caleb, Clodsire, Clodboy, Clod, and Bumby. very leftist.
videogame enjoyer. mathematics hobbyist and recovering physicist. recovering software engineer. professional wonk. prophet of The Truth. the walking embodiment of "not diagnosed, but somethings wrong". i like animals that wear cowboy hats.
number of fat cock awards received: 56
header is by @vaporeon_
"i regret ever allowing him here" ~aescling
"oh you're one of those weird movie likers" ~Ti
30+
he/him
sgraMrt