(map #(.getName %) (.getMethods java.io.File))
; -> ("equals" "toString" "hashCode" "compareTo" "compareTo" "getName" "length" "getParent" "isAbsolute" "getCanonicalPath" "setReadOnly" "list" "list" "delete" "getParentFile" "getPath" "getAbsolutePath" "getAbsoluteFile" "getCanonicalFile" "toURL" "toURI" "canRead" "canWrite" "exists" "isDirectory" "isFile" "isHidden" "lastModified" "createNewFile" "deleteOnExit" "listFiles" "listFiles" "listFiles" "mkdir" "mkdirs" "renameTo" "setLastModified" "setWritable" "setWritable" "setReadable" "setReadable" "setExecutable" "setExecutable" "canExecute" "listRoots" "getTotalSpace" "getFreeSpace" "getUsableSpace" "createTempFile" "createTempFile" "wait" "wait" "wait" "getClass" "notify" "notifyAll")
This file contains hidden or 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
| (require '[clojure.test :refer (is)]) | |
| (defn in-words | |
| "Represents the given number in English words without spaces nor hyphens. | |
| This works with a number in the range from 1 to 1000" | |
| [n] | |
| (cond | |
| (< n 20) | |
| (["" "one" "two" "three" "four" "five" "six" "seven" "eight" | |
| "nine" "ten" "eleven" "twelve" "thirteen" "fourteen" |
This file contains hidden or 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
| (require '[clojure.test :refer (is)]) | |
| (defn pms | |
| "Permutations lexicographic by index." | |
| [[a & [b & [c & _]] :as ls]] | |
| (cond | |
| (nil? a) '() | |
| (nil? b) `(~a) | |
| (nil? c) `((~a ~b) (~b ~a)) | |
| :else (mapcat (fn [h] (map (fn [r] (cons h r)) |
This file contains hidden or 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
| (require '[clojure.string :as s]) | |
| (require '[clojure.test :refer (deftest run-tests is)]) | |
| (defn trans [[& rows]] (apply (partial map list) rows)) | |
| (defn flip [mat] (map reverse mat)) | |
| (defn rot45 [mat] | |
| (let [w (count (first mat)) | |
| h (count mat) |
This file contains hidden or 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 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 |
This file contains hidden or 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
| (require '[clojure.test :refer (is)]) | |
| (require '[clojure.string :as s]) | |
| (def input " | |
| 75 | |
| 95 64 | |
| 17 47 82 | |
| 18 35 87 10 | |
| 20 04 82 47 65 | |
| 19 01 23 75 03 34 |
This file contains hidden or 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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #define u16 unsigned short | |
| #define u8 unsigned char | |
| static u16 | |
| crc16(u8 *p, int n) | |
| { | |
| static const u16 wCRCTable[] = { |
This file contains hidden or 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
| ;;; Copyright (c) 2013 Yoshinori Kohyama. Distributed under the BSD 3-Clause License. | |
| (ns puyo | |
| (:require [clojure.test :refer (with-test run-tests are)] | |
| [clojure.set :refer (union)] | |
| [clojure.string :as string])) | |
| (with-test | |
| (defn- fall-one [b s] | |
| (->> (reverse b) | |
| (apply map vector) |
This file contains hidden or 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
| (require '[clojure.test :refer (with-test are run-tests)]) | |
| (with-test | |
| (defn str-drop-while-same [& args] | |
| (if (some nil? args) args | |
| (->> (map #(concat % (repeat nil)) args) | |
| (apply map vector) | |
| (drop-while #(apply = %)) | |
| (take-while #(some identity %)) | |
| (apply map str)))) |