Last active
December 16, 2020 13:11
Revisions
-
exchez revised this gist
Nov 12, 2015 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ class Hack def initialize words @words = words.downcase.split(/\/|\s|,\s|\,/) @splitwords = [] @words.each { |w| @splitwords << w.split('') } show_likely @@ -37,7 +37,7 @@ def show_likely end def comb str hint = str.downcase.split(/\/|\,|\s|,\s/) @match_matrix.delete(hint[0]) @match_matrix.each_value do |v| if v[hint[0]] != hint[1].to_i @@ -68,4 +68,4 @@ def output puts "Input your word and likeness with a slash between (ex: foot/2) or quit to exit:" input = gets.chomp h.comb(input) end -
exchez revised this gist
Nov 12, 2015 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,4 @@ class Hack def initialize words @words = words.downcase.split(/\/|\s|,\s/) @@ -70,4 +68,4 @@ def output puts "Input your word and likeness with a slash between (ex: foot/2) or quit to exit:" input = gets.chomp h.comb(input) end -
exchez revised this gist
Nov 12, 2015 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,9 @@ class Hack attr_reader :match_matrix, :list def initialize words @words = words.downcase.split(/\/|\s|,\s/) @splitwords = [] @words.each { |w| @splitwords << w.split('') } show_likely @@ -42,8 +43,8 @@ def comb str @match_matrix.delete(hint[0]) @match_matrix.each_value do |v| if v[hint[0]] != hint[1].to_i @match_matrix.each_value {|q| q.delete(@match_matrix.key(v))} @match_matrix.delete(@match_matrix.key(v)) end end @match_matrix.each_value {|v| v.delete(hint[0])} -
exchez revised this gist
Nov 12, 2015 . 1 changed file with 11 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ class Hack attr_reader :match_matrix, :list def initialize words @words = words.downcase.split('/') @@ -14,7 +15,8 @@ def deduct end end end def show_likely @match_matrix = {} @words.each do |w| @@ -34,34 +36,37 @@ def show_likely deduct output end def comb str hint = str.downcase.split('/') @match_matrix.delete(hint[0]) @match_matrix.each_value do |v| if v[hint[0]] != hint[1].to_i @match_matrix.delete(@match_matrix.key(v)) @match_matrix.each_value {|q| q.delete(@match_matrix.key(v))} end end @match_matrix.each_value {|v| v.delete(hint[0])} output end def output puts "Here's what we got left..." @match_matrix.each_key do |k| print "#{k}".ljust(15) print "#{@match_matrix[k].values.count { |v| v > 0}-1} word matches " print "#{(@match_matrix[k].values.inject(0) {|sum, v| sum + v})-(k.length)} letter matches" print "\n" end end end puts "enter list separated by a dash, no spaces (ex: dog/cat/hop)" input = gets.chomp h = Hack.new(input) puts "\n" while input != "quit" puts "Input your word and likeness with a slash between (ex: foot/2) or quit to exit:" input = gets.chomp h.comb(input) end -
exchez revised this gist
Nov 11, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -61,7 +61,7 @@ def output h = Hack.new(input) puts "\n" while input != "quit" puts "Input your guess and likeness with a slash between (ex: foot/2) or quit to exit:" input = gets.chomp h.comb(input) end -
exchez revised this gist
Nov 11, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -56,7 +56,7 @@ def output end end puts "enter list separated by a slash, no spaces (ex: dog/cat/hop)" input = gets.chomp h = Hack.new(input) puts "\n" -
exchez revised this gist
Nov 11, 2015 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,8 +14,7 @@ def deduct end end end def show_likely @match_matrix = {} @words.each do |w| @@ -35,7 +34,7 @@ def show_likely deduct output end def comb str hint = str.downcase.split('/') @match_matrix.delete(hint[0]) -
exchez revised this gist
Nov 11, 2015 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ class Hack def initialize words @words = words.downcase.split('/') -
exchez revised this gist
Nov 11, 2015 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,10 +4,8 @@ class Hack def initialize words @words = words.downcase.split('/') @splitwords = [] @words.each { |w| @splitwords << w.split('') } show_likely end def deduct -
exchez revised this gist
Nov 11, 2015 . 1 changed file with 1 addition and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,14 +2,9 @@ class Hack attr_reader :match_matrix, :list def initialize words @words = words.downcase.split('/') @splitwords = [] @words.each do { |w| @splitwords << w.split('') } end show_likely -
exchez created this gist
Nov 11, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,76 @@ class Hack attr_reader :match_matrix, :list def initialize words @solutions = [] @words = words.downcase.split('/') @splitwords = [] @words.each do |w| @splitwords << w.split('') end @words.each do |w| @solutions << w end show_likely end def deduct @match_matrix.each_key do |w| if @match_matrix[w].values.inject(0) {|sum, v| sum + v} <= w.length @match_matrix.delete(w) end end end def show_likely @match_matrix = {} @words.each do |w| @words.each_with_index do |ww, i| i == 0 ? @match_matrix[w] = {ww => 0} : @match_matrix[w].merge!({ww => 0}) end end @splitwords.each do |word| word.each_with_index do |letter, i| @splitwords.each do |wordword| if letter == wordword[i] @match_matrix[word.join][wordword.join] += 1 end end end end deduct output end def comb str hint = str.downcase.split('/') @match_matrix.delete(hint[0]) @match_matrix.each_value do |v| if v[hint[0]] != hint[1].to_i @match_matrix.delete(@match_matrix.key(v)) end end output end def output puts "Here's what we got left..." @match_matrix.each_key do |k| print "#{k}".ljust(15) print "#{(@match_matrix[k].values.inject(0) {|sum, v| sum + v})-(k.length)} total matches" print "\n" end end end puts "enter list separated by a dash, no spaces (ex: dog/cat/hop)" input = gets.chomp h = Hack.new(input) puts "\n" while input != "quit" puts "Input your word and likeness with a slash between (ex: foot/2) or quit to exit:" input = gets.chomp h.comb(input) end