This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modeled after https://ericpony.github.io/z3py-tutorial/guide-examples.htm | |
# at a meetup someone mentioned a game for which they wanted to generate challenges with unique solutions and i proposed to use z3 for this | |
# the rules are similar to sudoku | |
# there are two symbols represented as -1 and 1 because this made calculations easier | |
from z3 import * | |
from itertools import * | |
import numpy as np |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://gcc.godbolt.org/z/n5eApv | |
// https://gcc.godbolt.org/z/Lximvt shorter, remove inline -> issue | |
// https://gcc.godbolt.org/z/dLznz9 wip more inline | |
// ok https://gcc.godbolt.org/z/3mv-Z6 | |
const std = @import("std"); | |
const warn = std.debug.warn; | |
const math = std.math; | |
const VALUE = enum { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://gcc.godbolt.org/z/dT6sd5 | |
use std::{ | |
future::Future, | |
pin::Pin, | |
task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, | |
}; | |
fn foo() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ported from https://www.craftinginterpreters.com/compiling-expressions.html#a-pratt-parser | |
fn main() { | |
let input = "10*2+3"; | |
assert_eq!(run(input), 10 * 2 + 3); | |
let input = "293474*4^5-50"; | |
assert_eq!(run(input), 300_517_376 - 50); | |
let input = "-50+3*2^3"; | |
assert_eq!(run(input), -50+3*8); |