-
Notifications
You must be signed in to change notification settings - Fork 36
Fire - Jing & Stacy #10
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: master
Are you sure you want to change the base?
Changes from all commits
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,52 @@ | ||
| <mxfile host="app.diagrams.net" modified="2020-12-18T08:14:57.125Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15" etag="cCoXQTFkrQucJ_5DPNGD" version="14.0.5" type="github"> | ||
| <diagram id="_95Hr5ytqPnYlgKhDQPe" name="Page-1"> | ||
| <mxGraphModel dx="874" dy="1604" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0"> | ||
| <root> | ||
| <mxCell id="0" /> | ||
| <mxCell id="1" parent="0" /> | ||
| <mxCell id="Pv-lDhROw9vmJ1KCem3l-1" value="" style="shape=image;imageAspect=0;aspect=fixed;verticalLabelPosition=bottom;verticalAlign=top;image=https://s3-us-west-2.amazonaws.com/forge-production.galvanize.com/content/c29d2d8a9a36c1542a5f6c8ee3399291.png;" vertex="1" parent="1"> | ||
| <mxGeometry x="20" y="-151.12" width="787.77" height="671.12" as="geometry" /> | ||
| </mxCell> | ||
| <mxCell id="Pv-lDhROw9vmJ1KCem3l-2" value="<font style="font-size: 23px">&lt;category /&gt;</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;strokeWidth=2;strokeColor=#FF0000;" vertex="1" parent="1"> | ||
| <mxGeometry x="190" y="-100" width="150" height="150" as="geometry" /> | ||
| </mxCell> | ||
| <mxCell id="Pv-lDhROw9vmJ1KCem3l-3" value="<font style="font-size: 23px">&lt;category /&gt;</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;strokeWidth=2;strokeColor=#FF0000;" vertex="1" parent="1"> | ||
| <mxGeometry x="190" y="60" width="150" height="160" as="geometry" /> | ||
| </mxCell> | ||
| <mxCell id="Pv-lDhROw9vmJ1KCem3l-4" value="<font style="font-size: 23px">&lt;category /&gt;</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;strokeWidth=2;strokeColor=#FF0000;" vertex="1" parent="1"> | ||
| <mxGeometry x="360" y="-100" width="170" height="160" as="geometry" /> | ||
| </mxCell> | ||
| <mxCell id="Pv-lDhROw9vmJ1KCem3l-5" value="<font style="font-size: 23px">&lt;category /&gt;</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;strokeWidth=2;strokeColor=#FF0000;" vertex="1" parent="1"> | ||
| <mxGeometry x="360" y="70" width="170" height="350" as="geometry" /> | ||
| </mxCell> | ||
| <mxCell id="Pv-lDhROw9vmJ1KCem3l-6" value="<font style="font-size: 23px">&lt;category /&gt;</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;strokeWidth=2;strokeColor=#FF0000;" vertex="1" parent="1"> | ||
| <mxGeometry x="190" y="230" width="150" height="240" as="geometry" /> | ||
| </mxCell> | ||
| <mxCell id="Pv-lDhROw9vmJ1KCem3l-7" value="<font style="font-size: 23px">&lt;category /&gt;</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;strokeWidth=2;strokeColor=#FF0000;" vertex="1" parent="1"> | ||
| <mxGeometry x="540" y="-100" width="110" height="460" as="geometry" /> | ||
| </mxCell> | ||
| <mxCell id="Pv-lDhROw9vmJ1KCem3l-8" value="<font style="font-size: 23px">&lt;category /&gt;</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;strokeWidth=2;strokeColor=#FF0000;" vertex="1" parent="1"> | ||
| <mxGeometry x="540" y="370" width="110" height="80" as="geometry" /> | ||
| </mxCell> | ||
| <mxCell id="Pv-lDhROw9vmJ1KCem3l-10" value="<font style="font-size: 23px ; background-color: rgb(255 , 255 , 255)">&lt;location /&gt;</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeColor=#3DFFB1;strokeWidth=2;fillColor=none;" vertex="1" parent="1"> | ||
| <mxGeometry x="190" y="-151.12" width="460" height="41.12" as="geometry" /> | ||
| </mxCell> | ||
| <mxCell id="Pv-lDhROw9vmJ1KCem3l-11" value="<font style="font-size: 23px">&lt;cities /&gt;</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=2;fillColor=none;strokeColor=#45C7FF;" vertex="1" parent="1"> | ||
| <mxGeometry x="670" y="-110" width="80" height="450" as="geometry" /> | ||
| </mxCell> | ||
| <mxCell id="Pv-lDhROw9vmJ1KCem3l-12" value="<span style="background-color: rgb(255 , 255 , 255)"><font style="font-size: 15px">&lt;Language /&gt;</font></span>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=2;fillColor=none;strokeColor=#FF9933;" vertex="1" parent="1"> | ||
| <mxGeometry x="660" y="-151.12" width="90" height="41.12" as="geometry" /> | ||
| </mxCell> | ||
| <mxCell id="Pv-lDhROw9vmJ1KCem3l-14" value="<font style="font-size: 23px">&lt;header /&gt;</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeColor=#FF9933;strokeWidth=2;fillColor=none;" vertex="1" parent="1"> | ||
| <mxGeometry x="20" y="-140" width="160" height="220" as="geometry" /> | ||
| </mxCell> | ||
| <mxCell id="Pv-lDhROw9vmJ1KCem3l-15" value="<font style="font-size: 20px">&lt;calendar /&gt;</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=2;fillColor=none;strokeColor=#FF66FF;" vertex="1" parent="1"> | ||
| <mxGeometry x="40" y="-20" width="120" height="90" as="geometry" /> | ||
| </mxCell> | ||
| <mxCell id="Pv-lDhROw9vmJ1KCem3l-16" value="<font style="font-size: 26px">&lt;links /&gt;</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=2;fillColor=none;strokeColor=#B266FF;" vertex="1" parent="1"> | ||
| <mxGeometry x="40" y="85" width="120" height="255" as="geometry" /> | ||
| </mxCell> | ||
| </root> | ||
| </mxGraphModel> | ||
| </diagram> | ||
| </mxfile> |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,123 @@ | ||||
| require 'csv' | ||||
|
|
||||
| ##################### wave 1 | ||||
| def draw_letters | ||||
| letter_pool = [] | ||||
|
|
||||
| 9.times {letter_pool.push("A", "I")} | ||||
| 2.times {letter_pool.push("B", "C", "F", "H", "M", "P", "V", "W", "Y" )} | ||||
| 4.times {letter_pool.push("D", "L", "S", "U")} | ||||
| 12.times {letter_pool << "E"} | ||||
| 3.times {letter_pool << "G"} | ||||
| letter_pool << "J" | ||||
| letter_pool << "K" | ||||
| 6.times {letter_pool.push("N", "R", "T")} | ||||
| 8.times {letter_pool << "O"} | ||||
| letter_pool.push("Q", "X", "Z") | ||||
|
|
||||
| drawn_letters = letter_pool.sample(10) | ||||
| return drawn_letters | ||||
| end | ||||
|
|
||||
| ####################### wave 2 | ||||
|
|
||||
| def uses_available_letters?(input, letters_in_hand) | ||||
| input_letters = input.split("") | ||||
| if input_letters.length > 10 | ||||
| puts "Oops, too many letters! You only have 10 :)" | ||||
|
Collaborator
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. You don't need to do
Suggested change
|
||||
| return false | ||||
| end | ||||
|
|
||||
| if input_letters == input_letters.uniq | ||||
| if (input_letters - letters_in_hand).empty? | ||||
| return true | ||||
| else | ||||
| return false | ||||
| end | ||||
| else | ||||
| counts_input = input_letters.group_by {|letter| letter} | ||||
| counts_letterinhand = letters_in_hand.group_by {|letter| letter} | ||||
|
Comment on lines
+38
to
+39
Collaborator
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. Clever use of |
||||
|
|
||||
| counts_input.each_pair do |letter, count| | ||||
| if counts_input[letter].length > counts_letterinhand[letter].length | ||||
| puts "Looks like you use #{letter} too many times." | ||||
|
Collaborator
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.
Suggested change
|
||||
| return false | ||||
| end | ||||
| end | ||||
|
|
||||
| return true | ||||
| end | ||||
|
|
||||
| end | ||||
|
|
||||
| ############################# wave 3 | ||||
| def score_word(word) | ||||
|
Collaborator
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. 👍 |
||||
| word = word.upcase | ||||
| input_letters = word.split("") | ||||
| score = 0 | ||||
| if input_letters.length > 6 | ||||
| score += 8 | ||||
| end | ||||
|
|
||||
| input_letters.each do |letter| | ||||
|
|
||||
| case letter | ||||
| when "A", "E", "I", "O", "U", "L", "N", "R", "S", "T" | ||||
| score += 1 | ||||
| when "D", "G" | ||||
| score += 2 | ||||
| when "B", "C", "M", "P" | ||||
| score += 3 | ||||
| when "F", "H", "V", "W", "Y" | ||||
| score += 4 | ||||
| when "K" | ||||
| score += 5 | ||||
| when "J", "X" | ||||
| score += 8 | ||||
| when "Q", "Z" | ||||
| score += 10 | ||||
| end | ||||
|
|
||||
|
|
||||
| end | ||||
|
|
||||
| return score | ||||
| end | ||||
|
|
||||
| ######################### wave 4 | ||||
| def highest_score_from(words) | ||||
|
Comment on lines
+87
to
+88
Collaborator
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. Nice uses of |
||||
| word_score = {} | ||||
| words.each do |word| | ||||
| word_score[word] = score_word(word) | ||||
| end | ||||
| winner_random = word_score.max_by {|word, score| score} | ||||
| winner_random[0] = winner_random[0].to_s | ||||
|
|
||||
| winner_all = word_score.select {|word, score| score == winner_random[1]} | ||||
| winner_final = {} | ||||
|
|
||||
| if winner_all.length > 1 | ||||
| ten_letter_words = winner_all.select {|word, score| word.size == 10} | ||||
| if ten_letter_words.empty? | ||||
| winner_final_candidates = winner_all | ||||
| else | ||||
| winner_final_candidates = ten_letter_words | ||||
| end | ||||
|
|
||||
| winner_final[:word], winner_final[:score] = winner_final_candidates.min_by{|word, score| word.length} | ||||
| else | ||||
| winner_final[:word] = winner_all.keys.join | ||||
| winner_final[:score] = winner_all.values.join.to_i | ||||
| end | ||||
|
|
||||
| return winner_final | ||||
|
|
||||
| end | ||||
|
|
||||
| ######################### wave 5 | ||||
| def is_in_english_dict?(input) | ||||
|
Comment on lines
+117
to
+118
Collaborator
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. Well done, you got the optional dictionary! |
||||
|
|
||||
| dictionary = CSV.read('../assets/dictionary-english.csv').map { |word| word.to_s } | ||||
| return dictionary.include?(input) | ||||
|
|
||||
| end | ||||
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.
👍