Skip to content

Instantly share code, notes, and snippets.

View vickean's full-sized avatar

Victor Kean vickean

  • Petaling Jaya, Selangor, Malaysia
View GitHub Profile
#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.
require 'Benchmark'
class Sudoku
attr_accessor :puzzle
def initialize
@puzzle = ''
@game = Array.new(9)
@game.map! { Array.new(9) }
9.times do |i|