Skip to content

Instantly share code, notes, and snippets.

def consumer1() -> int:
...
... = producer("A")
...
def consumer2() -> int:
...
... = producer("B")
...
# Because the strands are very long, in order to sequence DNA,
# labs will first split the strands into many small overlapping pieces.
# Once they're sequenced, the pieces need to be recombined.
# Write a function that recombines overlapping pieces into a single strand of DNA.
# Each sequenced piece contains Adenine, Thynine, Cystosine and Guanine represented by 'A', 'T', 'C', and 'G', respectively.
# Two pieces can connect if they overlap at least one base pair.
# Assume that there is only one way to combine all the pieces into a single strand.
from functools import reduce, partial
def eastward(level, position):
return (2**(level - 1)) * (int(position) % 2)
def southward(level, position):
if int(position) < 2:
return 0
else:
return 2**(level - 1)
def absolute_position(quadkey, x=0, y=0):
north_south = {
'0': '2',
'2': '0',
'1': '3',
'3': '1'
}
east_west = {
'2': '3',
'3': '2',
### Keybase proof
I hereby claim:
* I am desmondrawls on github.
* I am desmond22 (https://keybase.io/desmond22) on keybase.
* I have a public key ASATQfxOZQvwbbvfaK23X3PKMxL_MVkvz3eDlKI5yP8aMwo
To claim this, I am signing this object:
import {fizzbuzz} from './fizzbuzz'
describe('fizzbuzz', () => {
describe('numbers that are not multiples of 3 or 5', () => {
it.each([1,2,4,7,8,11])('returns %j unchanged', input => {
expect(fizzbuzz(input)).toEqual(input)
})
})
describe('numbers that are multiples of 3 but not 5', () => {
export const fizzbuzz = (i) => {
var thingsItsNotDivisibleBy = []
var stringI = i.toString()
var tempI = i
var elementsOfStringI = () => {
var elements = []
for(i = 0; i < stringI.length; i++)
if(parseInt(stringI[i]) != 0) elements = [...elements, parseInt(stringI[i])]
return elements
}
@desmondrawls
desmondrawls / path-finder.test.ts
Created January 3, 2019 00:30
type safe paths for use with redux
import { Path, State, initialState } from "./PathFinder";
describe('PathFinder', () => {
it('works', () => {
let actual = new Path<State>(initialState).path("driverInfo").path("gender").action("unicorn");
expect(actual.payload).toEqual({ "driverInfo": { "gender": "unicorn" } });
});
});
@desmondrawls
desmondrawls / bad_monad.go
Created February 9, 2018 05:18
Bad Golang Monads
package main
import (
"errors"
"fmt"
"strings"
)
func main() {
fmapOutcome, err := fmap(getName, isValidName)()
interface Either<V> {
map: <T>(f: (V) => T) => Either<T>
fold: <L,R>(l: (V) => L, r: (V) => R) => L | R
}
function left<V>(x: V): Either<V> {
return {
map: _ => left(x),
fold: (l, r) => l(x)
}