Skip to content

Instantly share code, notes, and snippets.

View kana's full-sized avatar

Kana Natsuno kana

View GitHub Profile
:function! F()
let xs = [2]
let i = 3
while len(xs) < 100
if empty(filter(copy(xs), 'i % v:val == 0'))
call add(xs, i)
endif
let i += 1
endwhile
put =xs
(a)
.---------. .--..--..--. .---------.
| ラ | ラ | |カ||カ||カ| | サ |姫ト|
|----+----| `--'`--'`--' |----+----|
| ラ | ラ | .------. | 呪 | 侍 |
|----+----| | 国外 | |----+----|
| ラ | ラ | `------' | 都 | 議 |
|----+----| .--..--..--. |----+----|
| ラ | ラ | |カ||カ||カ| | 大 | 爵 |
`---------' `--'`--'`--' `---------'
yl 現在のマスの状態を調べる
@=
@0=="G" ゴールに着いた?
? "maGD\"=@-+1\rP`a" 見つかった解の数を+1する。
: @0==" " 通路に居る?
? "r.l@1hj@1kh@1lk@1jr " 今のマスを訪問済みにマーク(r.)して、十字隣接するマスを調べて(l@1h...)、今のマスを未訪問に戻す(r )。
: "" 冒険は終わった。
@kana
kana / yubi.py
Created September 14, 2012 09:46
[Yubi]
from itertools import chain
RULES = {
1: {2: 3, 4: 7, 5: 9},
2: {5: 8},
3: {2: 1, 5: 7, 6: 9},
4: {5: 6},
5: {},
6: {5: 4},
7: {4: 1, 5: 3, 8: 9},
@kana
kana / Hatokura.hs
Created July 26, 2012 09:53
Haskellリハビリ中
import Data.List
data Card =
Nouson
| Toshi
| Daitoshi
| MinaraiJijo
| YakihataNougyo
deriving (Eq, Show)
@kana
kana / bookmarklet.txt
Created June 14, 2012 09:18
A bookmarklet to investigate an XPath expression of a clicked element.
javascript:(function(){var dialog=document.createElement("div");var setUpDialog=function(){dialog.style.position="fixed";dialog.style.bottom="0";dialog.style.left="10%";dialog.style.width="80%";dialog.style.color="#333";dialog.style.background="#efe";dialog.style.border="thin solid #9a9";dialog.style.margin="0 0 0.5em";dialog.style.padding="0.5em 1em";dialog.style.fontFamily="monospace";document.getElementsByTagName("body")[0].appendChild(dialog)};var notify=function(message){dialog.textContent=message};var loadJavaScript=function(uri){var script=document.createElement("script");script.setAttribute("type","text/javascript");script.setAttribute("src",uri);document.getElementsByTagName("body")[0].appendChild(script)};var isJQueryLoaded=function(){return window.jQuery!==undefined};var waitLoadingJQuery=function(continuation){var tryCount=0;var step=function(){if(isJQueryLoaded())continuation();else{tryCount++;setTimeout(step,tryCount*100);notify("Loading"+(new Array(tryCount+1)).join("."))}};step()};var getXPath
@kana
kana / hatokura.rb
Created June 9, 2012 16:26
即席ハトクラ手札シミュレーター
# coding: utf-8
ALL_CARDS = [
{id: '1', short_name: '農', name: '農村'},
{id: '2', short_name: '都', name: '都市'},
{id: '3', short_name: '大', name: '大都市'},
{id: 'x', short_name: 'ダ', name: '見習い侍女'},
]
CARD_FROM_ID_TABLE = Hash[ALL_CARDS.map {|c| [c[:id], c]}]
@kana
kana / nethack.txt
Created June 1, 2012 17:47
NetHack current status
Amulets
R - an uncursed amulet of reflection named Sokoban (being worn)
----------- -------- ----------- Weapons
------- |.........| |.....%+# ##..........| w - the blessed rustproof +7 Excalibur (weapon in hand)
|...|.| |...).)...-# |......|# # |.....>...| x - the blessed rustproof +7 Mjollnir
|....^| |..*......|# #.......|# ####..........| V - a blessed +7 silver saber (wielded in other hand)
|.....| |.....).`.|# #--------# # --.-------- Armor
|.....| #......)...|# #### % # #### A - a blessed +4 gray dragon scale mail (being worn)
|.....| ### ###-----------* # % # # # #
@kana
kana / git-checkout-failed.txt
Created May 25, 2012 04:56
didn't know that recent versions of Git tell about more useful error messages
$ git checkout -b master topic
fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'topic' which can not be resolved as commit?
@kana
kana / hatokrua-market-placement.md
Created May 18, 2012 08:13
ハトクラのマーケット置場にどのカードを置くかで悩む図

ハトクラのマーケット置場にどのカードを置くかで悩む図

4×2が2個ある場合

-------------
|R1 R2 R3 R4|
|R5 R6 R7 R8|
-------------
 (具)   (外)