Last active
April 4, 2019 00:36
-
-
Save tenderlove/f6d47e25c7cf8a7d5216 to your computer and use it in GitHub Desktop.
hack fallout terminals
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 characters
| ## | |
| # Program to help you hack terminals in Fallout | |
| # | |
| # Usage: | |
| # | |
| # Make your first guess in the terminal, and it will give you a score. Then | |
| # run this program with a '/' separated list of possible words, and another | |
| # '/' separated list of words and scores where the word and score are separated | |
| # by a ':' | |
| # | |
| # In this example, the words shown in my terminal were: | |
| # | |
| # CASTE | |
| # LINES | |
| # ALTER | |
| # OFFER | |
| # KEEPS | |
| # HAVEN | |
| # SPEED | |
| # BASIC | |
| # | |
| # The first word I chose was "CASTE", and the terminal said it scored 0, so | |
| # I ran this: | |
| # | |
| # ``` | |
| # $ ruby fallout.rb CASTE/LINES/ALTER/OFFER/KEEPS/HAVEN/SPEED/BASIC CASTE:0 | |
| # ["LINES", "ALTER", "OFFER", "KEEPS", "SPEED"] | |
| # ``` | |
| # | |
| # Next I guessed LINES, and the score was 1, so I ran this: | |
| # | |
| # ``` | |
| # $ ruby fallout.rb CASTE/LINES/ALTER/OFFER/KEEPS/HAVEN/SPEED/BASIC CASTE:0/LINES:1 | |
| # ["ALTER", "OFFER", "KEEPS", "SPEED"] | |
| # ``` | |
| # | |
| # Next I guessed ALTER, and the score was 0, so I ran this: | |
| # | |
| # ``` | |
| # $ ruby fallout.rb CASTE/LINES/ALTER/OFFER/KEEPS/HAVEN/SPEED/BASIC CASTE:0/LINES:1/ALTER:0 | |
| # ["KEEPS"] | |
| # ``` | |
| # | |
| # The only choice left is "KEEPS", and it was the correct answer! | |
| def hack w, t | |
| t.inject(w - t.map(&:first)) { |c, (w1, s)| | |
| c.find_all { |w2| | |
| s.to_i == w1.chars.zip(w2.chars).count { |a,b| a == b } | |
| } | |
| } | |
| end | |
| p hack ARGV[0].split('/'), ARGV[1].split('/').map { |x| x.split(':') } |
eileencodes
commented
Nov 16, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment