Skip to content

Instantly share code, notes, and snippets.

View mizukmb's full-sized avatar
🏠
Working from home

Yuto MIZUSHIRI mizukmb

🏠
Working from home
View GitHub Profile
// CPU EMULATOR
// CPUの作り方10講3章
#![allow(unused)]
use std::num::Wrapping;
// 命令コードのインデックス
const MOV: u16 = 0;
const ADD: u16 = 1;
const SUB: u16 = 2;
@mizukmb
mizukmb / sort.rs
Created May 11, 2020 15:07
バブルソート、選択ソート、挿入ソート、マージソート
fn bubble_sort(values: &Vec<i32>) -> Vec<i32> {
let mut result = values.clone();
for i in 0..(values.len() - 2) {
for base in 0..(values.len() - i) {
let target_index = base + 1;
if target_index >= values.len() {
break;
}
// lifegame
// 生→1
// 死→0
fn is_birth(target_row: i32, target_col: i32, field: &Field) -> bool {
if field[target_row as usize][target_col as usize] == 1 {
return false;
}
let mut count = 0;
// $ cargo +nightly --version # you need to use rustc nightly version
// cargo 1.39.0-nightly (3596cb86b 2019-09-19)
// $ cargo +nightly bench --features unstable
// Compiling ackermann-calc v0.1.0 (/home/mizukmb/src/ackermann-calc)
// Finished release [optimized] target(s) in 1.12s
// Running target/release/deps/ackermann_calc-83e1a1843dd244b1
//
// running 9 tests
// test tests::a0 ... ignored
// test tests::a1 ... ignored
#!/bin/sh
word=''
if [ -p /dev/stdin ]; then
word=$(cat -)
else
word=$1
fi
echo :ejoneco: \< $word
@mizukmb
mizukmb / settings.yml
Last active June 4, 2018 08:29
github-nippou settings
format:
subject: '### %{subject}'
line: '- [%{title}](%{url}) by [:@%{user}: @%{user}](https://github.com/%{user}) %{status}'
dictionary:
status:
merged: '**merged!**'
closed: '**closed!**'
import Control.Exception
import Data.List
import System.Directory
import System.Environment
import System.IO
dispatch :: String -> [String] -> IO ()
dispatch "add" = add
dispatch "view" = view
dispatch "remove" = remove
import System.IO
import System.Directory
import Data.List
import Control.Exception
main = do
contents <- readFile "todo.txt"
let todoTasks = lines contents
numberedTasks = zipWith (\n line -> show n ++ " - " ++ line) [0..] todoTasks
import System.IO
main = do
todoItem <- getLine
appendFile "todo.txt" (todoItem ++ "\n")
import Data.Char
-- main = putStrLn "Hello, World"
-- main = do
-- putStrLn "Hello, what's your name?"
-- name <- getLine
-- putStrLn ("Hey " ++ name ++ ", you rock!")
main = do
putStrLn "What's your first name?"