Skip to content

Instantly share code, notes, and snippets.

View ShittyCodeMan's full-sized avatar

ShittyCodeMan ShittyCodeMan

View GitHub Profile
import sys
import math
from functools import cache
@cache
def de_bruijn_bits(n):
k = 2
a = [0] * k * n
sequence = [0]
from enum import IntEnum, auto
from urllib.request import urlopen
import lzma
import json
class DamageType(IntEnum):
Impact = 0
Puncture = auto()
Slash = auto()
Heat = auto()
@ShittyCodeMan
ShittyCodeMan / lightsout_solver.js
Last active April 4, 2025 07:52
ライツアウトのソルバーをNode.jsに移植して入力CLIを実装したやつ
const readline = require("readline");
const RESET = "\x1b[0m";
const REVERSE = "\x1b[7m";
const LIGHT = "#";
const DARK = ".";
const GOAL_STATE = 1;
const GRID_WIDTH = +process.argv[2] || 10;
const GRID_HEIGHT = +process.argv[3] || GRID_WIDTH;
@ShittyCodeMan
ShittyCodeMan / Poe2CurrencyExchangeRatio.js
Last active March 28, 2025 06:48
Path of Exile 1~2のカレンシー交換で小数点以下第二位表記の安価カレンシー/1高価カレンシーを整数の比に直すスクリプト
v=2.26;a=Math.round(v*100);b=100;while(a%=b)[a,b]=[b,a];[Math.round(100/b*v),100/b]
@ShittyCodeMan
ShittyCodeMan / check_twitch_drops.py
Last active March 28, 2025 07:12
Twitchドロップの残り時間をcmdで確認する
import requests
import math
import sys
import time
import ctypes
from functools import reduce
kernel32 = ctypes.windll.kernel32
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
@ShittyCodeMan
ShittyCodeMan / group_popularity.js
Last active October 10, 2024 23:03
村人の友好関係 (paizaランク S 相当)
//どう足掻いてもテストケースがタイムアウトするしにたい
class Node {
constructor(data, next = null) {
this.data = data;
this.next = next;
}
}
let lines = require('fs').readFileSync("/dev/stdin", "utf8").split("\n");
const [N, M, Q] = lines[0].split(" ").map(Number);
@ShittyCodeMan
ShittyCodeMan / mod7.js
Last active October 7, 2024 03:31
mod7占い (paizaランク S 相当)
lines = require('fs').readFileSync("/dev/stdin", "utf8").split`\n`;
const N = +lines[0];
const CARDS = lines.slice(1).map(Number);
let count = 0;
for (let i = 0; i < N-2; i++) {
for (let j = i+1; j < N-1; j++) {
for (let k = j+1; k < N; k++) {
if ((CARDS[i] + CARDS[j] + CARDS[k]) % 7 === 0) {
count++;
@ShittyCodeMan
ShittyCodeMan / search-island.js
Last active October 7, 2024 03:31
島探し (paizaランク S 相当)
lines = require('fs').readFileSync("/dev/stdin", "utf8").split`\n`;
const [M, N] = lines[0].split` `.map(Number);
let world = lines.slice(1, N+1).map(v => v.split` `.map(Number));
let count = 0;
const sinkIsland = sinkIslandEx.bind(null, M, N);
for (let y = 0; y < N; y++) {
for (let x = 0; x < M; x++) {
if (world[y][x] === 1) {
@ShittyCodeMan
ShittyCodeMan / DTMF.py
Last active March 28, 2025 07:06
2024年までの仕様のうえで最速でダイヤルが回せる音声ファイルを生成する
import math, wave, struct
def gen(c, duration, pause, volume):
S = "123A456B789C?0#D"
L = [697, 770, 852, 941]
H = [1209, 1336, 1477, 1633]
idx = S.find(c)
lo, hi = L[idx // 4], H[idx % 4]
s1 = [math.sin(2.0 * math.pi * lo * t / 44100) for t in range(int(44100 * duration))]
s2 = [math.sin(2.0 * math.pi * hi * t / 44100) for t in range(int(44100 * duration))]
@ShittyCodeMan
ShittyCodeMan / a_rank_graph_boss.js
Created August 12, 2024 07:30
連結の判定 (paizaランク A 相当)
let lines = require("fs").readFileSync("/dev/stdin", "utf8").split`\n`;
const [N, M] = lines[0].split` `.map(Number);
const S = lines.slice(1, M+1).map(v => v.split` `.map(v => +v-1));
const gathering = start => {
let found = [start];
const f = start => {
for (let v of vertices[start]) {
if (found.includes(v)) {
continue;