Skip to content

Instantly share code, notes, and snippets.

View mustooch's full-sized avatar

Georges mustooch

  • Beirut, lebanon
View GitHub Profile
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MEM_MAX 2024
#define PROG_MAX 16384
#define NAME_MAX 256
void getprog(char *prg, char fname[NAME_MAX]) {
FILE *fp;
#include <stdio.h>
#include <math.h>
#define ERR -1
int hua2dec(char *str) {
long int res = 0;
int len = strlen(str);
if (str[0] != 'h' || str[len-1] != 'a') return ERR;
@mustooch
mustooch / VM.c
Created May 28, 2020 14:02
basic virtual machine
#include <stdio.h>
#define STACK_MAX 256
#define PROGRAM_MAX 512
#define DEBUG 1
// define DEBUG 1 for all output, 0 for no output.
#define FINAL 1
// define FINAL 1 for final output, 0 for no output.
enum codes {
import random, sys
def safeNumInput(string):
while True:
res = input(string+"\n>>>")
if res == "q":
input("Merci d'avoir jouer avec nous! [enter pour quitter le programme]")
sys.exit()
try:
res = int(res)
################################################################################
## python battle ship program ##################################################
################################################################################
import random
class Grid:
def __init__(self, height, width):
self.height = height
self.width = width
@mustooch
mustooch / hex_clock.lua
Last active July 18, 2019 16:10
Display current time with the hex color format in the background
function hex_time()
time = os.date("*t", os.time())
return {time.hour, time.min, time.sec}
end
function hex2dec(n)
return tonumber("0x"..n)
end
function hex2love(t)
def collatz(num):
num = float(num)
# base case
if num == 1 :
print(num)
return
# even
if num%2 == 0 :