Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Yuto MIZUSHIRI mizukmb

🏠
Working from home
  • Yayoi Co., Ltd.
  • Japan
  • 18:56 (UTC +09:00)
  • Twitter @mizukmb
View GitHub Profile
View cpu.rs
// 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
バブルソート、選択ソート、挿入ソート、マージソート
View sort.rs
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;
}
View lifegame.rs
// 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;
View ackermann-calc-bench.rs
// $ 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
View ejoneco
#!/bin/sh
word=''
if [ -p /dev/stdin ]; then
word=$(cat -)
else
word=$1
fi
echo :ejoneco: \< $word
@mizukmb
mizukmb / settings.yml
Last active Jun 4, 2018
github-nippou settings
View settings.yml
format:
subject: '### %{subject}'
line: '- [%{title}](%{url}) by [:@%{user}: @%{user}](https://github.com/%{user}) %{status}'
dictionary:
status:
merged: '**merged!**'
closed: '**closed!**'
View todo.hs
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
View deletetodo.hs
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
View appendtodo.hs
import System.IO
main = do
todoItem <- getLine
appendFile "todo.txt" (todoItem ++ "\n")
View helloworld.hs
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?"