Skip to content

Instantly share code, notes, and snippets.

View felixdae's full-sized avatar

Zhangqiu Yu felixdae

  • lemei tech
  • ShenZhen, China
View GitHub Profile
@felixdae
felixdae / tic_tac_toe.py
Created July 4, 2023 15:48
solve tic tac toe
import copy
from typing import List, Dict
def encode(board: List[List[int]]) -> int:
tmp = []
tmp.extend(board[0])
tmp.extend(board[1])
tmp.extend(board[2])
val = 0
@felixdae
felixdae / arnold.py
Created January 15, 2022 16:05
to show the insolvability of the quintic by computing nested commutators
import itertools
def reverse(forward: tuple) -> tuple:
lst = [-1 for _ in forward]
for idx in range(len(forward)):
lst[forward[idx]] = idx
return tuple(lst)
@felixdae
felixdae / 24.py
Created December 19, 2021 17:13
given 4 digits, compute how to get 24 by +,-,*,/
from itertools import permutations
class Stack:
def __init__(self):
self.arr = []
def push(self, val):
self.arr.append(val)
@felixdae
felixdae / Y Combinator in Haskell.md
Created June 9, 2019 08:02 — forked from lukechampine/Y Combinator in Haskell.md
Deriving the Y Combinator in Haskell

The Y Combinator

The Y Combinator is a classic lambda calculus construct that many people find baffling. Here's my attempt to explain it as clearly as possible (no promises!). Familiarity with Haskell syntax is assumed.

The problem we're trying to solve is how to write an anonymous function (a "lambda") that is recursive. Normally, if you want to write a recursive function, it looks like this:

fac n = if n == 0 then 1
        else n * fac (n-1)
import io
import numpy as np
from PIL import Image
import tensorflow as tf
class Tensorboard:
def __init__(self, logdir):
self.writer = tf.summary.FileWriter(logdir)
def close(self):
@felixdae
felixdae / mysqlpool.scala
Created July 16, 2016 12:50 — forked from tsuna/mysqlpool.scala
MySQL JDBC connection pool for Scala + Finagle
// Copyright (C) 2012 Benoit Sigoure
// Copyright (C) 2012 StumbleUpon, Inc.
// This library is free software: you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 2.1 of the License, or (at your
// option) any later version. This program is distributed in the hope that it
// will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
// General Public License for more details. You should have received a copy
// of the GNU Lesser General Public License along with this program. If not,
{------------------------------------------------
A Haskell solution to: http://www.coinheist.com/rubik/a_regular_crossword/grid.pdf
using the Z3 SMT solver.
Z3 finds the following solution in about 7 mins
on my Mac Core-i5, and another 7 mins to prove
it's unique.
NHPEHAS
DIOMOMTH
private static uint GetUint()
{
m_z = 36969 * (m_z & 65535) + (m_z >> 16);
m_w = 18000 * (m_w & 65535) + (m_w >> 16);
return (m_z << 16) + (m_w & 65535);
}