Skip to content

Instantly share code, notes, and snippets.

🔬
Blinded by Science!

# Chris Barrickcbarrick

🔬
Blinded by Science!
• Sort options
Last active Jul 5, 2019
View chapters.py
 #!/usr/bin/env python3 class Position: def __init__(self, file, offset): '''A position has both a file and offset''' self.file = file self.offset = offset def __lt__(self, other): '''Positions are ordered first by file then by offset.'''
Last active Aug 27, 2018
Matrix chain multiplication test cases
View Daily Programmer - Matrix Chain Multiplication.md

# Description

Consider the problem of matrix multiplication. A matrix `A` of shape `(n, m)` may be multiplied by a matrix `B` of shape `(m, p)` to produce a new matrix `A * B` of shape `(n, p)`. The number of scalar multiplications required to perform this operation is `n * m * p`.

Now consider the problem of multiplying three or more matrices together. It turns out that matrix multiplication is associative, but the number of scalar multiplications required to perform such operation depends on the association.

For example, consider three matrices of the following shapes:

``````A: (3, 5)
B: (5, 7)
``````
View tour.pl
 #!/usr/bin/env swipl :- initialization(main, main). :- use_module(library(clpfd)). :- use_module(library(dcg/basics)). %% tour(Shape, Tour) % Tour is a tour of a chess board of the given Shape.
Created Nov 21, 2017
mines problem
View mines.py
 import re import sys import numpy as np def read(stream=sys.stdin): '''Read some input to get a matrix of mines. Each row of the mine matrix is a different mine. The first column is the current gold value. The second column is the decay rate per travel step.
Last active Oct 12, 2017
ncdump and usage code
View ncdump
 \$ ncdump -h NAM-NMM/nam.20161111/nam.t00z.awphys.tm00.nc netcdf nam.t00z.awphys.tm00 { dimensions: reftime = 1 ; z_HTGL3 = 2 ; z_ISBL3 = 5 ; z_ISBL2 = 42 ; z_HTGL2 = 2 ; z_HTGL1 = 2 ; z_ISBL1 = 39 ;
Last active Dec 26, 2016
View Daily Programmer #296 Hard.md

# Description

The puzzle is a 4x4 grid of numbers between 1 and 5. 4-connected tiles of same number form a group. For example, the following grid has five groups:

``````1 2 2 1
1 3 3 1
1 3 3 2
2 2 2 2
``````
Last active May 29, 2016
An experiment to combine hashing with a floating point address space
View float_address.go
 // This is an experiment to combine hashing with a floating point address space. // // # The Problem: // // In a binary search tree, we wish to assign each node a unique address such // that nodes which sort to the right have higher addresses than nodes that sort // to the left. We want to generate the address when the node is inserted, and // we want addresses to be stable, meaning that new insertions will not effect // existing addresses. We also want finite bounds on the address space. //
You can’t perform that action at this time.