This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List, Callable, Union, Dict | |
from copy import deepcopy | |
def make_logical_op(n: int, f) \ | |
-> Callable[[List[bool]], bool]: | |
def __retfunc(stack: List[bool]): | |
if len(stack) < n: | |
raise RuntimeError("Lack of arguments") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
# 0 <= h <= 179 (色相) OpenCVではmax=179なのでR:0(180),G:60,B:120となる | |
# 0 <= s <= 255 (彩度) 黒や白の値が抽出されるときはこの閾値を大きくする | |
# 0 <= v <= 255 (明度) これが大きいと明るく,小さいと暗い | |
# ここでは青色を抽出するので120±20を閾値とした | |
LOW_COLOR = np.array([100, 75, 75]) | |
HIGH_COLOR = np.array([140, 255, 255]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// アルゴリズムパズル 7. 真夜中の橋渡り | |
use std::io; | |
use std::cmp::{max,min}; | |
use std::collections::BinaryHeap; | |
fn read_line() -> String{ | |
let mut s = String::new(); | |
io::stdin().read_line(&mut s).unwrap(); | |
s.trim().to_string() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 6. 指数え | |
(defparameter *fingers* | |
(list | |
"index finger" "thumb" "index finger" "middle finger" | |
"ring finger" "little finger" "ring finger" "middle finger")) | |
(defun solve-6 (n) | |
(nth (mod n 8) *fingers*)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// アルゴリズムパズル 5. 行と列の入れ替え | |
use std::io; | |
use std::process; | |
fn read_line() -> String{ | |
let mut s = String::new(); | |
io::stdin().read_line(&mut s).unwrap(); | |
s.trim().to_string() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun solve-4 (n-soldier n) | |
(if (= n-soldier 0) | |
(print (format nil "~{~A~}" (list "it takes " (write-to-string n) " steps."))) | |
(progn | |
(print "2 young man go to left.") | |
(print "1 young man go to right") | |
(print "1 soldier go to left.") | |
(print "1 young man go to right.") | |
(solve-4 (1- n-soldier) (+ 4 n))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
size(640, 480); | |
} | |
void draw() { | |
background(0); | |
make_triangle(millis()/100); | |
} | |
void make_triangle(int n) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; アルゴリズムパズル 2 | |
(defun solve-2-a (xs) | |
(1+ (apply #'+ xs))) | |
(defun solve-2-b (xs) | |
(let*( | |
(ys (sort xs #'<)) | |
(min-val (first ys)) | |
(rest-ys (rest ys))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::collections::HashSet; | |
#[derive(Hash, Eq, PartialEq, Debug, Clone)] | |
enum Kind{ | |
None, | |
Cabbage, | |
Wolf, | |
Goat, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import math | |
from inspect import signature | |
import sys | |
import traceback | |
LEFT = True | |
RIGHT = False | |
# トークンに分割する際に使う正規表現関係 |
NewerOlder