Skip to content

Instantly share code, notes, and snippets.

N = 1000
# s = N.times.each_with_object([1, 1]) { |_, a| a << 2*a[-2] + a[-1] }
# p [s, s.size]
# # https://www.crondose.com/2017/02/fibonacci-sequence-generator-ruby/
# s = N.times.reduce([1, 1]) { |a| a << 2*a[-2] + a[-1] }
# # https://docs.ruby-lang.org/ja/master/class/Enumerator.html#S_NEW
# enum = Enumerator.new { |y|
@autf
autf / impl.kt
Last active November 1, 2021 06:24
cs61b sp21 lec14 Disjoint Sets
interface DisjointSets {
fun connect(p: Int, q: Int)
fun isConnected(p: Int, q: Int): Boolean
}
class DisjointSetsByArray(val elements: Int) : DisjointSets {
private val map = IntArray(elements) { -1 }
private fun top(id: Int): Int {
if (id !in map.indices) return -1
package main
import (
"io/fs"
"log"
"net/http"
"strings"
)
func isVideoFile(name string) bool {
require 'nokogiri'
require 'open-uri'
base = 'https://ncode.syosetu.com'
ncode = 'x0000xx'
seen = i = 777
# start from #(seen + 1) chapter
p out = `date -Im`.strip
`mkdir #{out}`
@autf
autf / 3triangles.js
Last active September 16, 2021 11:38
Exercise 6.1 < 6.3 Translation < edX NYUx DMEDX6063 Creative Coding
function setup() {
createCanvas(500, 500)
background('lightgray')
}
function draw() {
let side = 300
let third = side / 3
noStroke()
translate(100, 100)