Skip to content

Instantly share code, notes, and snippets.

View ali2210's full-sized avatar
🦀
building empire

Ali Hassan ali2210

🦀
building empire
View GitHub Profile
@17twenty
17twenty / crazyOlSelectCase.go
Last active April 27, 2025 23:34
Using reflect.SelectCase - an example
package main
import (
"log"
"reflect"
"time"
)
func main() {
c1 := make(chan int)
@LiveOverflow
LiveOverflow / AcoraidaMonicaGame.sol
Last active January 24, 2025 19:53
Acoraida Monica
pragma solidity =0.4.25;
contract AcoraidaMonicaGame{
uint256 public version = 4;
string public description = "Acoraida Monica admires smart guys, she'd like to pay 10000ETH to the one who could answer her question. Would it be you?";
string public constant sampleQuestion = "Who is Acoraida Monica?";
string public constant sampleAnswer = "$*!&#^[` [email protected];Ta&*T` R`<`~5Z`^5V You beat me! :D";
Logger public constant logger=Logger(0x5e351bd4247f0526359fb22078ba725a192872f3);
address questioner;
string public question;
// You can edit this code!
// Click here and start typing.
package main
import (
"fmt"
"reflect"
)
type Person struct {

fiveoutofnine simplified

Some of the bit twiddling in my Solidity implementation of an on-chain engine, fiveoutofnine.sol, can be quite esoteric, so I've recreated some of the logic below. Note that the code below is only logically equivalent (gives same results, but do different things). Functions have similar names, so it should be pretty easy to match up to the functions from Chess.sol and Engine.sol. The main abstraction in these files are using an array for the board (as opposed to 64 bitpacked uint4s) and struct for moves (as opposed to 2 bitpacked uint6s). To further simplify it, it's in a language anyone can read easily: Python.

Chess.py

class Move:
    def __init__(self, from, to):
        self.from = from
        self.to = to