-
Notifications
You must be signed in to change notification settings - Fork 20
Ocelots - Ya-Juan Ruan #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ccurately_finds_best_scoring_word_even_if_not_sorted test
| export const scoreWord = (word) => { | ||
| // Implement this method for wave 3 | ||
| }; | ||
| export class Adagrams{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice use of OOP!
| this.letterPool = []; | ||
| for (let alphabet in letterMap){ | ||
| let times = letterMap[alphabet]; | ||
| for (let i=0; i<times; ++i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh, this is how I think about setting up the pool, with the appropriate stats for picking a random letter with a given frequency distribution for each letter, too!
| const letterBank = []; | ||
| let length = this.letterPool.length; | ||
|
|
||
| while (letterBank.length < 10){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loops makes sense, and I don't think you really have to worry about it here, but when I see
while loops like this, I think about adding some other kind of guard condition- like limiting the
number of attempts, for example-- to catch a possible infinite loop if there weren't enough letters
to be picked.
| letterCount.set(letter, count); | ||
| } | ||
|
|
||
| for (const cha of input){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might like to see something like 'inputLetter'-- I think 'cha' is short for 'character', here? ('character' may be a reserved word in javascript-- I'd have to double check)
No description provided.