Skip to content

Instantly share code, notes, and snippets.

@kmikael
kmikael / subsequences.py
Last active April 21, 2017 17:31
Generate `count` weights from a range, `seq` that add up to a given `target`
def subsequences(count, seq = range(5, 40, 5), target = 100, partial = []):
if count == 0:
return
s = sum(partial)
if s >= target:
return
if s == target or (count == 1 and (target - s) in seq):
@kmikael
kmikael / HomeCollectionViewFlowLayout.swift
Last active March 10, 2021 09:31
Snapping, centering and automatically sizing flow layout
import UIKit
class HomeCollectionViewFlowLayout: UICollectionViewFlowLayout {
var isSetUp = false
override func prepare() {
super.prepare()
setUpIfNeeded()