This is explaining stuff relevant to AOC 2021 day 6
First lets do fibonacci numbers because it's smaller (2x2 matrix instead of 9x9) and it's familiar ground.
So you can implement fibs like this:
def fib(n):
import SwiftUI | |
extension Color { | |
static var background: Color { | |
return Color(uiColor: .systemBackground) | |
} | |
static var secondaryBackground: Color { | |
return Color(uiColor: .secondarySystemBackground) | |
} |
<html> | |
<head> | |
<title>Stripe Gradient</title> | |
</head> | |
<body> | |
<canvas id="gradient-canvas" data-js-darken-top data-transition-in> | |
<!-- | |
Remove data-js-darken-top to keep the same brightness in the upper part of the canvas | |
--> | |
</canvas> |
# On slow systems, checking the cached .zcompdump file to see if it must be | |
# regenerated adds a noticable delay to zsh startup. This little hack restricts | |
# it to once a day. It should be pasted into your own completion file. | |
# | |
# The globbing is a little complicated here: | |
# - '#q' is an explicit glob qualifier that makes globbing work within zsh's [[ ]] construct. | |
# - 'N' makes the glob pattern evaluate to nothing when it doesn't match (rather than throw a globbing error) | |
# - '.' matches "regular files" | |
# - 'mh+24' matches files (or directories or whatever) that are older than 24 hours. | |
autoload -Uz compinit |
# Some of these settings came from http://cheat.errtheblog.com/s/git | |
[alias] | |
br = branch | |
brav = branch -avv | |
brv = branch -vv | |
ci = commit | |
co = checkout | |
contributors = shortlog -se | |
df = diff |
# Copyright 2017, Google, Inc. | |
# Licensed under the Apache License, Version 2.0 (the "License") | |
FROM node:6-onbuild | |
EXPOSE 3000 | |
ENV LANGUAGE English | |
ENV API_KEY 123-456-789 |
# set the base image to Debian | |
# https://hub.docker.com/_/debian/ | |
FROM debian:latest | |
# replace shell with bash so we can source files | |
RUN rm /bin/sh && ln -s /bin/bash /bin/sh | |
# update the repository sources list | |
# and install dependencies | |
RUN apt-get update \ |
Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".
Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).
Let's dig in:
/***************************************************************************** | |
* QuantCup 1: Price-Time Matching Engine | |
* | |
* Submitted by: voyager | |
* | |
* Design Overview: | |
* In this implementation, the limit order book is represented using | |
* a flat linear array (pricePoints), indexed by the numeric price value. | |
* Each entry in this array corresponds to a specific price point and holds | |
* an instance of struct pricePoint. This data structure maintains a list |