Skip to content

Instantly share code, notes, and snippets.

@k2works
k2works / chap05.py
Last active June 16, 2020 01:33
新・明快Pythonで学ぶアルゴリズムとデータ構造-再帰
# Doctest
from collections import deque
from typing import Any
import unittest
import doctest
class Stack:
def __init__(self, maxlen: int = 256) -> None:
self.capacity = maxlen
@k2works
k2works / README.md
Last active November 23, 2021 02:28
READMEテンプレート

テンプレート

概要

目的

前提

ソフトウェア バージョン 備考
@k2works
k2works / Chap03.Tests.ps1
Last active June 8, 2020 01:43
PowerShellで学ぶアルゴリズムとデータ構造-探索
# 探索アルゴリズム
Describe "線形探索" {
It "シーケンスaからkeyと等価な要素を線形探索(while文)" {
SearchWhile @(6, 4, 3, 2, 1, 2, 8) 2 | Should Be 3
SearchWhile @(12.7, 3.14, 6.4, 7.2, 7.2, 'End') 6.4 | Should Be 2
SearchWhile @(4, 7, 5.6, 2, 3.14, 1) 5.6 | Should Be 2
SearchWhile @('DTS', 'AAC', 'FLAC') 'DTS' | Should Be 0
}
@k2works
k2works / Chap02.Tests.ps1
Created May 9, 2020 01:17
PowerShellで学ぶアルゴリズムとデータ構造-データ構造と配列
# https://qiita.com/opengl-8080/items/bb0f5e4f1c7ce045cc57
# データ構造と配列
Describe "TestTotal" {
It "5人の点数を読み込んで合計点・平均点を返す" {
Total 32 68 72 54 92 | Should Be '318,63.6'
}
}
function Total {
@k2works
k2works / Chap01.Tests.ps1
Last active May 9, 2020 01:14
PowerShellで学ぶアルゴリズムとデータ構造-基本的なアルゴリズム
# アルゴリズムとは
## 3値の最大値
Describe "Max3" {
Context "3つの整数値を読み込んで最大値を求めて表示" {
$testCase = @(
@{ a = 3; b = 2; c = 1; expectedResult = 3 }
@{ a = 3; b = 2; c = 2; expectedResult = 3 }
@{ a = 3; b = 1; c = 2; expectedResult = 3 }
@{ a = 3; b = 2; c = 3; expectedResult = 3 }
@k2works
k2works / chap04.py
Last active May 2, 2020 02:21
新・明解Pythonで学ぶアルゴリズムとデータ構造-スタック
from collections import deque
from typing import Any
import unittest
import doctest
# 固定長スタッククラス
class TestFixedStack(unittest.TestCase):
def test_push(self):
@k2works
k2works / pl.py
Last active February 24, 2021 12:41
Pythonで財務分析
# Doctest
import unittest
import doctest
class TestPl(unittest.TestCase):
def test_売上総利益(self):
f = PL(FY27)
self.assertEqual(f['売上総利益'](), 75)
@k2works
k2works / pl.js
Last active April 12, 2020 09:09
JavaScriptで損益計算書
const assert = require("assert");
const PL = (PL) => {
const 売上総利益 = (() => {
const 売上総利益 = PL.filter(o => Object.keys(o).some(v => ['売上高', '売上原価'].includes(v)))
return 売上総利益.reduce((a,v) => parseInt(Object.values(a)) + parseInt(Object.values(v)))
})()
const 営業利益 = (() => {
const 販管費 =(() => {
@k2works
k2works / tdd.php
Created April 7, 2020 02:15
PHP TDD Startter
<?php
assert(add(2, 2) == 5);
function add($a, $b) {
$sum = $a + $b;
return $sum;
}
@k2works
k2works / chap03.py
Last active April 5, 2020 06:14
新・明解Pythonで学ぶアルゴリズムとデータ構造-探索
# 探索アルゴリズム
from __future__ import annotations
from enum import Enum
import hashlib
import copy
from typing import Any, Sequence
import unittest
import doctest