Skip to content

Instantly share code, notes, and snippets.

View arknave's full-sized avatar

Arnav Sastry arknave

View GitHub Profile
@arknave
arknave / PKGBUILD
Created February 13, 2021 15:54
PKGBUILD for kattis-problemtools
# Maintainer: Thorsten Wißmann <edu@thorsten-wissmann.de>
pkgname=kattis-problemtools
pkgver=v1.20201230
pkgrel=1
pkgdesc="Tools to manage problem packages using the Kattis problem package format"
arch=('i686' 'arm' 'x86_64')
url="https://github.com/Kattis/problemtools"
license=('MIT')
depends=('python' 'gmp' 'java-environment' 'plastex' 'python-yaml')
makedepends=('python-setuptools' 'boost')
// Say you have an integer array of length n. Then this monstrosity sorts it, slowly.
void cursed_sort(int* a, int n) {
int*q,i;
for(i=0;i<n;++i)
for(q=a;q+1<a+n;++q)
if(*q>*(q+1))
*q^=*(q+1)^=*q^=*(q+1);
}
Hello Challenge!
@arknave
arknave / CharCounter.hs
Created December 25, 2016 03:55
Counts characters in Golf.hs. Strips out imports, type definitions, and whitespace
import Data.List.Split
valid :: String -> Bool
valid "" = False
valid s = not $ foldr (\a b -> b || a `elem` ["::", "import", "->", "module" ]) False $ words s
count :: String -> Int
count s = if valid s then length . concat $ words s else 0
main = do
public class Trie {
final static int ALPHABET_SIZE = 26;
Trie[] children;
public Trie() {
this.children = new Trie[ALPHABET_SIZE];
}
// return true if the word added is new.
public boolean insert(String s) {
#include <iostream>
#include <cstring>
#define MAX_LETTERS 600005
#define ALPHABET_SIZE 26
using namespace std;
// These two structures should be intiialized to all 0
// (0 is the root and should never be the child of another node)
int trie[MAX_LETTERS][ALPHABET_SIZE];
@arknave
arknave / perms.cpp
Last active November 13, 2015 19:53
N = length(perm);
do {
print(perm);
} while (next_permutation(perm, perm + N));
for (int i = 0; i < N; i++) {
dist[i] = INFINITY;
}
dist[start] = 0;
for (int k = 0; k < N - 1; k++) {
for (int i = 0; i < N; i++) {
for (int e = 0; e < adj[i].size(); e++) {
int j = adj[i][e].vertex;
// Assume N is the number of vertices
for (int k = 0; k < N; k++) {
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
dist[i][j] = min(dist[i][j],
dist[i][k] + dist[k][j]);
}
}
}

Keybase proof

I hereby claim:

  • I am arknave on github.
  • I am arknave (https://keybase.io/arknave) on keybase.
  • I have a public key whose fingerprint is 86D1 F11A 1C62 FD23 EAFD E7E2 A108 24C9 4330 0001

To claim this, I am signing this object: