Skip to content

Instantly share code, notes, and snippets.

@hoheinzollern
hoheinzollern / wordle.py
Created February 14, 2022 13:50
Returns all valid guesses from the linux dictionary: `y` defines the letters to be included, `n` defines the letters to be excluded, `g` contains a space where the character is unknown, the right letter otherwise, and `e` contains the excluded letters from each position
words = open('/usr/share/dict/words').read().splitlines()
l5w = list(filter(lambda x: len(x) == 5 and x.islower() and x.isalpha(), words))
def guess(y, n, g=' ', e=['','','','','']):
return list(
filter(
lambda x:
all(c in x for c in y) and
all(not(c in x) for c in n) and
import Data.List
data Choose a = Choose [a]
deriving (Eq, Show)
choices (Choose xs) = xs
instance Functor Choose where
fmap f (Choose xs) = Choose $ map f xs
from z3 import *
def find_path(path, f, *args, **kwargs):
log = []
def unwrap(other):
try:
return other.v
except:
return other
class Sym:
module Main where
import Data.List
import Control.Exception
instance Show Expr where
show (e@(Plus e1 e2)) = autoparl e e1 ++ " + " ++ autoparr e e2
show (e@(Minus e1 e2)) = autoparl e e1 ++ " - " ++ autoparr e e2
show (e@(Times e1 e2)) = autoparl e e1 ++ " * " ++ autoparr e e2
show (e@(Div e1 e2)) = autoparl e e1 ++ " / " ++ autoparr e e2
show (Const x) = show x
*** Date: Friday, December 7, 2012 10:25:15 AM Central European Time
*** Platform Details:
*** System properties:
awt.nativeDoubleBuffering=true
awt.toolkit=apple.awt.CToolkit
eclipse.application=org.eclipse.ui.ide.workbench
eclipse.buildId=M20120208-0800
eclipse.commands=-os
@hoheinzollern
hoheinzollern / gist:4223830
Created December 6, 2012 11:29
Eclipse configuration
*** Date: Thursday, December 6, 2012 12:29:19 PM Central European Time
*** Platform Details:
*** System properties:
applicationXMI=org.eclipse.ui.workbench/LegacyIDE.e4xmi
awt.nativeDoubleBuffering=true
awt.toolkit=apple.awt.CToolkit
eclipse.application=org.eclipse.ui.ide.workbench
eclipse.buildId=M20120914-1800
@hoheinzollern
hoheinzollern / WekaTest.java
Created August 2, 2012 09:07
Clustering in Weka
import java.awt.Container;
import java.awt.GridLayout;
import java.util.ArrayList;
import javax.swing.JFrame;
import weka.clusterers.HierarchicalClusterer;
import weka.core.Attribute;
import weka.core.DenseInstance;
import weka.core.EuclideanDistance;
from copy import deepcopy
from pprint import pprint
board = [
[-1,-1, 1, 1, 1,-1,-1],
[-1,-1, 1, 1, 1,-1,-1],
[ 1, 1, 1, 1, 1, 1, 1],
[ 1, 1, 1, 0, 1, 1, 1],
[ 1, 1, 1, 1, 1, 1, 1],
[-1,-1, 1, 1, 1,-1,-1],
%% instance
place(1).
place(2).
place(3).
place(4).
transition(1).
transition(2).
t_pre(1,1).
t_post(1,2).
@hoheinzollern
hoheinzollern / admin.py
Created October 4, 2011 07:25
Reordering of tabular inlines in Django administration website.
from django.contrib import admin
class SlaveInline(admin.TabularInline):
model = Slave
extra = 0
class MasterAdmin(admin.ModelAdmin):
inlines = (SlaveInline,)
class Media: