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
Duration | |
45 minutes | |
Problem Description | |
This game is about calculating the next generation of Conway’s game of life, given any starting position. See http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life for background. | |
You start with a two dimensional grid of cells, where each cell is either alive or dead. In this version of the problem, the grid is finite, and no life can exist off the edges. | |
When calculating the next generation of the grid, follow these rules: | |
1. Any live cell with fewer than two live neighbours dies, as if caused by underpopulation. | |
2. Any live cell with more than three live neighbours dies, as if by overcrowding. | |
3. Any live cell with two or three live neighbours lives on to the next generation. |
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
import pandas | |
import fastavro | |
def avro_df(filepath, encoding): | |
# Open file stream | |
with open(filepath, encoding) as fp: | |
# Configure Avro reader | |
reader = fastavro.reader(fp) | |
# Load records in memory | |
records = [r for r in reader] |
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
// | |
val prop=new java.util.Properties() | |
prop.put("user","username") | |
prop.put("password","yourpassword") | |
val url="jdbc:mysql://host:port/db_name" | |
val df=spark.read.jdbc(url,"table_name",prop) | |
df.show() | |
// |
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
8 | |
4 | |
3 |
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
x = dict() | |
def update(x, id, location, time): | |
locs = x.get(id) | |
if (locs is None): | |
locs = dict() | |
locs[location] = [time] | |
x[id] = locs | |
else: | |
times = locs.get(location) |
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
import numpy as np | |
import torch | |
# 9 data points: one x1 x2 y | |
xy = np.matrix ([ | |
[1.0, 0.0, 0.0, 0.5], | |
[1.0, 0.0, 0.5, 0.3], | |
[1.0, 0.0, 1.0, 0.2], | |
[1.0, 0.5, 0.0, 0.8], | |
[1.0, 0.5, 0.5, 0.5], |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
As configured in my dotfiles.
start new:
tmux
start new with session name:
OlderNewer