Skip to content

Instantly share code, notes, and snippets.

View mfrazi's full-sized avatar
😼
...

Fahrul Razi mfrazi

😼
...
View GitHub Profile
@mfrazi
mfrazi / gcd.c
Last active September 23, 2015 08:55
Find GCD (Greatest Common Divisor) of two integer
// Source : http://www.math.wustl.edu/~victor/mfmm/compaa/gcd.c
/* Standard C Function: Greatest Common Divisor */
int
gcd ( int a, int b )
{
int c;
while ( a != 0 ) {
c = a; a = b%a; b = c;
}
@mfrazi
mfrazi / .vimrc
Created September 23, 2015 03:50
vim configuration
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin('~/.vim/bundle/Vundle.vim')
import socket, select, sys, os
if __name__ == "__main__":
# list to keep track of socket descriptors
CONNECTION_LIST = []
# list to keep clint id
CLIENT_ID = {}
total_client = 0
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#define garis printf("---------------------------------------------------------\n")
#define garis2 printf("|=======================================================|\n")
struct hasil_jarak{
int index;
double jaraknya;
};
@mfrazi
mfrazi / DEL.py
Last active December 2, 2015 12:54
import os
def DEL(path)
os.remove(path)
# manggil fungsi DEL, cara ngeceknya
DEL("/ini/yang/dihapus.txt")
# Kalau yang di atas itu cuma buat ngapus file, gak bisa folder.
# Jadi nanti di dalam fungsi DEL itu bisa ngapus buat file sama folder.
@mfrazi
mfrazi / K-Means.c
Last active December 16, 2015 01:09
V 0.1
#include <stdio.h>
#include <math.h>
const int data_total=6;
const int max_data=3;
/*double data_training[data_total][max_data]={
{1,1,0,0},
{0,0,0,1},
{1,0,0,0},
{0,0,1,1}
#include <stdio.h>
#include <string.h>
int main(){
char data[100];
scanf("%s", data);
int Q=0, W=0, E=0, i, awal=0;
for(i=0; i<strlen(data); i++){
//printf("%c %d %d %d %d\n", data[i], Q, W, E, awal);
if(data[i]=='R'){
#include <stdio.h>
// Cara 1 (Slow) (TLE)
void hitung1(int hari, int berat, int maks_hari, unsigned int *total){
//printf("%d %d %d\n", hari, maks_hari, *total);
if(hari>maks_hari)
return;
if(berat==1)
*total = *total + 1;
BEAUTIFUL_VIEW = 1;
PC_1 = [ 57, 49, 41, 33, 25, 17, 9,
1, 58, 50, 42, 34, 26, 18,
10, 2, 59, 51, 43, 35, 27,
19, 11, 3, 60, 52, 44, 36,
63, 55, 47, 39, 31, 23, 15,
7, 62, 54, 46, 38, 30, 22,
14, 6, 61, 53, 45, 37, 29,
21, 13, 5, 28, 20, 12, 4 ];
@mfrazi
mfrazi / ex_tree.cpp
Created May 4, 2016 03:58
Expression Tree - Infix to Postfix
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct node {
int data;
struct node *left,
*right,
*parent;
}node_t;