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
""" | |
Turing machine implementation in Python | |
Example input: | |
(Machine to generate Collatz sequence) | |
0,I;1,I,R | |
1,I;2,I,L | |
2,I;3,I,R |
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 | |
import json | |
import os | |
import requests | |
import sys | |
from bs4 import BeautifulSoup | |
headers = { | |
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36' |
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
""" | |
The function simplex takes initial feasible dictionary of a LP problem with | |
m basic variables and n non-basic variables, represented by (m+1)x(n+1) matrix | |
wrapped in numpy.array, as its only input. | |
The format of the input matrix input is as follows: | |
In each row, the first column is reserved for additive constant | |
while the rest of the columns stores coefficients of non-basic variable. | |
The first row describes the objective function while the rest of the rows | |
list constraints. You can check some examples near the end of the file. |
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
/* g++ pi.cpp -o pi -std=c++14 -lSDL2 */ | |
/* Grab pi.csv from https://dsp.stackexchange.com/a/59181/70343 */ | |
#include <iostream> | |
#include <fstream> | |
#include <string> | |
#include <sstream> | |
#include <complex> | |
#include <vector> | |
#include <algorithm> |
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 matplotlib.pyplot as plt | |
import numpy as np | |
from math import comb, log | |
def annotate_max(x, y, ax=None): | |
xmax = x[np.argmax(y)] | |
ymax = y.max() | |
text= "U_A={:.3f}, S={:.3f}".format(xmax, ymax) | |
if not ax: |
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
# Draw 5 cards from the standard deck of 52 cards. Denote random variables X to be the number of black cards in the hand and Y to be the number of spades in the hand. | |
from math import comb | |
from pandas import DataFrame | |
nways = comb(52, 5) | |
joint_pmf = [[0.0 for x in range(7)] for y in range(7)] | |
total = 0.0 |
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
#include <iostream> | |
#include <bitset> | |
#include <cstdint> | |
#include <array> | |
using BYTE = uint8_t; | |
struct HALFWORD | |
{ | |
union |
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
{{FrontSide}} | |
<hr id=answer> | |
読み方: {{Reading}} <br> | |
品詞: {{PartOfSpeech}} <br> | |
{{#Picture}} | |
画像: <br> | |
<div id="center-text">{{Picture}}<br></div> |
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 sys import argv | |
import requests | |
import json | |
import os | |
import itertools | |
endpoint_url = "https://ssl.seiga.nicovideo.jp" | |
OUT_DIR = "out" | |
# endpoint + "/api/v1/comicwalker/episodes/" + episode_id + "/frames" |
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::process; | |
use std::thread; | |
use std::time::Duration; | |
use rand::Rng; | |
use sdl2::event::Event; | |
use sdl2::pixels::PixelFormatEnum; | |
const WIDTH: usize = 256; |
NewerOlder