Skip to content

Instantly share code, notes, and snippets.

View AmalJossy's full-sized avatar
🎮
Work, game, repeat

Amal Jossy AmalJossy

🎮
Work, game, repeat
View GitHub Profile
@AmalJossy
AmalJossy / relatednumbers.cpp
Last active October 10, 2020 15:59
Size of largest subset of numbers that share a digit directly OR INDIRECTLY
#include <iostream>
using namespace std;
int counters[10];
int* ref[10];
void init(){
for(int i=0;i<10;i++){
counters[i]=0;
ref[i]=&counters[i];
}
@AmalJossy
AmalJossy / getscreen.cmd
Created June 10, 2019 12:05
Get whats on my phone's broken screen :(
@echo off
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png
adb shell rm /sdcard/screen.png
mspaint "screen.png"
@AmalJossy
AmalJossy / intercodegen.c
Last active November 7, 2018 10:31
Intermediate code generator
#include <stdio.h>
#include<string.h>
#include<ctype.h>
#define MAX_SIZE 100
char expr[MAX_SIZE] = {0};
char STACK[MAX_SIZE] = {0}, POST[MAX_SIZE] = {0};
int top=-1;
int rear=-1,front=-1;
@AmalJossy
AmalJossy / firstfollow.c
Last active November 3, 2018 18:34
Program to find first and follow of non terminals in a grammer
#include<stdio.h>
#include<string.h>
/*******/
// row 1 : no of rules
// rows>1: production rules
/*******/
int p;
char NTERM[20];
char LHS[20];
char RHS[20][10];
@AmalJossy
AmalJossy / lex.c
Created October 31, 2018 10:18
Program to to simulate lexical analyse of a C program
#include<stdlib.h>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
char buff[255];
FILE *fpout;
int i;
void append(char ch){buff[i++]=ch;buff[i]='\0';}
int identify(){
char keywords[32][8] = {"auto","break","case","char","const","continue","default",
@AmalJossy
AmalJossy / eclosure.c
Created October 31, 2018 10:16
Program to find Epsilon-Closure
#include<stdio.h>
#define MAXSIZE 10
int iS,iC;
char closure[MAXSIZE],stack[MAXSIZE];
void stackPush(char arg){
if(iS==MAXSIZE){
printf("Stack overflow");
return;
}
stack[iS++]=arg;
@AmalJossy
AmalJossy / minimize.c
Last active March 9, 2024 22:53
Program to minimize a given DFA
#include <stdio.h>
/* input format
row 1: input symbols
row 2: non-final states
row 3: final states
rows>3: transition table
*/
int table[10][10];
int matrix[10][10]={0};
@AmalJossy
AmalJossy / segmentation.py
Last active October 14, 2018 18:26
character segmentation of given text image
import cv2
import numpy as np
#import image
image = cv2.imread('1.png')
# image = cv2.imread('malayalam.jpg')
# image = cv2.imread('medium.png')
#cv2.imshow('orig',image)
#cv2.waitKey(0)
#grayscale
@AmalJossy
AmalJossy / ENFA2NFA.c
Created October 11, 2018 10:01
Convert given E-NFA to NFA
#include<stdio.h>
#include<malloc.h>
/****************/
//Author: Amal Jossy
//Description: Convert given E-NFA to NFA
//input format -
//row 1 : no of transitions
//rows>1: transitions "qi input qj"
/*****************/
typedef struct trans TRANS;
@AmalJossy
AmalJossy / NFA2DFA.c
Created October 11, 2018 07:11
C program to convert NFA(no epsilon transition) to DFA
#include<stdio.h>
/****************************/
// input: row 1: Length of language
// row 2: Input symbols
// row 3: No of Transitions
// row >3: "qi input qj"
/****************************/
typedef struct trans TRANS;