http://www.jitbit.com/news/181-jitbits-sql-interview-questions/
employees
- employee_id
- department_id
- boss_id
- name
| class RPNCalculator | |
| def evaluate(rpn) | |
| expression = rpn.split | |
| stack = Array.new | |
| unless expression.count > 1 | |
| return expression[0].to_i | |
| end | |
| expression.each do |e| |
| cities = {'CA' => 'San Francisco', 'MI' => 'Detroit', 'FL' => 'Jacksonville'} | |
| cities['NY'] = 'New York' | |
| cities['OR'] = 'Portland' | |
| def find_city(map, state) | |
| if map.include? state | |
| return map[state] | |
| else | |
| return "Not found." |
| puts | |
| print "What's your name? " | |
| name = gets.chomp | |
| puts "Hi, #{name}, welcome to Blackjack!" | |
| puts | |
| def random_cards() | |
| first_card = Random.rand(1..10) | |
| second_card = Random.rand(1..10) | |
| return both_cards = {"first" => first_card, "second" => second_card} |
| #Using if statements, write a loop that prints out a range of numbers | |
| #that can be divided by 7 without any remainder. | |
| def seven(nums) | |
| for x in nums | |
| puts x if x % 7 == 0 | |
| end | |
| end | |
| def reverse_an_array_the_hard_way(array) | |
| new_array = [] | |
| length = array.length | |
| for x in (1..length) | |
| new_array << array.pop | |
| end | |
| p new_array | |
| end | |
| def recurse(count=0) | |
| return if count == 10 | |
| puts count | |
| count += 1 | |
| recurse(count) | |
| end | |
| recurse |
| http://www.backwardsteps.com/Recursion.pdf |
http://www.jitbit.com/news/181-jitbits-sql-interview-questions/
employees
| import os | |
| import random | |
| deck = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]*4 | |
| def deal(deck): | |
| hand = [] | |
| for i in range(2): | |
| random.shuffle(deck) | |
| card = deck.pop() |
Watch the video if you need help. Keep in mind that your output will look different than mine as I already have these installed on my machine - http://screencast.com/t/NjkrLsKH1gZo
Download setuptools for Python 2.7
curl -o setuptools-0.6c11-py2.7.egg https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg#md5=fe1f997bc722265116870bc7919059ea
Install setup tools