Skip to content

Instantly share code, notes, and snippets.

// Omitting headers
using namespace std;
void MatrixMultiply(
const vector<vector<uint64_t>>& source_mat1,
const vector<vector<uint64_t>>& source_mat2,
int N,
vector<vector<uint64_t>>* dest_mat) {
for (int i = 0; i < N; ++i) {
@agam
agam / gist:9263277
Last active August 29, 2015 13:56
Permuting vectors ...
using namespace std;
static int op_counter = 0;
void Move(vector<int>* state,
int pos, int zero_pos) {
++op_counter;
assert(state->at(zero_pos) == 0);
assert(state->at(pos) != 0);
cout << "Moved '" << state->at(pos) << "' from "
@agam
agam / gist:a832613064f958641330
Created July 23, 2014 01:16
Simple game of life
(defpackage :game-of-life
(:use :cl))
(in-package :game-of-life)
(defparameter *board-size* 10)
(defparameter *game-board* nil)
(defparameter *space* #\ )
(defparameter *life* #\#)
@agam
agam / gist:527c5fa85b316c84e9ba
Created July 23, 2014 18:17
Utilities for game of life
;;; Useful helpers to add stuff to the board. Describe a pattern as a list.
(defun add-life (x y)
(setf (aref *game-board* y x) 1))
(defun draw-pattern (x y pattern)
"Assuming 'pattern' is specified as a row-major set of 1s and 0s, replicates that on the board"
(mapindex #'(lambda (row-num row)
(mapindex #'(lambda (col-num entry)
(let ((x-eff (+ x col-num))
package main
import (
"fmt"
"time"
)
const (
NameCmd int = iota
PingCmd int = iota
package main
import (
"fmt"
"time"
)
const (
NameCmd int = iota
PingCmd int = iota
package main
import "fmt"
type Bignum struct {
digits []*Digit
add chan<- bool
stable chan bool
}
package main
import (
"bufio"
"flag"
"fmt"
"log"
"math"
"os"
)
package main
import "fmt"
type Node struct {
val uint8
next *Node
visited bool
cycle int
}
@agam
agam / sticks.go
Last active August 29, 2015 14:11
package main
import "fmt"
import "math"
type Stick struct {
id int
x1, y1, x2, y2 float64
}