Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am csamu on github.
  • I am csamu (https://keybase.io/csamu) on keybase.
  • I have a public key whose fingerprint is 5783 1864 2571 48F5 E54D A581 C447 A54C B82E A5A0

To claim this, I am signing this object:

@csamu
csamu / README.md
Created May 2, 2012 15:20
Algodat 12.5 - Slottet

There are different houses in this task. Inside the house there are rooms with walls separating the rooms. A wall can be destroyed anywhere in the house and hence combine the 2 adjacent rooms into 1 room; like opening a door.

Which 2 adjacent rooms can be combined to create the largest room possible?

There are 4 different houses: house1.txt, house2.txt, house3.txt and house4.txt. The first line in a house file states the height of the house, the second line states the width of the house.

Compile

@csamu
csamu / 8.8.c
Created March 10, 2012 18:36
Algodat 8.8 - Pussel med vinklar
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
static const short BOARDSIZE = 5;
static const short PIECE[4][2][2] = {{{0,1},{1,1}},{{1,0},{1,1}},{{1,1},{0,1}},{{1,1},{1,0}}};
static int CHECKSUMS[1000][8]; //Har plats för 100 lösningar för varje start-pusselbit
static int CHECKSUM_COUNTER = 0;
@csamu
csamu / 8.6.c
Created March 5, 2012 13:35
Algodat 8.6 - Brickspel
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BLACK 1
#define WHITE 15
struct BRICK_MOVE {
int color;
int from;
@csamu
csamu / solitere.c
Created March 4, 2012 12:34
Algodat 8.4 - Solitaire
#include <stdlib.h>
#include <stdio.h>
int brade[11][11];
int losning[32][6]; //Uppgiften är troligen att fylla denna och skriva ut till fil
//Skapar brädet enligt figuren
void init(void){
int i,j;
for(i=0;i<=10;i++)
@csamu
csamu / uppg3.3.c
Created January 30, 2012 12:52
Algodat 3.3 - Merge
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct namntyp{
char namn[10];
struct namntyp *nasta;
}namntyp;
void laes_in(namntyp **l1,char filnamn[]){
@csamu
csamu / bitstr.c
Created January 21, 2012 19:51
Algodat 1.13 - Bitstring
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void BitStr(char *str, int k, int n){
float p2 = pow(2, n);
int b = k < n * p2; // Kollar om den ska snurra vidare (sant/falskt)
int c = (n+1)-((k % n) + 1); //Vart den är i binärtalet (n .. 1)
int and = (int)pow(2, c-1); //Vilket tal den ska AND'a (basen 2)
@csamu
csamu / tt.java
Created October 23, 2011 12:17
OOP - TruthTable
public void printTruthTable() throws AllInputsNotDefinedException {
//Sparar
List<OutputCalculator> saved = new ArrayList<OutputCalculator>(inputs);
int numinputs = numberOfInputs();
System.out.println("Truthtable, " + this.getClass().getSimpleName());
for(int row=0; row < (int)Math.pow(2, numinputs); row++){
inputs.clear();
for(int pos = numinputs; pos > 0; pos--){