forked from AdaGold/js-adagrams
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Sea Turtles Carranza, Katina #114
Open
kmcarranza
wants to merge
5
commits into
ada-c17:main
Choose a base branch
from
kmcarranza:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dfd459f
Working on Project but submitting what is complete
kmcarranza e2bd94e
Made changes to pass test - resubmitting
kmcarranza 322e77e
Completed and Passed all test through Wave 4
kmcarranza eac4f45
Cleaned up extra console.log statements
kmcarranza 91cc6b1
Cleaned up last console.log statement
kmcarranza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"name": "vscode-jest-tests.v2", | ||
"request": "launch", | ||
"args": [ | ||
"--runInBand", | ||
"--watchAll=false", | ||
"--testNamePattern", | ||
"${jest.testNamePattern}", | ||
"--runTestsByPath", | ||
"${jest.testFile}" | ||
], | ||
"cwd": "${workspaceFolder}", | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen", | ||
"disableOptimisticBPs": true, | ||
"program": "${workspaceFolder}/node_modules/.bin/jest", | ||
"windows": { | ||
"program": "${workspaceFolder}/node_modules/jest/bin/jest" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,110 @@ | ||
const availableLetters = { | ||
'A': [9, 1], | ||
'B': [2,3], | ||
'C': [2, 3], | ||
'D': [4, 2], | ||
'E': [12, 1], | ||
'F': [2, 4], | ||
'G': [3, 2], | ||
'H': [2, 4], | ||
'I': [9, 1], | ||
'J': [1, 8], | ||
'K': [1, 5], | ||
'L': [4, 1], | ||
'M': [2, 3], | ||
'N': [6, 1], | ||
'O': [8, 1], | ||
'P': [2,3], | ||
'Q': [1,10], | ||
'R': [6,1], | ||
'S': [4,1], | ||
'T': [6,1], | ||
'U': [4,1], | ||
'V': [2,4], | ||
'W': [2,4], | ||
'X': [1,8], | ||
'Y': [2,4], | ||
'Z': [1,10] | ||
} | ||
|
||
export const drawLetters = () => { | ||
// Implement this method for wave 1 | ||
let letterHand = []; | ||
while (letterHand.length < 10){ | ||
// picked_letter = Math.floor(Math.random(Object.keys(available_letters))); | ||
const randomIndex = Math.floor(Math.random()*26); | ||
const letterList = Object.keys(availableLetters); | ||
const picked_letter=letterList[randomIndex]; | ||
const elementCount = letterHand.reduce((total,x) => (x==picked_letter ? total+1 : total) ,0); | ||
if (elementCount < availableLetters[picked_letter][0]){ | ||
letterHand.push(picked_letter); | ||
} | ||
} | ||
return letterHand | ||
}; | ||
|
||
export const usesAvailableLetters = (input, lettersInHand) => { | ||
export const usesAvailableLetters = (input,lettersInHand) => { | ||
// Implement this method for wave 2 | ||
const lettersInHandCopy = [...lettersInHand]; | ||
let result = true; | ||
// const word = input.toUpperCase() | ||
for (const char of input){ | ||
if (lettersInHandCopy.includes(char)===true){ | ||
const index = lettersInHandCopy.indexOf(char); | ||
lettersInHandCopy.splice(index,1); | ||
result = true; | ||
} else { | ||
result = false; | ||
return result; | ||
} | ||
} | ||
return result | ||
}; | ||
|
||
export const scoreWord = (word) => { | ||
// Implement this method for wave 3 | ||
let score = 0; | ||
if (word.length == 0){ | ||
score = 0; | ||
return score; | ||
} | ||
for (const letter of word.toUpperCase()){ | ||
score += availableLetters[letter][1]; | ||
} | ||
if (word.length >= 7 && word.length <= 10) { | ||
score += 8; | ||
} | ||
return score | ||
}; | ||
|
||
export const highestScoreFrom = (words) => { | ||
// Implement this method for wave 1 | ||
}; | ||
let scores = [] | ||
let topScoringWords = [] | ||
let lgth = 0; | ||
let longestWord; | ||
|
||
for (let word of words){ | ||
let wordScore = scoreWord(word); | ||
scores.push(wordScore); | ||
// Loop to find the longest word | ||
if (word.length > lgth){ | ||
lgth = word.length; | ||
longestWord = word; | ||
} | ||
} | ||
let maxScore = Math.max(...scores); | ||
// makes list of all words with the top score | ||
for (let i = 0; i < scores.length; i++){ | ||
if (scores[i] === maxScore){ | ||
topScoringWords.push(words[i]); | ||
} | ||
} | ||
if (longestWord.length === 10){ | ||
return {"score": maxScore,"word":longestWord} | ||
} else { | ||
// finds shortest word with top score | ||
let topWord = topScoringWords.reduce((a,b) => a.length <= b.length ? a:b); | ||
return {"score": maxScore, "word":topWord} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 would use the spread operator to make a copy of the letterPool
use a for loop to draw 10 letters
use math.floor to make the random draw
push the letter to letterHand
return letterHand