Skip to content

Instantly share code, notes, and snippets.

Kotet kotet

Block or report user

Report or block kotet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kotet
kotet / app.d
Created Nov 1, 2019
線形符号
View app.d
import std.stdio : writefln, writef;
import std.format : format;
import std.conv : to;
void main(string[] args)
{
long L = args[1].to!long();
auto fmt = format!"%%0%db"(L);
outer: foreach (c_bitmask; 1 .. (1 << (1 << L)))
@kotet
kotet / merge.c
Created Jul 19, 2019
非再帰マージソート
View merge.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdint.h>
typedef struct stack_element
{
int64_t *ptr;
size_t length;
int8_t state;
@kotet
kotet / tree.d
Last active May 30, 2019
半永続(partially persistent)2分探索木 https://www.youtube.com/watch?v=T0yzrZL1py0
View tree.d
/*
$ rdmd tree.d
insert/print [i,p]: i
value: 2
2 inserted. current version: 1
insert/print [i,p]: i
value: 6
6 inserted. current version: 2
insert/print [i,p]: i
value: 3
@kotet
kotet / test.bf
Created Jan 5, 2019
Stack and Heap in Brainfuck
View test.bf
stack and heap in brainfuck
result: 7 5 0 3 1 7
b1 == 5
b2 == 7
stack == [3 7]
>> allocate 2
>+++ push 3
push 5
>+
@kotet
kotet / skskprime1.d
Created Dec 9, 2018
シクシク素数列 Advent Calendar 2018
View skskprime1.d
#!/usr/bin/rdmd
// 自然数を返す無限レンジ。
// map等の関数を使うためにはinputrangeである必要があり、
// inputrangeの条件を満たすためには
// front,popFront,emptyという3つの関数を実装する必要がある
struct NaturalNumber
{
long n = 1;
@kotet
kotet / main.js
Created Nov 20, 2018
論理式を変形するやつ
View main.js
"use strict";
let variable_names = [];
function tokenize(s) {
function isNextToken(s, i, t) {
for (let j = 0; j < t.length; j++) {
if (s.substr(i, t[j].length) == t[j]) {
return j;
@kotet
kotet / javarun.sh
Created Oct 11, 2018
javacを省略するやつ
View javarun.sh
javarun() {
if [ -z "$1" ]; then
echo "usage: javarun Triangle"
return
fi
local bar="\n------------------------------------\n"
echo -e $bar
mkdir -p output
local c="javac -d output $1.java $HOME/Turtle.java"
echo -e "$c:\n"
@kotet
kotet / mkws.sh
Last active Oct 5, 2018
ディレクトリ整理
View mkws.sh
mkws() {
local dhome="$HOME"
local droot="workspace"
local ddate="$(date '+%Y/%m-%d')"
local dname="${1:-space}"
local dseparator="."
local dsalt="$(cat /dev/urandom | tr -dc 'a-z' | head -c 4)"
local d="$dhome/$droot/$ddate/$dname$dseparator$dsalt"
mkdir -p -v "$d"
View kotet.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kotet
kotet / cramer.hs
Last active Jul 5, 2018
クラーメルの公式 in Haskell
View cramer.hs
import Data.List
-- 行列式
det :: [[Rational]] -> Rational
det [[a]] = a
det (a:b) | sum (map abs a) == 0 = 0
| head a == 0 = negate $ det (map (\ (a:b) -> b ++ [a]) (a:b))
| otherwise = (head a) * (det $ sub a b)
where sub a bs = map (\b -> tail(zipWith (\x y -> y - x * ((head b) / (head a))) a b)) bs
You can’t perform that action at this time.