Skip to content

Instantly share code, notes, and snippets.

@rprtr258
rprtr258 / quicksort.ink
Last active November 1, 2024 16:10
ink std to import
` minimal quicksort implementation
using hoare partition `
{map, clone} := import('std.ink')
sortBy := (v, pred) => (
vPred := map(v, pred)
partition := (v, lo, hi) => (
pivot := vPred.(lo)
lsub := i => (vPred.(i) < pivot) :: {
@rprtr258
rprtr258 / chans.go
Last active June 30, 2024 15:29
golang coroutines benchmark
package main
import "strings"
func chan_fromstring(input string) <-chan byte {
ch := make(chan byte)
go func() {
for _, c := range input {
ch <- byte(c)
}
@rprtr258
rprtr258 / t_test.go
Last active May 7, 2023 00:09
direct call/interface/function pointer benchmark
package tt
/*
goos: linux
goarch: amd64
cpu: Intel(R) Core(TM) i3-6100U CPU @ 2.30GHz
BenchmarkInterface-4 402143721 2.880 ns/op
BenchmarkTemplate-4 205737126 6.119 ns/op
BenchmarkDirect-4 1000000000 0.5869 ns/op
BenchmarkFunctionPointer-4 166973348 6.738 ns/op
@rprtr258
rprtr258 / main.go
Last active October 12, 2022 11:36
holes count program
package main
import (
"fmt"
"os"
)
var _table = map[rune]int{
// Numbers
'0': 1,
@rprtr258
rprtr258 / main.py
Last active April 20, 2021 12:08
cps
def nop(*args): pass
def f(n, e=lambda f:f()):
print(f"f#{n} started")
def cont(k=nop):
print(f"f#{n} ended")
k()
e(cont)
f(1, lambda cont: f(2, lambda cont2: cont(cont2)))
@rprtr258
rprtr258 / autotest.js
Last active April 26, 2021 22:55
vanuchaya
/*
Автоматическое прохождение проверочных заданий. Просто нажимает все первые ответы и отправляет.
Неправильные ответы можно исправить вручную.
*/
$(".response-label > input[value=choice_0]").click();
$("button.submit").click();
setTimeout(() => {
for (let f of $(".notification.error.notification-submit"))
f.parentNode.querySelector("input[value=choice_1]").click();
$("button.submit").click();
@rprtr258
rprtr258 / 1.csv
Last active November 8, 2019 15:33
flats dataset
METRO_DISTANCE PRICE
677 7328400
120 9754600
1344 6781500
1003 6784100
591 7296200
719 8121900
406 8889400
216 9819000
2497 3924500