aboutsummaryrefslogtreecommitdiffstats
path: root/linkHints.js
diff options
context:
space:
mode:
Diffstat (limited to 'linkHints.js')
-rw-r--r--linkHints.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/linkHints.js b/linkHints.js
index f30425aa..24fa7946 100644
--- a/linkHints.js
+++ b/linkHints.js
@@ -352,7 +352,23 @@ var alphabetHints = {
for (var i = start; i < start + longHintCount; i++)
hintStrings.push(this.numberToHintString(i, digitsNeeded, linkHintCharacters));
- return hintStrings;
+ return this.shuffleHints(hintStrings, linkHintCharacters.length);
+ },
+
+ /*
+ * This shuffles the given set of hints so that they're scattered -- hints starting with the same character
+ * will be spread evenly throughout the array.
+ */
+ shuffleHints: function(hints, characterSetLength) {
+ var buckets = [], i = 0;
+ for (i = 0; i < characterSetLength; i++)
+ buckets[i] = []
+ for (i = 0; i < hints.length; i++)
+ buckets[i % buckets.length].push(hints[i]);
+ var result = [];
+ for (i = 0; i < buckets.length; i++)
+ result = result.concat(buckets[i]);
+ return result;
},
/*