More for the "geez, past me" department, I had grappled with
this bot in 119 commits over five months. It passed phrases through automatic translation services multiple times in order to try to generate a result that was funny or interesting. The vast majority of the time, it just made shrugworthy stuff.
It was never good, but I just kept grinding. I started this a month after the guy was born and was sleep-deprived. Maybe in that state, I just did not feel safe enough to step away from a failure? I'm surprised I had time to do any coding at all. I vaguely remember taking time out each morning to go to a coffee shop before getting on the train to go into town. This is probably what I hammered at during that time.
Look at this baroqueness in the README:
clockworkPair deterministically picks a pair of numbers from a range from 0 to c - 1, where c is the upper limit, and a seed, such that:
- The first element of a pair generated from seed s + 1 will follow the first element of a pair generated the seed s.
- Unless p[0] (the first element of the pair) generated from s is c - 1. In that case, p[0] for s + 1 will be 0.
- If
pickTranslationLocales
is called for every seed from 0 to c * (c - 1), every pair combination will be generated.
- Basically:
clockworkPair(upperLimit, seed) =>
- Let base = seed % upperLimit
- Let gap = floor(seed/upperLimit) + 1
- Let wraparound = fn(x, c) => x < c ? x : x - c
- return [base, wraparound(base + gap)]
- If seed >= c * (c - 1), seed will be seed % c * (c - 1).
I can't remember why I thought it was important to explain this and explain this in this "math" style. Maybe I was caught up in some kind of "mathematics is the real programming" trend.