Created
February 27, 2020 18:38
-
-
Save profh/2f94a57e7f7b0de938812c9de34982b5 to your computer and use it in GitHub Desktop.
Arrays and hashes for the 2020 midterm in 67-272
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
characters = { kirk: :TOS, spock: :TOS, picard: :TNG, janeway: :VOY, scotty: :TOS, sisko: :DS9, | |
kira: :DS9, chakotay: :VOY, seven: :VOY, dax: :DS9, tuvok: :VOY, tpol: :ENT, | |
riker: :TNG, troi: :TNG} | |
series = { TOS: "The Original Series", NTG: "The Next Generation", DS9: "Deep Space 9", | |
VOY: "Voyager", ENT: "Enterprise" } | |
runtimes = { TOS: [1966, 1969], NTG: [1987, 1994], DS9: [1993, 1999], | |
VOY: [1995, 2001] , ENT: [2001, 2004] } | |
captains = { kirk: :ncc1701, sisko: :nx74205, janeway: :ncc74656, picard: :ncc1701d } | |
first_officers = [:spock, :kira, :chakotay, :riker, :tpol] | |
vulcans = [:spock, :tuvok, :tpol] | |
humans = [:sisko, :kirk, :picard, :chakotay, :janeway, :riker, :an, :seven] | |
females = [:kira, :dax, :tpol, :janeway, :troi, :seven, :an] | |
ships = { ncc1701: "Enterprise", nx74205: "Defiant", ncc1701d: "Enterprise", ncc74656: "Voyager", nx01: "Enterprise" } | |
# ============================== | |
p ships.values.sort | |
puts | |
p ships.select{ |s| !captains.values.include?(s) } | |
puts | |
series.each do |show| | |
puts "#{show[1]}: #{(runtimes[show[0]][1] - runtimes[show[0]][0])}" | |
end | |
puts | |
p characters.select{ |c| females.include?(c) }.select{ |c| humans.include?(c) }.keys.sort | |
p females.select{|f| humans.include?(f) }.sort # will include :an, who is not a character | |
puts | |
p first_officers.select{|fo| vulcans.include?(fo)}.map{|fo| [fo, characters[fo]]}.to_h | |
p first_officers.select{|fo| vulcans.include?(fo)}.map{|fo| [fo, characters[fo]]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment