Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ochaochaocha3's full-sized avatar

Kosuke Yamashita ochaochaocha3

View GitHub Profile
@ochaochaocha3
ochaochaocha3 / a.md
Last active July 3, 2022 04:13
Twitterの2次関数の問題
@ochaochaocha3
ochaochaocha3 / Makefile
Last active June 23, 2022 17:47
Vi村さんの重複キー検索の問題(C++17)
map_key: map_key.cpp
$(CXX) -o $@ -std=gnu++17 -Wall -Wpedantic -g $^
@ochaochaocha3
ochaochaocha3 / Makefile
Last active September 6, 2021 14:54
オークの問題C言語版
orcs: orcs.c
$(CC) -std=gnu11 -o $@ $^
@ochaochaocha3
ochaochaocha3 / orcs.rb
Last active September 6, 2021 12:54
オークの問題
# frozen_string_literal: true
# https://twitter.com/MomiRaccoon/status/1434402973627531267
#
# 女騎士「わ、私に性感度3000倍もさせて一体何をさせるんだ…」
# オーク「ククク…」
#
# オークA「感度を半分にするクスリだ」
# オークB「感度を900マイナスにするクスリだ」
# オークC「感度を2000プラスにするクスリだ」
@ochaochaocha3
ochaochaocha3 / bcdice-translation-guide-en.md
Last active May 28, 2021 04:55
BCDice翻訳ガイドの英語版の案

BCDice development team accepts translations from Japanese into other languages. This document explains how to submit a translation.

Preliminary Confirmation

Please contact us on the Discord server "bcdice-help" if the directory for the game system that you are going to translate does not exist in i18n/. There is some work to be done before we accept your translation.

Things to submit

@ochaochaocha3
ochaochaocha3 / drop_innodb-result.txt
Created February 14, 2021 13:56
外部キー制約によってMroongaでDROP DATABASEが失敗する例
Table Create Table
contents CREATE TABLE `contents` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `text` text,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC
Table Create Table
c_refs CREATE TABLE `c_refs` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `content_id` int(11) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `index_c_refs_on_content_id` (`content_id`),\n CONSTRAINT `content_id` FOREIGN KEY (`content_id`) REFERENCES `contents` (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC
@ochaochaocha3
ochaochaocha3 / parser.y
Created December 3, 2020 14:57
BCDiceのLALR(1)構文解析器をまとめようとした跡(reduce/reduce conflict多発のため却下)
class BCDice::CommonCommand::Parser
token
ASTERISK
AT
BRACKETL
BRACKETR
C
CMP_OP
D
@ochaochaocha3
ochaochaocha3 / 00_README.md
Last active April 19, 2020 12:43
式の簡単化

Joel S. Cohen: "Computer Algebra and Symbolic Computation: Mathematical Methods", A K Peters (2003)を参考にして、抽象構文木の変形による数式の代数的簡約化(algebraic simplification)を実装した。現在は、加算、減算、乗算、および符号反転(単項マイナス)のみに対応している。また、BCDiceでの需要に合わせて、加算部分は間の項をまたいで簡約化されないように文献からアルゴリズムを変えている。

実行にはparslet gemが必要。

実行例

require_relative 'parser'
require_relative 'simplification'
@ochaochaocha3
ochaochaocha3 / .gitignore
Last active February 14, 2020 16:53
2点を通る対称な形の放物線の求め方
.ipynb_checkpoints
@ochaochaocha3
ochaochaocha3 / txt_to_yaml.rb
Created October 19, 2019 07:22
どどんとふのチャットログからダイスロール部分を抽出するスクリプト
require 'yaml'
require 'json'
lines = ARGF.readlines(chomp: true)
json_lines = lines.map { |line|
left_bracket_index = line.index('[')
line[left_bracket_index..-1]
}
hashes = json_lines.map { |line|
JSON.parse(line)