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
using StringDistances | |
function countdict(qgrams) | |
d = Dict{eltype(qgrams), Int32}() | |
for qg in qgrams | |
index = Base.ht_keyindex2!(d, qg) | |
if index > 0 | |
d.age += 1 | |
@inbounds d.keys[index] = qg | |
@inbounds d.vals[index] = d.vals[index][1] + 1 |
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
# Checking the "Boxes puzzle" solution strategy via stochastic simulation. | |
# robert.feldt@gmail.com 2022 | |
using Random # We need randperm below | |
# Fill N boxes by getting a random permutation of length N. | |
fillboxes(N) = randperm(N) | |
# Given a strategy, simulate its use by N people and return true iff strategy | |
# worked for them all. |
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
# Setup step 0: Build PyCall.jl for right Python binary | |
# | |
# Might be needed to ensure the right python is used, here for my homebrew | |
# installed python3 on a M1 MacBook Pro: | |
# ENV["PYTHON"] = "/opt/homebrew/bin/python3" | |
# using Pkg | |
# Pkg.build("PyCall") | |
# Setup step 1: Ensuring you have access to GPT-SW3 by setting up a token on Hugging Face | |
# a. login on HF: https://huggingface.co/login |
OlderNewer