Skip to content

Instantly share code, notes, and snippets.

Game Link Authors
Agent Aloe https://itch.io/jam/love2d-jam-2024/rate/2549349 @mehlerp
Back Window https://itch.io/jam/love2d-jam-2024/rate/2548702 @britdan
BangPong https://itch.io/jam/love2d-jam-2024/rate/2549445 @zhengying#5215
Body is thirsty https://itch.io/jam/love2d-jam-2024/rate/2550182 undercoverDemoness
BrightBound https://itch.io/jam/love2d-jam-2024/rate/2548448 @coldchange
BuiLLET HELL https://itch.io/jam/love2d-jam-2024/rate/2550565 @the_syncr0
Button Clicker https://itch.io/jam/love2d-jam-2024/rate/2546495 LolmanBruh
Catch the Interface https://itch.io/jam/love2d-jam-2024/rate/2547097 mitya
Click OK https://itch.io/jam/love2d-jam-2024/rate/2550183 @14rry.
namespace Alvornithms
{
class Itertools
{
static IEnumerable<T[]> Permutations<T>(T[] ts) where T : System.IComparable<T>
{
Array.Sort(ts);
while (true)
{
yield return (T[])ts.Clone();
@DUznanski
DUznanski / faction_list.py
Created July 13, 2018 17:26
Magic the Gathering faction list generator
def check_faction_set_validity(factions):
# count the number of on bits in each position for our list of faction IDs. If they're all the same, then the faction list is valid.
return factions and len({sum((faction >> k) & 1 for faction in factions) for k in range(5)}) == 1
def faction_string(faction):
return ''.join('WUBRG'[i] for i in range(5) if (faction >> i) & 1)
def faction_list_string(factions):
return ','.join(faction_string(faction) for faction in factions)
@DUznanski
DUznanski / abudhabi_greedy.py
Created July 12, 2018 16:12
Greedy algorithm for abudhabi
from collections import Counter
def abudhabi_greedy(target, candidates):
true_candidates = sorted(candidates + candidates, reverse=True)
signatures = set()
for result in greedy_algorithm(target, true_candidates):
count = Counter(result)
signature = tuple(count[k] for k in candidates)
if signature not in signatures:
yield signature
# random-fill testing:
def makes_sufficently_large_table():
unittest.assertEqual(generate_choices([('a',2),('b',1),('c',2)]), ['a','a','b','c','c'])
# ... similar. Include, among others, things with fallbacks that don't get used.
def fills_small_table():
choices = generate_choices([('a',2),('b',1),('c',0),('d',0)])
# make sure the first part is all the ones with known frequencies
# this actually suggests that what we really want is to break this down into more functions:
@DUznanski
DUznanski / 12marbles.py
Created October 2, 2017 02:02
12 Marbles Problem
from collections import Counter, defaultdict
from itertools import combinations_with_replacement, product
def sgn(x):
"""Return -1, 0, or 1, whichever matches the sign of x."""
if x < 0: return -1
if x > 0: return 1
return 0
# generate the layouts and make it easy to find the signatures.
function aStar_compare(a, b) {
return a.cost + a.estimate < b.cost + b.estimate || (a.cost + a.estimate == b.cost + b.estimate && a.cost < b.cost);
}
var Heap = function(compare) {
if (!compare) {
compare = function(a, b) {return a < b;};
}
this.compare = compare;
this.heap = [];
#!/usr/bin/env/python3
import random
gaps = []
events = 0
current_gap = 0
for trial in range(1000000):
if random.random() < (1/500):
gaps.append(current_gap)
current_gap = 0
events += 1
do
local ArcGroup_class_table = {}
function ArcGroup(x, y)
-- construct an ArcGroup around the chosen point. The starting interval is a single arc,
-- containing the whole circle.
return setmetatable({x = x, y = y, intervals = {{0, 2*math.pi}}}, { __index = ArcGroup_class_table })
end
function ArcGroup_class_table:width()
Apr 12 19:49:38 <zHafydd> You can derive 11^5 from the 11th row of Pascal's triangle: 1, 5, 10, 10, 5, 1.
Apr 12 19:50:13 <lemonade`> how would that work?
Apr 12 19:50:28 <zHafydd> 11^5 = 1 + 5*10 + 10*10^2 + 10*10^3 + 5*10^4 + 1*10^5
Apr 12 19:51:11 <zHafydd> A consequence of the binomial theorem.
Apr 12 19:51:14 <lemonade`> weird.
Apr 12 19:51:50 <zHafydd> If you think it's weird, you haven't thought about it enough.
Apr 12 19:52:25 <baxx> zHafydd: should the binomial be obvious?
Apr 12 19:52:30 <lemonade`> I likely haven't. I'm on it now :)
Apr 12 19:53:08 <zHafydd> baxx: should the binomial theorem be obvious? To a person practicing mathematics beyond an elementary level, yes.
Apr 12 19:53:35 <baxx> zHafydd: because they've been told or because, using a basic toolset, it's obvious