Skip to content

Instantly share code, notes, and snippets.

import java.io.File
import java.util.SortedSet
fun main() {
val FIRST_SAMPLES_COUNT = 1000
val input = File("input.txt").readLines()
.map { it.split(',').map(String::toLong) }
val circuits = input.withIndex().mapTo(ArrayList())
{ (idx, _) -> hashSetOf(idx) }
package main
import (
"bytes"
"fmt"
"os"
)
type Beam struct {
X int
#include <iostream>
#include <fstream>
#include <sstream>
int main() {
std::ifstream file("input.txt");
std::string A, B, C, D, O;
std::getline(file, A);
std::getline(file, B);
std::getline(file, C);
input = document.querySelector('pre').innerText;
[ranges, ids] = input.split('\n\n').map(x => x.split('\n'));
ranges = ranges.map(r => r.split('-').map(x => parseInt(x)));
console.log(ids.filter(id => ranges.some(r => id >= r[0] && id <= r[1])).length)
function mergeRanges() {
const N = ranges.length
for (let i = 0; i < N; ++i)
for (let j = 0; j < N; ++j) {
string[] lines = File.ReadAllLines("input.txt");
int W = lines[0].Length, H = lines.Length;
char[][] map = lines
.Select(l => $".{l}.")
.Prepend(new string('.', 2 + W))
.Append(new string('.', 2 + W))
.Select(l => l.ToCharArray())
.ToArray();
(int dx, int dy)[] NeighbourOffsets = {
function joltage(line, n)
local index = 1
local result = 0
for a = 1, n do
local maxDigit = line:byte(index)
for i = index, #line - (n - a) do
if line:byte(i) > maxDigit then
maxDigit = line:byte(i)
index = i
end
(module
(import "sys" "open" (func $open (param i32 i32 i32 i32) (result i32)))
(import "sys" "close" (func $close (param i32)))
(import "sys" "read" (func $read (param i32 i32 i32) (result i32)))
(import "sys" "write" (func $write (param i32 i32 i32) (result i32)))
(memory (export "memory") 1)
(data (i32.const 0) "input.txt")
(module
(import "sys" "open" (func $open (param i32 i32 i32 i32) (result i32)))
(import "sys" "close" (func $close (param i32)))
(import "sys" "read" (func $read (param i32 i32 i32) (result i32)))
(import "sys" "write" (func $write (param i32 i32 i32) (result i32)))
(memory (export "memory") 1)
(data (i32.const 0) "input.txt")
default rel
section .data
filename: db "input.txt", 0
section .bss
char: resq 1
number_string: resq 32
number: resq 1
isL: resq 1
@dkaraush
dkaraush / oklch2rgb.js
Last active November 5, 2025 15:58
conversion OKLCH into RGB and RGB into OKLCH in js, simplified
const multiplyMatrices = (A, B) => {
return [
A[0]*B[0] + A[1]*B[1] + A[2]*B[2],
A[3]*B[0] + A[4]*B[1] + A[5]*B[2],
A[6]*B[0] + A[7]*B[1] + A[8]*B[2]
];
}
const oklch2oklab = ([l, c, h]) => [
l,