Skip to content

Instantly share code, notes, and snippets.

View calda's full-sized avatar

Cal Stephens calda

View GitHub Profile
@khanlou
khanlou / Collection+Chunking.swift
Last active December 23, 2020 02:00
Collection chunking via @timvermeulen
extension Collection {
func chunk(size: Int) -> ChunkedCollection<Self> {
ChunkedCollection(self, size: size)
}
}
struct ChunkedCollection<Base: Collection>: Collection {
private let base: Base
@yurrriq
yurrriq / CGRect+Subract.swift
Created May 5, 2017 18:07
Subtract a CGRect from another
import CoreGraphics
public extension CGRect {
func subtract(_ subtrahend: CGRect, edge: CGRectEdge) -> CGRect {
guard intersects(subtrahend) else { return self }
let intersectSize: CGSize = intersection(subtrahend).size
let distance: CGFloat = (edge == .minXEdge || edge == .maxXEdge)
@calda
calda / BulgarianSolitairePlayer.java
Last active October 11, 2016 19:16
Statistical analysis of Bulgarian Solitaire
//scroll down for statistical analysis
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
public class BulgarianSolitairePlayer{
static List<Integer> moves = new ArrayList<Integer>();