Skip to content

Instantly share code, notes, and snippets.

@deveah
deveah / blink.s
Created January 13, 2018 22:51
Blink
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <stdio.h>
pid_t children[10];
int n_children = 0;
int main(int argc, char **argv)
@deveah
deveah / Duel.java
Created August 26, 2015 06:44
Three duelists' problem.
import java.util.ArrayList;
public class Duel {
private static ArrayList<Duelist> duelists;
private static int nDuels = 10000;
/*
* main(): entry point of application.
@deveah
deveah / trei.c
Created March 11, 2014 18:37
sda 3
/* problema 3 - liste */
/* gcc trei.c -o trei -Wall -Wextra -ansi -g3 */
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
struct categorie
{
@deveah
deveah / doi.c
Created March 11, 2014 18:36
sda 2
/* problema 2 - liste */
/* gcc doi.c -o doi -Wall -Wextra -ansi -g3 */
#include <stdio.h>
#include <stdlib.h>
struct obiect
{
int data;
@deveah
deveah / unu.c
Created March 11, 2014 18:36
sda 1
/* problema 1 - liste */
/* gcc unu.c -o unu -Wall -Wextra -ansi -g3 */
#include <stdio.h>
#include <stdlib.h>
#define DIM 3
int main( int argc, char **argv )
@deveah
deveah / hashtable2.c
Created February 23, 2014 20:22
Another hash table implementation using an array; it also deals with potential hash collisions
/*
* hashtable.c
* A straightforward, and apparently memory safe, hash table implementation;
* it seems to work even with as low as two buckets!
*
* This code is Public Domain.
*
* TODO:
* - use unsigned int for sizes
@deveah
deveah / hashtable.c
Created February 21, 2014 17:12
(wip) hash table implementation
/* TODO:
* how to handle collisions?
* how probable are collisions for relatively small tables?
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
local Entity = {}
Entity.__index = Entity
function Entity.new( name )
assert( type( name ) == "string" )
local e = {}
setmetatable( e, Entity )
#include <stdio.h>
typedef struct
{
char *name;
int damage, accuracy;
int ammo;
} weapon_t;