Skip to content

Commit

Permalink
duck-typer: include new letters in each words (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikht0 authored Aug 22, 2024
1 parent 286c528 commit 90418ab
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions code/duck-typist.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ const MIN_PRECISION = 98; // percentage of correct keys
const MIN_CPM_SPEED = 100; // characters per minute
const MIN_WIN_STREAK = 5;

const STARTING_LEVEL = 4; // number of keys to begin with
const MIN_WORD_COUNT = 42; // nim number or words/ngrams we want for a lesson
const STARTING_LEVEL = 4; // number of keys to begin with
const MIN_WORD_COUNT = 42; // nim number or words/ngrams we want for a lesson
const INCLUDE_NEW_LETTERS = 2; // at least of the n last letters should be included in each word

const ALL_30_KEYS = [
'KeyF', 'KeyJ',
'KeyD', 'KeyK',
Expand Down Expand Up @@ -117,9 +119,10 @@ window.addEventListener('DOMContentLoaded', () => {
.filter(letter => letter in odk)
.map(letter => odk[letter]);

const lessonLetters = rawLetters.concat(deadkeyLetters);
const lessonFilter = word =>
Array.from(word).every(letter => lessonLetters.indexOf(letter) >= 0);
const lessonLetters = rawLetters.concat(deadkeyLetters).join('');
const newLetters = rawLetters.slice(-INCLUDE_NEW_LETTERS).join('');
const lessonRe = new RegExp(`^[${lessonLetters}]*[${newLetters}][${lessonLetters}]*$`)
const lessonFilter = word => lessonRe.test(word)

gLessonWords = [];
for (const dict of [
Expand Down

0 comments on commit 90418ab

Please sign in to comment.