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
module Base65536 | |
BLOCK_START = { | |
0 => 13312, | |
1 => 13568, 2 => 13824, 3 => 14080, 4 => 14336, 5 => 14592, 6 => 14848, 7 => 15104, 8 => 15360, 9 => 15616, 10 => 15872, 11 => 16128, 12 => 16384, 13 => 16640, 14 => 16896, 15 => 17152, 16 => 17408, 17 => 17664, 18 => 17920, 19 => 18176, 20 => 18432, 21 => 18688, 22 => 18944, 23 => 19200, 24 => 19456, 25 => 19968, 26 => 20224, 27 => 20480, 28 => 20736, 29 => 20992, 30 => 21248, 31 => 21504, 32 => 21760, 33 => 22016, 34 => 22272, 35 => 22528, 36 => 22784, 37 => 23040, 38 => 23296, 39 => 23552, 40 => 23808, 41 => 24064, 42 => 24320, 43 => 24576, 44 => 24832, 45 => 25088, 46 => 25344, 47 => 25600, 48 => 25856, 49 => 26112, 50 => 26368, 51 => 26624, 52 => 26880, 53 => 27136, 54 => 27392, 55 => 27648, 56 => 27904, 57 => 28160, 58 => 28416, 59 => 28672, 60 => 28928, 61 => 29184, 62 => 29440, 63 => 29696, 64 => 29952, 65 => 30208, 66 => 30464, 67 => 30720, 68 => 30976, 69 => 31232, 70 => 31488, 71 => 31744, 72 => 32000, 73 => 32256, 74 => 32512, 75 => 32768, 76 |
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 csv | |
import os | |
import plotly.express as px | |
import pandas as pd | |
diameters = [] | |
widths = [] | |
weights = [] | |
csv_filepath = os.path.join(os.environ['HOME'], 'Downloads/yoyos.csv') |
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 csv | |
import os | |
import matplotlib | |
import matplotlib.pyplot as plt | |
import matplotlib.ticker as ticker | |
import numpy as np | |
from scipy.stats import gaussian_kde | |
# Use Agg (Anti-Grain Geometry) to avoid the error “ModuleNotFoundError: No module named ‘_tkinter’”. | |
matplotlib.use('Agg') |
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
# Count the yo-yos I have by brand and get the top 5 brands. | |
# Use the CSV output from Notion's database to tally. | |
require 'csv' | |
rows = CSV.read(Pathname(Dir.home).join('Downloads/my_yoyos.csv')) | |
resutls = rows.slice(1..).map { _1[1].split(/,\s*/) }.flatten.tally | |
resutls.sort_by { -_2 }.first(5).to_h |
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
# 決定性有限オートマトン (DFA) | |
class DFA | |
class InvalidEvent < StandardError; end | |
attr_reader :current_state | |
def initialize(current_state:, accept_states:, rules:) | |
@current_state = current_state | |
@accept_states = accept_states | |
@rules = rules |
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
const convertTableToRows = (selector) => { | |
const table = document.querySelector(selector); | |
const rows = []; | |
const headers = Array.from(table.querySelectorAll('tr:first-child th')).map(th => th.innerText); | |
rows.push(headers); | |
table.querySelectorAll('tr').forEach(tr => { | |
const row = []; | |
tr.querySelectorAll('td').forEach(td => { | |
row.push(td.innerText); |
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 itertools | |
from collections.abc import Iterator | |
def fizzbuzz(n: int) -> Iterator[int | str]: | |
''' | |
Return the fizzbuzz of n, an exact integer >= 0. | |
>>> from fizzbuzz import fizzbuzz | |
>>> [i for i in fizzbuzz(15)] |
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
require 'terminal-table' # https://github.com/tj/terminal-table | |
| |
N = 30 # 合計人数 | |
| |
# table[n][0] は男子を選ぶ組み合わせの数。 | |
# table[n][1] は女子を選ぶ組み合わせの数。 | |
table = Array.new(N + 1) { Array.new(2, 0) } | |
| |
# n = 1 のときは男子も女子も 1 通りずつ。 | |
table[1][0] = 1 |
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
require 'delegate' | |
# https://github.com/tj/terminal-table | |
require 'terminal-table' | |
# ナップサック問題(Ruby) | |
# http://obelisk.hatenablog.com/entry/2017/05/26/162601 | |
# 典型的な DP (動的計画法) のパターンを整理 Part 1 ~ ナップサック DP 編 ~ | |
# https://qiita.com/drken/items/a5e6fe22863b7992efdb | |
class Item |
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
# | |
# Sets Prezto options. | |
# | |
# Authors: | |
# Sorin Ionescu <sorin.ionescu@gmail.com> | |
# | |
# | |
# General | |
# |
NewerOlder