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
import Data.List as List | |
import Data.Map as Map | |
import Data.Maybe as Maybe | |
import Data.Sequence as Seq | |
import Data.Set as Set | |
maze = "#S######.#" ++ | |
"......#..#" ++ | |
".#.##.##.#" ++ | |
".#........" ++ |
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
import Data.List | |
main :: IO () | |
main = print $ solve [ "def", "fdc", "abcd", "char", "hoge"] | |
solve :: [String] -> [String] | |
solve wrds = snd $ last $ sortOn fst $ map (\ws -> (calc ws, ws)) $ permutations wrds | |
calc :: [String] -> Int | |
calc [] = 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
-- http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1129 | |
-- http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2162974#1 | |
main :: IO () | |
main = do | |
s <- getContents | |
mapM_ print $ solve (strings2ds s) [] | |
solve :: [[Int]] -> [[Int]] -> [Int] | |
solve ([0, 0]:_) acc = map head $ reverse acc | |
solve datasets acc = solve rest (result : acc) where |
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
const delayed_yeah = () => { | |
console.log('delayed_yeah!') | |
return new Promise((resolve, reject) => { | |
setTimeout(() => resolve('yeah!'), 2000) | |
}) | |
} | |
const delayed_hi = () => { | |
console.log('delayed_hi!') | |
return new Promise((resolve, reject) => { |
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
require 'set' | |
COL_NUM = 8 | |
def queen() | |
place([], 1, COL_NUM).select{ |l| l.length == 8 } | |
end | |
def place(accum, col, col_num) | |
available_squares = find_available_squares(accum, col_num) |
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
import IM from 'immutable' | |
import _ from 'lodash' | |
export const DISC = { | |
WHITE_SIDE : Symbol('WHITE_SIDE'), | |
BLACK_SIDE : Symbol('BLACK_SIDE') | |
} | |
export const SQUARE_STATUSES = { | |
WHITE: Symbol('WHITE'), |
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
root = true | |
[*] | |
end_of_line = lf | |
insert_final_newline = true | |
charset = utf-8 | |
indent_style = space | |
indent_size = 2 |
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
function seq2candlestick(range, nDiv, noHeader) { | |
const vals = range.filter(function(val) { return val != "" }).map(function(val) { return Number(val) }) | |
const res = _splitseq(vals, Number(nDiv)).map(function(ns) { | |
const min = Math.min.apply(null, ns) | |
const q1 = _q1(ns) | |
const q3 = _q3(ns) | |
const max = Math.max.apply(null, ns) | |
return [min, q1, q3, max] | |
}) | |
if (noHeader) { |
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
import MeCab | |
t = MeCab.Tagger('-Ochasen') | |
n = t.parseToNode('MeCabを使って何かやってみる。') | |
while n: | |
print("surface:\t{0}".format(n.surface)) | |
print("feature:\t{0}".format(n.feature)) | |
print("cost:\t{0}".format(n.feature)) | |
n = n.next |