This file contains hidden or 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 PIL import Image, ImageDraw, ImageChops, ImageEnhance | |
| img = Image.open("animal_arupaka.png") | |
| dat = img.split() | |
| r,b,g,a = img.split() | |
| basecolor = (212, 195, 188) #毛の色 | |
| cangap = 18 | |
| # 毛を推察する。+-gapは許容 | |
| r = r.point(lambda x: 1 if basecolor[0] - cangap <= x <= basecolor[0] + cangap else 0, mode="1") |
This file contains hidden or 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 multiprocessing import Pool | |
| multi = 10 | |
| N = 10**4 | |
| mod = 10**9 + 7 | |
| def f(x): | |
| data = [x] * N | |
| for i in range(N): | |
| for j in range(N): |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """ | |
| ガチャシミュレーション | |
| ./try.py [percent] [kai] | |
| percentパーセント(1.5%なら1.5と入力)であたりがでるガチャを、あたりが出るまで引きます。 | |
| これをkai回試して、何回で引くことができたかの分布を出力します。 | |
| 実行例 | |
| ./try2.py 1.5 100 |
This file contains hidden or 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
| def do(): | |
| while True: | |
| from collections import deque | |
| w, h = map(int, input().split()) | |
| if w == h == 0: break | |
| maze = [] | |
| curh, curw = -1, -1 | |
| maze.append("#" * (w+2)) | |
| for hh in range(h): | |
| l = list("#" + input() + "#") |
This file contains hidden or 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
| # !!pip install japanmap | |
| from japanmap import pref_names,pref_code,picture | |
| %matplotlib inline | |
| import matplotlib.pyplot as plt | |
| from pylab import rcParams | |
| rcParams['figure.figsize'] = 8,8 | |
| # 硬度ランキング | |
| rank = [ | |
| "沖縄", "千葉", "埼玉", "熊本", "茨城", | |
| "東京", "神奈川", "福岡", "愛媛", "群馬", |
This file contains hidden or 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
| """ | |
| 課題意識: | |
| マイクラ統合版(Win)ではチャットウィンドウに複数行送れない | |
| 建物を立てるためのコマンドを生成しても、1行ずつコピペしないとならず苦行 | |
| アプローチ: | |
| キーボードエミュレートして生成したコマンドを流し込む. | |
| キーを流し込む際にはマイクラにフォーカスがないとならないのでキーボードのフックもする。 | |
| 使い方: |
This file contains hidden or 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
| """ | |
| insert_numbers(85229ul); // AtCoder C++20, C++23 gcc12.2 killer | |
| insert_numbers(107897);// CodeForces C++11, C++14 killer | |
| insert_numbers(126271);// CodeForces C++17 killer | |
| """ | |
| N = 200000 | |
| # output points | |
| cur = 0 | |
| magic = 85229 | |
| # point |
This file contains hidden or 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
| # python3 makeCasePythonKiller.py > testcases/in/pythondictkiller.txt | |
| n = 200000 | |
| mask = (1<<17) - 1 # 0xffff | |
| fill = int((1<<15)*1.3+1) # 43599 | |
| arr = [mask+2]*2 | |
| x = 6 # magic number | |
| for i in range(1,fill): | |
| arr += [x]+[x] | |
| x = (x * 5 + 1) & mask | |
| arr += [1]*(n-len(arr)) |
This file contains hidden or 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 time | |
| # [1, 2, 3, ...N, 1, 2, 3, ...N]というリストを作る | |
| n = 200000 | |
| start = time.time() | |
| listSeq = list(range(n//2)) | |
| d = dict() | |
| for x in listSeq: d[x] = True | |
| print("listSeq elapsed_time:{0}".format(time.time() - start) + "[sec]") # listSeq elapsed_time:0.0070133209228515625[sec] | |
| # [2^17+1(=1), 6,31, 156]というリストを作る |
This file contains hidden or 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
| """ | |
| https://twitter.com/recuraki/status/1741709264471937422 | |
| 大吉の入ったおみくじがある。おみくじは引かれると消費される。 | |
| 他の参拝者は大吉を引くまで連続しておみくじを引く。 | |
| この時、自分がおみくじを最初に引くのと後で引くので大吉を引く確率は異なるか? | |
| 自分を含めて参拝者は他の参拝者の結果を見て引く引かないを決めない。 | |
| ↓ | |
| n, m: 全体, 大吉の数 |