#Day 1
Matz Keynote
Static Type vs. Dynamic Type.
- Static Typing is against DRY.
- Soft typing:
- Type is represented by set of methods e.g name and # of arguments
- Class (as set of methods)
UNMARKED = ' ' | |
def board_to_s board | |
board.each_slice(3).map { |a, b, c| " #{a} | #{b} | #{c} " }.join("\n---|---|---\n") | |
end | |
def display board, after_board = nil | |
puts board_to_s board | |
puts after_board if after_board | |
end |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Ansi 0 Color</key> | |
<dict> | |
<key>Blue Component</key> | |
<real>0.19370138645172119</real> | |
<key>Green Component</key> | |
<real>0.15575926005840302</real> |
#Day 1
Matz Keynote
Static Type vs. Dynamic Type.
California is famous not only for its booming tech economy, controversial film industry, and yearlong summers, but due to its position on both the Pacific and North America plates, it experiences approximately 10,000 earthquakes each year. U.S. Geological Survey (USGS) provides near real time data and information and earth observations so that policy makers and the public have the understanding they need to enhance precedence, response and resilience.
You can find data of all earthquakes for the past 30 days here
Using the CSV above, write a Ruby program to find the first 10 cities and states with an earthquake that was felt in Los Angeles in a given date range. For the sake of over simplicity, let's assume a linear relationship between the magnitude of an earthquake and the distance it travels before it can be felt. Let's assume a magnitude-5 earthquake can be felt at up to a distance of 500 miles, ma
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# All Vagrant configuration is done below. The "2" in Vagrant.configure | |
# configures the configuration version (we support older styles for | |
# backwards compatibility). Please don't change it unless you know what | |
# you're doing. | |
Vagrant.configure(2) do |config| | |
# The most common configuration options are documented and commented below. | |
# For a complete reference, please see the online documentation at |
class Node: | |
def __init__(self, data, nextNode=None): | |
self.data = data | |
self.next = nextNode | |
def __str__ (self): | |
return str(self.data) | |
class PyLinkedList: | |
def __init__(self): |
class PyStack(): | |
def __init__(self): | |
self._items = [] | |
def push(self, item): | |
self._items.append(item) | |
def pop(self): | |
if not self.isEmpty(): | |
return self._items.pop() |
class Node: | |
def __init__(self, data): | |
self.data = data | |
self.left = None | |
self.right = None | |
# To allow duplicates we can store extra information i.e count | |
# to optimize memory and make search, insert, delete easier | |
#self.count = 1 | |
def insert(self, data): |
class Node: | |
def __init__(self, data): | |
self.data = data | |
self.parent = self | |
self.rank = 0 | |
class DisjointSet: | |
def __init__(self): | |
self.map = {} |
class TrieNode: | |
def __init__(self): | |
self.children = dict() | |
self.end_of_word = False | |
def leafNode(self): | |
return self.end_of_word | |
def freeNode(self): | |
return not any(self.children) |