Skip to content

Instantly share code, notes, and snippets.

View kokx's full-sized avatar

Pieter Kokx kokx

  • GEWIS
  • Netherlands
View GitHub Profile
@kokx
kokx / keybase.md
Created May 17, 2018 10:32
keybase.md

Keybase proof

I hereby claim:

  • I am kokx on github.
  • I am kokx (https://keybase.io/kokx) on keybase.
  • I have a public key ASBqJFX5rR_o2KNCUAFDcepTyziSljiI0Zzllu3hqwvwQQo

To claim this, I am signing this object:

@kokx
kokx / .travis.yml
Last active April 29, 2017 23:51
LaTeX on Travis for Education
install:
- ./texlive-install.sh
- export PATH="$PATH:$HOME/texlive/bin/x86_64-linux"
- tlmgr install wrapfig
script:
- pdflatex file.tex
@kokx
kokx / levenshtein.cpp
Created October 1, 2014 19:57
levenshtein.cpp
#define replace_cost(s,t) 1
#define insert_cost(s) 1
#define delete_cost(s) 1
// String mag ook een vector van iets zijn wat te comparen is
int levenshtein(string s, string t)
{
int sl = s.length();
int tl = t.length();
// init DP table
@kokx
kokx / Facebook Hackercup Solutions.md
Last active December 11, 2015 21:09
Solutions to Facebook Hackercup. Feel free to fork and make improvements! I didn't really take much time to write this, so help on clarifying the text is very much appreciated!

Disclaimer: I have no idea if this are indeed the correct answers. I just solved the exercises like this. I think that they are right though.

I have added my own code to this gist. It is ugly as hell, just like you can expect from code created in a contest like this.

Beautiful Strings

Difficulty: easy

It is simple to see that a greedy solution is good enough.

<?php
namespace User\Form;
use Zend\Form\Form,
Zend\Form\Element;
class Register extends Form
{
<?php
return array(
'routes' => array(
'user-register' => array(
'type' => 'Literal',
'route' => '/user/register',
'defaults' => array(
'controller' => 'User\Index',
'action' => 'register'
)
<?php
/**
* @pre count($a) == count($b)
* @post \forall ( $x \in \N : \ret[$x] == $a[$x] + $b[$x] )
*/
function add(array $a, array $b)
{
$c = array();
for ($i = 0; $i < count($a); $i++) {
<?php
// you simply call this with Singleton::getInstance()
class Singleton
{
private static $instance;
private function __construct()
{}
\item $n^{-1}$
\item $16 = 2^{\log 16}$
\item $\log \sqrt{n}$
\item $\log n^3$
\item $n$
\item $n + \log n^4$
\item $n^{\log 4} \ (= n^2)$
\item $n^2 \log n$
\item $4^{\log n}$
#!/usr/bin/php
<?php
function genChildName($min = 4, $max = 11, $consonants = 'aoiue', $noncons = 'qwrtpsdfghjklzxcvwnmy')
{
$len = rand($min, $max);
$name = '';
for ($i = 0; $i < $len; $i++) {