Skip to content

Instantly share code, notes, and snippets.

@evertheylen
evertheylen / palindrome.py
Created October 20, 2014 17:44
Inleiding programmeren, palindromen
# Author: Evert Heylen
# Date: 09.10.2014
# call the program with 'color' as an argument to have red input like in
# the Assignment file!
# call the program with 'exp' to use the experimental faster function
# The previous assignment had example output in Dutch, this one has the example output in English, so
# I've edited my helper fucntions accordingly.
import math
defaultbits = 8
def char_to_int(s):
return int(s, 36)
def int_to_char(i):
if 0 <= i <= 9:
return str(i)
package main
import (
"fmt"
)
func main() {
s := []bool{false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,
true, true, true, true, true, true, true, true, true, true, true, true, true, true, true}
# A basic function works like this:
def A_times_B_plus_C(a, b, c):
return (a*b) + c
# a, b and c are positional arguments. I define them by putting a value in the right place.
print(A_times_B_plus_C(5, 10, 6)) # == 56
# however, as functions grow large, they might have a lot of parameters, and you don't want to
Stel u voor; een simpele tabel van pagina's.
+-----+-----------------------------------------+
| nr | tekst |
+=====+=========================================+
| 1 | "pagina 1 tekst...." |
+-----+-----------------------------------------+
| 2 | "pagina 2 tekst...." |
+-----+-----------------------------------------+
| 5 | "pagina 5 tekst...." |
def searchValues(values, attr, key):
for v in values:
if v.__dict__[attr] == key:
return v
@evertheylen
evertheylen / logfile
Created January 22, 2015 21:59
Xonotic 0.8 segfaulted, playing local and just jumping around, no shooting.
Game is Xonotic using base gamedir data
gamename for server filtering: Xonotic
Xonotic Linux 21:47:07 Jan 18 2015 - release
Skeletal animation uses SSE code path
DPSOFTRAST available (SSE2 instructions detected)
Failed to init SDL joystick subsystem:
execing quake.rc
execing default.cfg
execing defaultXonotic.cfg
execing sRGB-disable.cfg
set stack {}
while 1 {
puts "{ $stack }"
set input [gets stdin]
if {$input in {+ - * /}} {
# calculate new_element (trick with parsing input as part of the command)
set new_element [eval [list tcl::mathop::$input [lindex $stack [expr {[llength $stack] - 1}]] [lindex $stack [expr {[llength $stack] - 2}]]]]
# remove previous values
@evertheylen
evertheylen / generator.py
Created March 14, 2015 23:48
Opdrachten generator
# ----[ Settings ]------------
x = 500
coca_eur = 100
xtc_eur = 650
wiet_eur = 300
startgeld = 200
@evertheylen
evertheylen / convert.py
Created May 5, 2015 23:12
Converteer oude formaat Speelveld.xml naar nieuw formaat
#!/usr/bin/python3
# HOE TE GEBRUIKEN:
# ./convert.py Speelveld.xml
# Om Bewegingen.xml om te zetten naar Acties.xml; all hail the console!
# mv Bewegingen.xml Acties.xml
# sed -i "s/SPELERNAAM/ID/g" Acties.xml
# sed -i "s/BEWEGINGEN/ACTIES/g" Acties.xml