Skip to content

Instantly share code, notes, and snippets.

View ahmedengu's full-sized avatar

Ahmed Aboumalwa ahmedengu

View GitHub Profile
@ahmedengu
ahmedengu / Main.java
Last active January 23, 2016 14:25
sic-two-pass-assembler
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Vector;
public class Main {
public static Vector<String> f1 = new Vector<>();
@ahmedengu
ahmedengu / Home.form
Created January 25, 2016 11:35
a expression evaluation using ScriptEngineManager ( JavaScript ) java , with a swing GUI
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
<Property name="title" type="java.lang.String" value="Discreet"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
@ahmedengu
ahmedengu / Main.java
Last active January 30, 2016 18:24
Smallest Turing Machine code :D
public class Main {
public static void main(String[] args) {
String[][] transitions = {{"qs", "1", "qs", "1", "r"},{"qs", "_", "q0", "_", "l"},{"qs", "0", "qa", "0", "r"}};
String tape = "111111100000000011", startState = "qs";
for (int headPosition = 0; !(startState.equals(("qa"))) && !(startState.equals("qr")); ) {
String[] tmpTransition = null;
for (int i = 0; i < transitions.length; i++)
if (transitions[i][1].contains("" + tape.charAt(headPosition)))
if (transitions[i][0].contains(startState))
tmpTransition = transitions[i];
#include <iostream>
using namespace std;
void selectionSort() {
int arr[] = {1,5,9,8,9,4,7,5,6,3,1,7};
int size=12;
int i, j, min;
for (i = 0; i < size-1; i++) {
min = i;
for (j = i + 1; j < size; j++)
#include <iostream>
using namespace std;
void merge(int arr[], int l, int m, int r)
{
int i, j, k;
int n1 = m - l + 1;
int n2 = r - m;
int L[n1], R[n2];
#include <iostream>
using namespace std;
void insertionSort() {
int arr[] = {1,5,9,8,9,4,7,5,6,3,1,7};
int size=12;
int i,j;
for (i = 1; i < size; i++)
{
for (j = i; j >= 1; j--)
#include <iostream>
using namespace std;
void binarysearch(int target)
{
int arr[] = {1 ,1 ,3 ,4 ,5 ,5 ,6 ,7 ,7 ,8 ,9 ,9};
int size=12;
int f,l,mid,c;
f=0,l=size-1;
while(f<=l)
#include <iostream>
using namespace std;
void linearSearch(int target){
int arr[] = {1,5,9,8,9,4,7,5,6,3,1,7};
int size=12;
for (int i = 0; i < size; i++) {
if(target == arr[i]){
cout<<endl<<"found at :"<<i;
return;
#include <iostream>
using namespace std;
// Complexity is O(r*c) r : row : column
int main() {
int j,i,r,c;
r=3;c=3;
int mat[r][c] = {{1,2,3},
{4,5,6},
{7,8,9}};
for(i=0;i<r;i++){ // r+1
@ahmedengu
ahmedengu / Main.java
Last active March 27, 2016 09:41
Solving puzzle using BFS
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Main {
public static boolean ReadFromFile = true; // do you wanna read from file
public static boolean displaced = true; // displaced or manhattan
public static int dimensions;
static int start[][], goal[][];