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
// Game of Life cell matrix wrapped in an object | |
type Matrix = { | |
m: boolean[][] | |
wrap: boolean; | |
}; | |
// Makes matrix of desired width x height plus an initial configuration of "on" cells and wrap-around flag | |
function makeMatrix(width: number, height: number, initialConfig: [number, number][], wrap: boolean) { | |
let m = new Array<boolean[]>(height); |
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
MIN_MERGE = 32 | |
MIN_GALLOP = 7 | |
minGallop = MIN_GALLOP | |
def minRunLength(n): | |
r = 0 | |
while n >= MIN_MERGE: | |
r |= n & 1 | |
n >>= 1 |
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
Timestamp | KeyType | KeyValue | EventType | EventProperties | |
---|---|---|---|---|---|
2020-06-01T00:00:00Z | CustomerId | 1001 | Subscription-Create | {"SubscriptionId": "fd10b613-8378-4d37-b8e7-bb665999d122"} | |
2020-07-01T00:00:00Z | Support-CustomerId | 21 | SupportTicket-Opened | {"Message": "..."} | |
2020-07-03T00:00:00Z | Support-CustomerId | 21 | SupportTicket-Opened | {"Message": "..."} | |
2020-07-05T00:00:00Z | Support-CustomerId | 21 | SupportTicket-Closed | {"Message": "..."} | |
2020-07-19T00:00:00Z | Support-CustomerId | 21 | SupportTicket-Closed | {"Message": "..."} | |
2020-07-19T00:00:00Z | CustomerId | 1001 | Subscription-Close | {"SubscriptionId": "fd10b613-8378-4d37-b8e7-bb665999d122"} |
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
GroupId | KeyType | KeyValue | |
---|---|---|---|
f03c9e90-5d97-4a11-82aa-480f74325a2c | CookieId | 657d31b9-0614-4df7-8be6-d576738a9661 | |
62159798-2447-41e3-b0ef-f1a239d55978 | CookieId | 0864c60d-cc36-4384-81a3-e4c1eee14fe7 | |
f03c9e90-5d97-4a11-82aa-480f74325a2c | ProfileId | 10002 | |
62159798-2447-41e3-b0ef-f1a239d55978 | ProfileId | 10003 | |
f03c9e90-5d97-4a11-82aa-480f74325a2c | emma@hotmail.com | ||
62159798-2447-41e3-b0ef-f1a239d55978 | oliver@hotmail.com | ||
f03c9e90-5d97-4a11-82aa-480f74325a2c | SupportCustomerId | 21 | |
62159798-2447-41e3-b0ef-f1a239d55978 | SupportCustomerId | 22 | |
f03c9e90-5d97-4a11-82aa-480f74325a2c | CustomerId | 1001 |
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
git log --diff-filter=D --name-only --pretty="format:" > ..\FILES | |
for /f "tokens=*" %%a in (..\FILES) do ( | |
git filter-branch --tag-name-filter cat --index-filter "git rm -r --cached --ignore-unmatch %%a" --prune-empty -f -- --all | |
) |
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
#include <array> | |
#include <fstream> | |
#include <iostream> | |
using namespace std; | |
const size_t memory_size = 1024; | |
template <typename It> | |
It& skip(It&& it, char from, char to) { |
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
#include <type_traits> | |
// Natural numbers | |
struct nat { }; | |
// Typed only if T is derived from nat | |
template <typename T> | |
using nat_only = std::enable_if_t<std::is_base_of<nat, T>::value>; | |
// Zero is a natural number |
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
// Since generics in Java are removed at compile-time, we cannot overload methods | |
// based on generic types | |
// Below class does not compile: | |
// Erasure of method Foo(T1) is the same as another method in type Test<T1,T2> | |
// Erasure of method Foo(T2) is the same as another method in type Test<T1,T2> | |
class Generic<T1, T2> { | |
void Foo(T1 arg) { | |
} | |
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
class Graph: | |
def __init__(self, nodes=dict(), edges=[]): | |
self.nodes = nodes | |
self.edges = edges | |
self.colors = len(set(nodes.values())) | |
def connected(self, node): | |
for edge in self.edges: | |
if edge[0] == node: | |
yield edge[1] |
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
components = [tuple(map(int, line.strip().split('/'))) for line in open("input.txt").readlines()] | |
def best_bridge(end, components): | |
result = 0 | |
for i, c in enumerate(components): | |
if end == c[0]: | |
new_end = c[1] | |
elif end == c[1]: | |
new_end = c[0] | |
else: |
NewerOlder