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
| #1. Count the votes for Sen. Olympia Snowe, whose id is 524. | |
| SELECT COUNT(*) FROM votes WHERE politician_id = 524 ; | |
| #2. Now do that query with a JOIN statement without hard-coding the id 524 explicitly, querying both the votes and congress_members table. | |
| SELECT COUNT(*) FROM congress_members INNER JOIN votes ON congress_members.id = votes.politician_id WHERE congress_members.name = "Sen. Olympia Snowe" ; | |
| #3. How about Rep. Erik Paulsen? How many votes did he get? | |
| SELECT COUNT(*) FROM congress_members INNER JOIN votes ON congress_members.id = votes.politician_id WHERE congress_members.name = "Rep. Erik Paulsen" ; | |
| #4. Make a list of Congress members that got the most votes, in descending order. Exclude the create_at and updated_at columns. |
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
| require 'Benchmark' | |
| class Sudoku | |
| attr_accessor :puzzle | |
| def initialize | |
| @puzzle = '' | |
| @game = Array.new(9) | |
| @game.map! { Array.new(9) } | |
| 9.times do |i| |