Skip to content

Instantly share code, notes, and snippets.

@danielgavrilov
danielgavrilov / whack.c
Last active April 25, 2021 11:44
[Theory I] Problem 5: Whack-A-Mole (C version)
#include <stdio.h>
#include <stdlib.h>
#define WIDTH 4
#define HEIGHT 4
#define LENGTH 16 // WIDTH * HEIGHT
#define MAX_HITS 11 // increase this to use your laptop as a stove
// -----------------------------------------------------------------------------
// A board is represented as an integer. I'm choosing integers simply because
@danielgavrilov
danielgavrilov / whack.py
Created November 5, 2014 02:56
[Theory I] Problem 5: Whack-A-Mole (Python version)
width = 4
height = 4
length = width * height
def at(board, pos):
"""Return 1 if there is a mole at the specified position, otherwise return 0."""
return (board >> pos-1) & 1
def toggle(board, pos):
"""Hide the mole if there is one at the given position, otherwise pop it up. Return the resulting board."""
@danielgavrilov
danielgavrilov / change_moodle_option.js
Last active January 9, 2016 21:26
Enables all options again on Moodle form.
// Go to the noodle selection page, open the web console in your broser and execute:
$(".tableform").find("input").prop("disabled", "").end().append("<input type='submit' value='Change group'>")
// If using Chrome, you can copy the line above into the address bar, add "javascript:" before it and hit Enter.
<html>
<head>
<title>Test</title>
<style>
body {
display: flex;
margin: 0;
padding: 0;
}
EMPTY = " "
RIGHT = "→"
LEFT = "←"
class color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'

Keybase proof

I hereby claim:

  • I am danielgavrilov on github.
  • I am gavrilov (https://keybase.io/gavrilov) on keybase.
  • I have a public key ASAfcXpWqTToARDoERqg3Fq676VoJ4hE_nRVvaMq6HqILwo

To claim this, I am signing this object:

@danielgavrilov
danielgavrilov / .block
Created March 4, 2017 17:29
Pan & Zoom SVG + HTML in sync
license: mit
@danielgavrilov
danielgavrilov / .block
Last active April 8, 2017 16:24
Solar Path
license: gpl-3.0
height: 960
scrolling: