This file contains 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
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCr6VkBkvGW2RrDt0X+6HpEnhpWvKq1nqfczVxb0FXm00l5Fu68+kAmK+QOCHnRBMP9LZU/tsHWxjxiN6tKD1sORn4e72QMvXk53q4VJhOSJLA9yyPsrzCAF1wIHA7yQvm3lxQ23e+Vtzwnl/bjyrxUeRO8H1z2v62pJ6KpX3kdVV0KTZouT3DFiuQmfT+CasCLKCUX4FyUxoT08MwapX5MFVetiRJ8CLKlL6DUBx5HuYUwi9cb8oZIv11ffG3QJDCBhJWrkDDa4RihC01MWztWxiDffpCCOiwwlmOW08PaLxuP922ZSBJwMj34Iu3f8X0HP/qByUdq9DQtFGyp+wC1eG3OAqnZF+oN0BKurzwfYk8DHiUoPernxeoADfJwvsn1q7cQ9nQxVtg9NFP4bq4ZRkWu5aU9GRFVDvDw1NDLTRAbvrHv2L/Jfj0dLlBjhvJww68qKeClKiAKEGSoizsm59tbHBVP8h76k11JoP7o0VSML1FzxuJkoAh8MjrIcz92tHVgX+MI+BYmZLwBxwJOoB0aydpiL1GTU9HBNIY5rPKdoMOC6iWGS737CqPXHL+MACeDBMMbAz3gcGmFynUd8VHOfmX7puR0oOD3XwuymmbwIChYe/UL314Yp9JWtTzAaWQMeLldi3LXcirjp+x00vPGU+gdlYnhC08n5KKUpQ== [email protected] |
This file contains 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
f_lines = File.read("input.txt").lines.map(&:chomp) | |
result_lines = f_lines.map do |line| | |
# Extract all angle brackets, and sort them. | |
# We use this as a "stack" of angle brackets that we can pull from | |
# when we need an angle bracket in the final result | |
angle_brackets = line.scan(/[<>]/).sort | |
line_chars = line.chars.map do |c| | |
c == " " ? " " : angle_brackets.shift | |
end |
This file contains 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
# Brute force | |
# Times out | |
# O(n^2) time, O(1) space | |
def max_area(heights) | |
max = 0 | |
current_left_index = nil | |
current_right_index = nil | |
heights.each_with_index do |num1, index1| | |
next if num1 == 0 |
This file contains 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
# @param {Integer[][]} image | |
# @param {Integer} sr | |
# @param {Integer} sc | |
# @param {Integer} new_color | |
# @return {Integer[][]} | |
def flood_fill(image, sr, sc, new_color) | |
x_max = image.length - 1 | |
y_max = image[0].length - 1 | |
stack = [[sr, sc]] |
This file contains 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 "json" | |
require "byebug" | |
mapping = {} | |
list = File.read("9_input.txt").lines.map(&:chomp) | |
list.each do |l| | |
a, _, b, _, number = l.split(" ") | |
mapping[[a, b]] = number.to_i |
This file contains 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
input = File.read("7_input.txt").gsub("OR", "|").gsub("AND", "&").gsub("LSHIFT", "<<").gsub("RSHIFT", ">>").gsub("NOT", "~").lines.map(&:chomp) | |
@map = {} | |
input.each do |expression| | |
left_side, right_side = expression.split("->") | |
@map[right_side.strip] = left_side | |
end | |
@memo = {} | |
def evaluate(label) |
This file contains 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
# Strategy: | |
# 1. Find location of each number | |
# 2. For each combination of 2 numbers, find the distance between them in the graph. Use BFS because I'm lazy | |
# 3. Brute force the shortest path that goes through each of the 7 numbers. | |
# - For each permutation of 7 numbers that begins with 0, sum up the distances for each hop. | |
# - E.g. [0, 2, 5, ...] == distance(0, 2) + distance(2, 5) + ... | |
# - Find min distance among all permutations | |
require "byebug" | |
input = File.read("input.txt").lines.map(&:strip).map(&:chars) |
This file contains 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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEditor; | |
using UnityEngine; | |
public static class TakeScreenshot | |
{ | |
// See http://docs.unity3d.com/ScriptReference/MenuItem.html for docs on [MenuItem] hotkeys | |
[MenuItem("Helpers/Screenshot _g")] | |
public static void Screenshot() |
This file contains 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
public static class RenderQueueSorter | |
{ | |
private static int nextRenderQueue = 5; // Don't go over 2500! Or we leak into transparent queues | |
private static Dictionary<Mesh, Material> _meshToMatMap = new Dictionary<Mesh, Material>(); | |
public static Material SortedMaterialFromMesh(Mesh mesh, Material sharedMaterial) | |
{ | |
if (_meshToMatMap.ContainsKey(mesh)) return _meshToMatMap[mesh]; | |
return GenerateMaterialForMesh(mesh, sharedMaterial); |
This file contains 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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class ExceptionManager : MonoBehaviour | |
{ | |
private const int ExceptionsPerCooldown = 5; | |
private const float CooldownTime = 5f; | |
private int _exceptionsLeftBeforeTimeout = ExceptionsPerCooldown; |
NewerOlder