Skip to content

Instantly share code, notes, and snippets.

def _to_snake_case(word):
final = ''
for item in word:
if item.isupper():
final += "_" + item.lower()
else:
final += item
if final[0] == "_":
final = final[1:]
return final
@tera3939
tera3939 / main.rs
Created June 19, 2017 13:56
ぴゅあぴゅあList
#![feature(box_syntax)]
use std::rc::Rc;
#[derive(Debug)]
enum List<T: Clone> {
Empty,
Exist(Rc<Box<Node<T>>>),
}
@tera3939
tera3939 / main.py
Last active August 3, 2017 13:36
分割統治法で階乗計算
# -*- encoding: utf-8 -*-
def each_slice_2(f, iterator):
a = iterator.__iter__()
for i in a:
try:
j = a.__next__()
except:
j = 0
yield f(i, j)
@tera3939
tera3939 / word_count.py
Created December 8, 2017 03:31
https://paiza.jp/learning/word-count を一行でウェイってする奴
[print(*t) for terms, used in zip([input().split()], [set()]) for t in map(lambda x: (x, terms.count(x)), terms) if t not in used and (used.add(t) or True)]
@tera3939
tera3939 / setting.json
Created December 11, 2017 03:33
Visual Studio Codeの設定っぽい
//-------- Rust extension configuration --------
// The mode in which the extension will function
"rust.mode": "rls",
// Specifies path to Racer binary if it's not in PATH
"rust.racerPath": "C:\\Users\\tera\\.cargo\\bin\\racer.exe",
// Specifies path to Rustfmt binary if it's not in PATH
"rust.rustfmtPath": "C:\\Users\\tera\\.cargo\\bin\\rustfmt.exe",