Skip to content

Instantly share code, notes, and snippets.

View tnoda's full-sized avatar

Takahiro Noda tnoda

View GitHub Profile
@tanakh
tanakh / gist:8750952
Created February 1, 2014 11:20
なぜ我々はHaskellを使うのか

スタートアップ企業 Silk が、Haskellを採用した理由。

http://engineering.silk.co/post/31920990633/why-we-use-haskell

As a newly started company, we have a lot of technical decisions to make. One of the important ones is the choice of a programming language. Since we’re building a web application, this goes for both the client (i.e. the web browser) and the server.

新しく始めた会社として、我々はたくさんの技術的決定を行わなければなりません。中でも重要なのは、プログラミング言語の選択です。我々はウェブアプリケーションを作っていたので、この選択がクライアント(Webブラウザなど)とサーバの両方で必要になります。

On the client, there wasn’t much discussion. Javascript is the only viable choice, unless you want to use Flash or similar plugin-based models. But on the server, we had more freedom. Popular choices for web applications are dynamically typed languages like Ruby, Python and PHP, and statically typed languages like Java and C#.

@ponkore
ponkore / problem_25.clj
Created January 9, 2013 14:18
Project Euler Problem 25
(ns projecteuler.problem-25
(:require [clojure.string :as str]
[clojure.math.numeric-tower :as math])
(:use clojure.test))
(defn fib-gen
"フィボナッチ数を generate する関数。初期値[1 1]から iterate する前提。"
[[a b]] [b (+' a b)])
(def fib-seq
@kohyama
kohyama / pep019.clj
Last active December 10, 2015 18:08
Project Euler Problem 19
;; 閏年かどうか
(defn leap? [year]
(and (zero? (mod year 4))
(or (pos? (mod year 100))
(zero? (mod year 400)))))
;; 西暦で与えられた年の各月の日数のリスト
(defn numbers-of-days [year]
(if (leap? year)
;;Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
@emanon001
emanon001 / problem_20.clj
Created January 6, 2013 08:56
Project Euler Problem 20 #mitori_clj
;;; Project Euler Problem 20
;;; 「100! の各桁の数字の和を求めよ」
;;; http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2020
(ns emanon001.projecteuler-answers.problem-020
(:require [clojure.test :refer [are]]))
(defn factorial
"n の階乗を返します"
[n]
@tnoda
tnoda / problem_19.clj
Created January 5, 2013 04:50
#mitori_clj Project Euler Problem 19
(ns tnoda.projecteuler.problem-19
(:import (org.joda.time DateTime) ; [joda-time/joda-time "2.1"]
(org.joda.time.chrono GregorianChronology)))
(defn- a-month-later
[^DateTime dt]
(.plusMonths dt 1))
(defn- sunday?
[^DateTime dt]
;;; Project Euler #22
;;; http://projecteuler.net/problem=22
;;; http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2022
; [org.clojure/data.csv "0.1.2"]
(require '[clojure.test :refer [deftest is]]
'[clojure.data.csv :as csv])
(defn char-score
[c]
;;; Project Euler Problem 23 solution
;;; http://projecteuler.net/problem=23
(use 'clojure.test)
(def limit 28123)
(defn gen-sigma1-list
"original implementation by @ypsilon-takai: https://gist.github.com/4284814"
[^long size]
@tnoda
tnoda / problem_11.clj
Created December 28, 2012 03:56
#mitori_clj Project Euler Problem 11
(ns tnoda.projecteuler.problem-11
[:require [clojure.string :as str]])
(def ^:private input "08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
@mnzk
mnzk / euler011.clj
Last active December 10, 2015 05:38
Project Euler 11番
(ns euler.problem011
(:require [clojure.string :as string]))
(defn parse-numbers
[input]
(for [line (->> (string/split-lines input)
(map #(re-seq #"\d+" %)))
:when (not-empty line)]
(map #(Long/parseLong %) line)))
@ypsilon-takai
ypsilon-takai / description.md
Last active December 10, 2015 05:18
Euler: Problem 24

解説

実際に数列を作るときに、樹形図を描いたのですが、それを見ていて思いつい た方法です。

図を作りました。

樹形図を描いてX番目の数を求めるときには、全部描いて、端から数えればい いわけですが、図のようにあるノードの下にある葉の数は計算で求めることが