🌲 Invert a binary tree! 🌲
Except with 3 catches:
- It must invert the keys ("bit-reversal permutation")
- It must be a dependency-free, pure recursive function
- It must have type
Bit -> Tree -> Tree
(i.e., a direct recursion with max 1 bit state)
public static int hash(String... args) { | |
if (args != null) { | |
switch (args.length) { | |
case 1: | |
return 31 + Objects.hashCode(args[0]); | |
case 2: | |
return 961 + Objects.hashCode(args[0]) * 31 | |
+ Objects.hashCode(args[1]); | |
case 3: | |
return 29791 + Objects.hashCode(args[0]) * 961 |
# THIS LINUX SETUP SCRIPT HAS MORPHED INTO A WHOLE PROJECT: HTTPS://OMAKUB.ORG | |
# PLEASE CHECKOUT THAT PROJECT INSTEAD OF THIS OUTDATED SETUP SCRIPT. | |
# | |
# | |
# Libraries and infrastructure | |
sudo apt update -y | |
sudo apt install -y \ | |
docker.io docker-buildx \ | |
build-essential pkg-config autoconf bison rustc cargo clang \ |
#include <stdio.h> | |
#include <stdlib.h> | |
#define da_append(xs, x) \ | |
do { \ | |
if ((xs)->count >= (xs)->capacity) { \ | |
if ((xs)->capacity == 0) (xs)->capacity = 256; \ | |
else (xs)->capacity *= 2; \ | |
(xs)->items = realloc((xs)->items, (xs)->capacity*sizeof(*(xs)->items)); \ | |
} \ |
FROM quay.io/fedora/fedora:38 | |
# Install requirements for building OpenJDK from source | |
RUN dnf install -y \ | |
file \ | |
diffutils \ | |
alsa-lib-devel \ | |
cups-devel \ | |
fontconfig-devel \ | |
freetype-devel \ |
/* | |
@robertkingnz | |
https://www.youtube.com/c/RobertKing/videos -> https://youtu.be/Z5WzJ9jbnKg | |
https://codingcompetitions.withgoogle.com/kickstart/round/00000000008cb0f5/0000000000ba86e6 | |
*/ | |
extern crate core; | |
fn calc_toll(c: i64, toll: &(char, i64)) -> i64 { | |
let ans = match toll.0 { |
<!-- plug-in configuration to put into your parent POM for avoiding any usages of | |
outdated log4j2 versions, some of which are subject to the RCE CVE-2021-44228 | |
("Log4Shell"), CVE-2021-45046, and CVE-2021-45105. Make sure to check for the | |
latest version of log4j2 at | |
https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core --> | |
... | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-enforcer-plugin</artifactId> | |
<version>3.0.0</version> |
// Extremely hacky server program that will send a standard response | |
// to every client that connects, then closes the connection. Will | |
// issue no system calls (as measured by `strace`) after initial setup | |
// no matter how many requests are served. | |
// Yes, this program is sorely lacking in error checking. It's a toy | |
// and not meant to be taken seriously. | |
// compile with gcc no_syscall_server.c -luring |
#!/usr/bin/env python3 | |
# | |
# Copyright 2021 Matt Fleming | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# |
/* | |
* MIT License | |
* | |
* Copyright (c) 2021 Brice Dutheil <[email protected]> | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is |