Skip to content

Instantly share code, notes, and snippets.

View patrickbucher's full-sized avatar

Patrick Bucher patrickbucher

View GitHub Profile
from encodings.aliases import aliases
for a in aliases:
try:
print('ö'.encode('utf-8').decode(a), a)
except:
pass
@patrickbucher
patrickbucher / formula1.pl
Last active October 21, 2018 19:26
Will Hamilton become World Champion in the 2018 US Grand Prix?
:- use_module(library(clpfd)).
points(1, 25).
points(2, 18).
points(3, 15).
points(4, 12).
points(5, 10).
points(6, 8).
points(7, 6).
points(8, 4).
@patrickbucher
patrickbucher / badmacro.c
Created October 11, 2018 14:20
Why C Function Macros Are Bad
#include <stdio.h>
#define IS_DIGIT(C) ((C) >= '0' && (C) <= '9')
int main()
{
int i = 0, n = 0;
char *s = "a!b+c(75"; // two digits, right?
while (s[i] != '\0') {