-
Notifications
You must be signed in to change notification settings - Fork 50
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
Leaves - Cloudy #47
base: master
Are you sure you want to change the base?
Leaves - Cloudy #47
Changes from all commits
4401597
474e49c
360d502
7fd844a
aa19ae7
2165c53
2cdd457
afb3eb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"workbench.colorCustomizations": { | ||
"activityBar.background": "#1accff", | ||
"activityBar.activeBorder": "#df00ad", | ||
"activityBar.foreground": "#15202b", | ||
"activityBar.inactiveForeground": "#15202b99", | ||
"activityBarBadge.background": "#df00ad", | ||
"activityBarBadge.foreground": "#e7e7e7", | ||
"titleBar.activeBackground": "#00b3e6", | ||
"titleBar.inactiveBackground": "#00b3e699", | ||
"titleBar.activeForeground": "#15202b", | ||
"titleBar.inactiveForeground": "#15202b99", | ||
"statusBar.background": "#00b3e6", | ||
"statusBarItem.hoverBackground": "#008bb3", | ||
"statusBar.foreground": "#15202b" | ||
}, | ||
"peacock.color": "#00b3e6" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,68 @@ | ||
const Adagrams = { | ||
drawLetters() { | ||
// Implement this method for wave 1 | ||
let allLetters = { | ||
A: 9, N: 6, B: 2, O: 8, C: 2, P: 2, D: 4, Q: 1, E: 12, R: 6, F: 2, S: 4, G: 3, T: 6, H: 2, U: 4, I: 9, V: 2, J: 1, W: 2, K: 1, X: 1, L: 4, Y: 2, M: 2, Z: 1 }; | ||
|
||
let letterScores = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a Style note: put each letter on it's own line.
|
||
A : 1, E : 1, I : 1, O : 1, U : 1, L : 1, N : 1, R : 1, S : 1, T : 1, D : 2, G : 2, B : 3, C : 3, M : 3, P : 3, F : 4, H : 4, V : 4, W : 4, Y : 4, K : 5, J : 8, X : 8, Q : 10, Z : 10 }; | ||
|
||
const Adagrams = { | ||
drawLetters() { | ||
let letters = []; | ||
for(let letter in allLetters) { | ||
for(let i = 0; i < allLetters[letter]; i += 1) { | ||
letters.push(letter); | ||
} | ||
} | ||
|
||
const myHand = []; | ||
|
||
for(let i = 0; i < 10; i += 1) { | ||
const myShuffledLetters = Math.floor(Math.random(letters) * (letters.length)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Walk through what this line of code is doing.
There is a small bug where this could would allow you to pick 10 Z's (for instance), even though there aren't 10 Z's. What chance is necessary? |
||
myHand.push(letters[myShuffledLetters]); | ||
} | ||
return myHand; | ||
}, | ||
}; | ||
|
||
// Do not remove this line or your tests will break! | ||
usesAvailableLetters(input, lettersInHand) { | ||
const wordInput = input.toUpperCase().split(""); | ||
if (wordInput.length > lettersInHand.length) return false | ||
const howManyTimes = {} | ||
for(let i = 0; i < lettersInHand.length; i += 1) { | ||
let char = lettersInHand[i]; | ||
if (howManyTimes[char]) { | ||
howManyTimes[char] += 1; //if it exists, increment | ||
} else { | ||
howManyTimes[char] = 1; | ||
} | ||
} | ||
|
||
for(let i = 0; i < wordInput.length; i += 1) { | ||
let char = wordInput[i]; | ||
if (howManyTimes[char]) { | ||
if (howManyTimes[char] > 0) { | ||
howManyTimes[char] -= 1; | ||
} else { | ||
return false; | ||
} | ||
} else if (!howManyTimes[wordInput[i]]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}, | ||
|
||
scoreWord(word) { | ||
let thisTotal = 0; | ||
const newWord = word.toUpperCase().split(""); | ||
newWord.forEach((letter) => { | ||
thisTotal += letterScores[letter]; | ||
}); | ||
if (word.length >= 7) { | ||
return thisTotal + 8; | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
return thisTotal; | ||
} | ||
} | ||
} | ||
|
||
// Do not remove this line or your tests will break | ||
export default 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.
This should be a
const
.Style note: put each letter on it's own line.