This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; sense-region.el --- minor mode to toggle region and rectangle. | |
;;; $Id: sense-region.el,v 1.9 2002/10/16 13:47:14 komatsu Exp $ | |
;;; | |
;;; AUTHOR: Hiroyuki KOMATSU <komatsu@taiyaki.org> | |
;;; LICENSE: GPL2 | |
;;; ORIGINAL-SOURCE: http://www.taiyaki.org/elisp/sense-region/ (in Japanese) | |
;;; Version: 1.9.0 | |
;;; | |
;;; ------------------------------------------------------------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UnionFind: | |
"""Weighted quick-union with path compression. | |
The original Java implementation is introduced at | |
https://www.cs.princeton.edu/~rs/AlgsDS07/01UnionFind.pdf | |
>>> uf = UnionFind(10) | |
>>> for (p, q) in [(3, 4), (4, 9), (8, 0), (2, 3), (5, 6), (5, 9), | |
... (7, 3), (4, 8), (6, 1)]: | |
... uf.union(p, q) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
city_code | prefecture | city | pop | age | working_age_pop | daytime_pop | |
---|---|---|---|---|---|---|---|
1100 | 北海道 | 札幌市 | 1952356 | 46.4 | 1235516 | 1959740 | |
1202 | 北海道 | 函館市 | 265979 | 52.7 | 152154 | 273408 | |
1203 | 北海道 | 小樽市 | 121924 | 56.5 | 65317 | 124293 | |
1204 | 北海道 | 旭川市 | 339605 | 51.9 | 191423 | 341732 | |
1205 | 北海道 | 室蘭市 | 88564 | 52.5 | 49005 | 96865 | |
1206 | 北海道 | 釧路市 | 174742 | 51.4 | 101909 | 175733 | |
1207 | 北海道 | 帯広市 | 169327 | 47.6 | 103890 | 175954 | |
1208 | 北海道 | 北見市 | 121226 | 50.9 | 70781 | 121080 | |
1209 | 北海道 | 夕張市 | 8843 | 64.4 | 4045 | 9104 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
city_code | prefecture | city | |
---|---|---|---|
1000 | 北海道 | 北海道 | |
1100 | 北海道 | 札幌市 | |
1101 | 北海道 | 中央区 | |
1102 | 北海道 | 北区 | |
1103 | 北海道 | 東区 | |
1104 | 北海道 | 白石区 | |
1105 | 北海道 | 豊平区 | |
1106 | 北海道 | 南区 | |
1107 | 北海道 | 西区 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Coursera | |
coursera.com * | |
_ 1st-party script | |
_ cloudfront.net * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn prime? [n] | |
(every? #(pos? (rem n %)) (range 2 (Math/sqrt (inc n))))) | |
(defn naive-primes [n] | |
(filter prime? (range 2 (inc n)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns tnoda.projecteuler.problem-5 | |
(:import org.apache.commons.math.util.MathUtils) ; [org.apache.commons/commons-math "2.2"] | |
(:use clojure.test)) | |
(defn- solver* | |
[n] | |
(reduce (fn [^long x ^long y] (MathUtils/lcm x y)) (range 1 (inc n)))) | |
(def solver (partial solver* 20)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(let [m (BattleMap. "Ironbottom Sound") | |
f (Fleet. "Center Fleet")] | |
(loop [] | |
(doto f .repair .supply) | |
(when (and (.isFullyRepaired f) | |
(.isFullySupplied f) | |
(>= (.morale f) 40)) | |
(.attack f m) | |
(if (-> m .gauges pos?) | |
(recur)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun shibayu36/chomp (str) | |
(replace-regexp-in-string "[\n\r]+$" "" str)) | |
(defun anything-git-project-project-dir () | |
(shibayu36/chomp | |
(shell-command-to-string "git rev-parse --show-toplevel"))) | |
(defun anything-c-sources-git-project-for () | |
(loop for elt in | |
'(("Modified files (%s)" . "--modified") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package recfun | |
object DrillOne { | |
// sum of arithmetic progression | |
def soap(x: Int): Int = | |
if (x == 0) 0 | |
else soap(x - 1) + x | |
// factorial | |
def fact(x: Int): Int = |
NewerOlder