Skip to content

Instantly share code, notes, and snippets.

@jckw
jckw / pancakes.py
Created April 10, 2016 10:09
Python3 solution to the Revenge of the Pancakes Google Code Jam 2016 problem (qual round, problem B).
import numpy as np
no = int(input())
for i in range (1, no + 1):
case_text = "Case #" + str(i) + ": "
pcakes = input()
height = len(pcakes)
bool_stack = []
@jckw
jckw / sheep.py
Created April 10, 2016 10:12
Python3 solution to the Counting Sheep Google Code Jam problem (qual round, problem A)
no = int(input())
final = [True, True, True, True, True,
True, True, True, True, True]
for i in range(0, no):
total = 0
number = int(input()) # int
strNum = str(number)
nums = [False, False, False, False, False,
@jckw
jckw / rle.py
Created April 20, 2016 18:21
Basic text RLE compression (despite increasing file size in most cases)
import sys
dotTxt = sys.argv[1]
textfile = open(dotTxt)
string = textfile.read()
compressed = []
noInRow = 1
import pi2go, time
def endCheck():
start = time.time()
# While still on the line, go forwards
while not pi2go.irLineLeft and not pi2go.irLineRight():
forward(slow)
# Now off the line
@jckw
jckw / flushroute.sh
Created April 7, 2017 09:03
Fix for OpenVPN/ Tunnelblick: `Can't assign requested address`
# en1 for WLAN
# en0 for Ethernet
sudo ifconfig en1 down
sudo route flush
sudo ifconfig en1 up
@jckw
jckw / mergesort.py
Created May 31, 2017 17:19
Simple merge sort demonstration with some explanation
def mergeSort(sorting, first, last):
"""Recursive merge sort function that takes the indices of the
first and last values that are being sorted in this pass and methodically
splits down the `sorting` list, until it can start remerging the halves.
Recursion is the only way that merge sort makes sense. It's pretty neat.
"""
if first >= last:
# If the first and last pointers are the same or switched, we're done
@jckw
jckw / keybase.md
Created July 14, 2017 18:42
Keybase Proof

Keybase proof

I hereby claim:

  • I am jckw on github.
  • I am jckw (https://keybase.io/jckw) on keybase.
  • I have a public key ASCtgz5vmmZ7V8Zkz2pkpzBot92btUibusolJ9aaVXMpFgo

To claim this, I am signing this object:

@jckw
jckw / factors.lhs
Last active October 31, 2017 14:54
Practical 1: Factoring Numbers
Here is a simple method for finding the smallest prime factor of a positive
integer:
> factor :: Integer -> (Integer, Integer)
> factor n = factorFrom 2 n
> factorFrom :: Integer -> Integer -> (Integer, Integer)
> factorFrom m n | r == 0 = (m,q)
import React from "react"
import { Image } from "react-native"
const sources = [
{
height: 16,
uri:
"https://finimize-img-test.imgix.net/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1498671546682-94a232c26d17%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D987%26q%3D80?fit=crop&h=16&ixlib=python-3.0.0&w=16&s=60604503c09cf60a0a360046429a8fc0",
width: 16
},
@jckw
jckw / useConnection.js
Created June 3, 2020 12:00 — forked from jedwards1211/useConnection.js
useConnection (a React hook for infinite scrolling with Apollo, Relay-style Connections, and react-virtualized)
/**
* @flow
* @prettier
*/
import { type QueryRenderProps } from 'react-apollo'
import * as React from 'react'
import {
get,
takeRightWhile,