Skip to content

Instantly share code, notes, and snippets.

View woodrush's full-sized avatar

Hikaru Ikuta woodrush

View GitHub Profile
@woodrush
woodrush / MakeNGameSolver.lisp
Last active August 29, 2015 14:10
Solves the generalized version of the "Make 10 with 4 numbers" game (use for around 4 numbers)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Make N Game Solver
;; Naiive version
;; 11.24.2014
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar *target* 10)
@woodrush
woodrush / MakeNGameSolver.py
Last active August 29, 2015 14:10
Solves the generalized version of the "Make 10 with 4 numbers" game. Usage: "$ python MakeNGameSolver.py"
#coding: utf-8
from itertools import combinations
from collections import Counter
from operator import *
import random
targetNum = 10
numlist = sorted([random.randint(1,100) for i in range(100)])
searchMode = 0
# 0: Randomized search (fast for long number lists, doesn't stop if no solutions exist)
@woodrush
woodrush / varargsify-hy.hy
Created July 25, 2017 23:13
Hy macros for creating varargs versions of a fixed-args macro
(defmacro defmacro-varargsify [m margs &rest mbody]
"
Defines an N-argument macro to a n*N-argument macro,
where the original macro is applied using each of the N arguments.
Example:
(defmacro-varargsify a [x y]
`(print (+ ~x ~y)))
(a 1 2 3 4 5 6)
@woodrush
woodrush / placeholder-macro.hy
Last active August 17, 2017 18:43
Scala-style placeholder functions in Hy
;;; Same, but with macros
(defmacro pm [expr &rest args]
(defn _listlike? [l]
(or
(= hy.models.HyList (type l))
(= hy.models.HyExpression (type l))
(= list (type l))))
(defn _recursive-count [l]
@woodrush
woodrush / pokemon-wordle-entropy.txt
Created February 3, 2022 15:53
ポケモンWordleにおける初手回答ポケモンのエントロピー
1 ジーランス 2.81552027301750 53 [136, 71, 55, 36, 24, 17, 16, 15, 14, 11, 10, 9, 8, 8, 7, 6, 6, 5, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
2 レントラー 2.80590281618208 46 [143, 54, 54, 38, 22, 21, 21, 15, 13, 12, 9, 9, 9, 7, 7, 7, 6, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
3 ネンドール 2.76650256510168 44 [152, 57, 52, 30, 25, 22, 19, 15, 13, 10, 9, 8, 8, 7, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
4 グラードン 2.75490681338029 58 [163, 78, 36, 30, 22, 16, 15, 12, 11, 11, 11, 10, 9, 7, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
5 ランクルス 2.73260697699840 48 [152, 60, 53, 32, 31, 20, 17, 14, 14, 11, 10, 9, 8, 7, 7, 6, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
6 ルナトーン 2.71418343665737 46 [145, 56, 47, 39, 34, 32, 18, 16,
@woodrush
woodrush / pokedle-normal-entropy.txt
Last active February 3, 2022 17:44
Pokedleのノーマルモードにおける初手回答ポケモンのエントロピー
1 ジーランス 2.81829961417558 53 [137, 71, 55, 36, 24, 18, 18, 15, 14, 11, 10, 10, 8, 8, 7, 6, 6, 5, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
2 レントラー 2.81370559638248 47 [143, 56, 54, 38, 22, 22, 22, 15, 13, 12, 9, 9, 9, 7, 7, 7, 6, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
3 ネンドール 2.75997489897431 44 [154, 57, 54, 30, 25, 22, 19, 16, 13, 10, 9, 8, 8, 7, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
4 グラードン 2.75770580942433 58 [164, 78, 36, 32, 23, 16, 15, 12, 11, 11, 11, 10, 9, 7, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
5 ランクルス 2.73115286105027 48 [153, 63, 53, 32, 31, 20, 17, 14, 14, 11, 10, 9, 8, 7, 7, 6, 5, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
6 ルナトーン 2.72005023450342 46 [145, 56, 47, 41, 34, 32, 19,
@woodrush
woodrush / pokedle-hard-entropy.txt
Created February 3, 2022 16:41
Pokedleのハードモードにおける初手回答のエントロピー
1 マンキー 3.00312777465967 61 [186, 152, 63, 62, 45, 42, 40, 30, 26, 23, 19, 18, 14, 14, 10, 10, 10, 9, 9, 9, 8, 8, 7, 7, 7, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
2 チリーン 2.96396350655794 72 [191, 166, 85, 65, 44, 32, 26, 23, 21, 19, 18, 17, 16, 14, 13, 11, 11, 10, 9, 9, 8, 6, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
3 マンムー 2.96375620314442 65 [191, 151, 72, 67, 42, 40, 38, 30, 27, 23, 18, 18, 13, 13, 13, 11, 11, 9, 9, 9, 9, 8, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
4 コクーン 2.95295816571321 66 [186, 159, 94, 69, 41, 33, 27, 24, 21, 21, 19, 19, 17, 14, 11, 9, 9, 9, 8, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
5 ガルーラ 2.91500277145171 6
@woodrush
woodrush / card-puzzle.py
Created July 4, 2022 01:26
Card Puzzle
# A solver for https://twitter.com/ikeikey/status/1543710547874615297
import numpy as np
def search(A, l_count, handlist, i, j):
if i == 7 and j == 7:
return A
elif i == j:
return search(A, l_count, handlist, i, j+1)
l_count = list(l_count)
@woodrush
woodrush / metacircular.lisp
Created September 20, 2022 14:50
Metacircular evaluator for LambdaLisp
;; Original code: https://github.com/jart/sectorlisp/blob/main/lisp.lisp
;; Runs on LambdaLisp: https://github.com/woodrush/lambdalisp
(let ((assoc*) (evcon) (pairlis) (evlis) (apply*) (eval*))
(setq assoc*
(lambda (x y)
(cond ((eq y ()) ())
((eq x (car (car y)))
(cdr (car y)))
((quote t)
(assoc* x (cdr y))))))
@woodrush
woodrush / meta-metacircular.lisp
Created September 20, 2022 15:40
Meta-Metacircular evaluator for LambdaLisp
;; Original code: https://github.com/jart/sectorlisp/blob/main/lisp.lisp
;; Runs on LambdaLisp: https://github.com/woodrush/lambdalisp
(let ((assoc*) (evcon) (pairlis) (evlis) (apply*) (eval*))
(setq assoc*
(lambda (x y)
(cond ((eq y ()) ())
((eq x (car (car y)))
(cdr (car y)))
((quote t)
(assoc* x (cdr y))))))