Skip to content

Instantly share code, notes, and snippets.

from collections import defaultdict
import sys
N = int(sys.stdin.readline())
grid = defaultdict(lambda: 0)
grid[0, 0] = 1
x, y = 0, 0
dx, dy = 1, 0
while grid[x, y] <= N:
@maksverver
maksverver / PKGBUILD
Created July 16, 2017 12:37
Fix for Katawa Shoujo with Ren'Py > 6.99.10
# Based on original katawa-shoujo PKGBUILD (but use native renpy instead of bundled one) written by Anton Larionov <diffident dot cat at gmail dot com>
# Maintainer: Cravix < dr dot neemous at gmail dot com >
pkgname=katawa-shoujo
pkgver=1.3.1
pkgrel=2
pkgdesc="a bishoujo-style visual novel by Four Leaf Studios built on renpy"
arch=('any')
url='http://katawa-shoujo.com/'
license=('CCPL:BY-NC-ND')
@maksverver
maksverver / PKGBUILD
Created July 6, 2017 20:21
Golly 2.8 PKGBUILD
# Maintainer: Kyle Sferrazza <kyle.sferrazza@gmail.com>
# Contributor: Maks Verver <maksverver@geocities.com>
# Contributor: p2k <Patrick.Schneider@uni-ulm.de>
# Contributor: nokangaroo <nokangaroo@aon.at>
pkgname=golly
pkgver=2.8
pkgrel=3
pkgdesc="A simulator for Conway's Game of Life and other cellular automata"
arch=('i686' 'x86_64')
from __future__ import print_function
digits = [
[3,3,3,5,6,3,6,3],
[3,6,6,3,3,5,6,3],
[3,3,3,3,3,2,3,3],
[3,3,5,3,3,3,3,3],
[2,3,3,3,3,3,3,3],
[3,6,3,3,3,2,3,2],
[3,3,3,4,3,3,3,3],
#include <stdio.h>
#include <assert.h>
/* Calculates the square root of a nonnegative number using Newton's method. */
double square_root(double a) {
assert(a >= 0);
if (a == 0) return 0;
double x = a, prev;
do {
prev = x;
@maksverver
maksverver / Makefile
Last active August 25, 2016 12:26
Sentinel linear search benchmark
CFLAGS=-std=c99 -O3 -march=native
OBJS=main.o search1.o search2.o search3.o
main: $(OBJS)
cc -o $@ $(OBJS)
clean:
rm -f $(OBJS)
@maksverver
maksverver / planet-explore.c
Last active August 21, 2016 00:22 — forked from skeeto/planet-explore.c
Planet exploration solver
/* 1) Immediately prints the base puzzle SVG to stdout.
* 2) Creates a path-*.svg each * time it hits a longest path.
* 3) Creates a solution-*.svg for each solution.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#define WIDTH 8u
#define HEIGHT 8u
class A {
public static boolean isPrime(int i) {
if (i < 2) return false;
for (int j = 2; j <= (int) Math.sqrt(i); ++j) {
if (i % j == 0) return false;
}
return true;
}
# https://www.hackerrank.com/challenges/candies
import sys
N = int(sys.stdin.readline())
ratings = [ int(sys.stdin.readline()) for n in range(N) ]
candies = [1]*N
for i in range(1, N):
if ratings[i] > ratings[i - 1]:
candies[i] = candies[i - 1] + 1
@maksverver
maksverver / D.cc
Created January 24, 2016 18:52
Facebook Hacker Cup 2016 Round 2 - Problem D: Costly Labels
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i, a, b) for(int i = int(a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(c) (int((c).size()))