Skip to content

Instantly share code, notes, and snippets.

View shahril96's full-sized avatar
🐢

Mohd Shahril shahril96

🐢
View GitHub Profile
@shahril96
shahril96 / knapsack_problem.c
Created June 27, 2015 20:54
0-1 Knapsack problem solved using bottom-up fashion (tabulated dynamic programming)
#include <stdio.h>
#include <string.h>
#define max(X,Y) ((X) > (Y)) ? (X) : (Y)
typedef struct item
{
int value;
int weight;
} Item;
@shahril96
shahril96 / lcs.py
Last active October 2, 2015 16:48
My first attempt toward Python language by implementing Longest Common Sub-sequence algorithm
# recursive method
def lcs(a, b):
if(len(a) <= 0 or len(b) <= 0):
return 0
elif(a[-1] == b[-1]):
return lcs(a[:-1], b[:-1]) + 1
@shahril96
shahril96 / secret.c
Last active October 4, 2015 07:43
Secret Code generator programming task (Universiti Malaysia Pahang)
#include <stdio.h>
int main()
{
char D[2], M[2], Y[4], name[100]; // char string
printf("Please enter your birthdate (DDMMYYYY): ");
scanf("%2s%2s%4s", D, M, Y);
printf("Please enter your name : ");
@shahril96
shahril96 / sumOfPower.java
Last active October 17, 2015 18:46
Sum of Power (ACM ICPC Al-Khawarizmi 2011) O(1) solution
import java.math.BigInteger;
import java.util.Scanner;
public class i
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int T, N, K;
@shahril96
shahril96 / heun.cpp
Created October 23, 2015 15:50
Heun's method for computing ordinary differential equation
#include <iostream>
using namespace std;
// cara nk buat function biasa
// return = output calculation tu
double f(double x, double y)
{
return 2 * x * y;
}
@shahril96
shahril96 / dns.bat
Last active October 31, 2015 00:40
Google DNS automation tool for Windows's network adapter
@echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
@shahril96
shahril96 / lafarge_keygenme.c
Last active November 2, 2015 13:52
LaFarge's crackme #2 solution in C
#include <stdio.h>
/*
crackme link : http://crackmes.de/users/lafarge/lafarges_crackme_2/
*/
void xor_data(char *src, int nsrc, char *byte)
{
for(int i = 0; nsrc-- > 0; i++)
{
@shahril96
shahril96 / level2.c
Created November 2, 2015 13:53
borismilner's 4N006135 level-2.exe keygenme solution
#include <stdio.h>
#include <string.h>
int main()
{
char key[40] = {0};
memset(key, 'O', 32);
int i = 0;
unsigned id;
@shahril96
shahril96 / php_mswiki_getsummary.php
Last active December 21, 2015 12:29
php skrip function untuk dapatkan ringkasan tajuk daripada wikipedia bahasa melayu..
<?php
// simple usage..
echo get_wiki_summary_ms('php');
/**
* Error Code :-
* 3 - search x dijumpai..
* 4 - php gagal nk dptkan content dari wikipedia page..
*/
@shahril96
shahril96 / tahukah_anda.php
Last active December 21, 2015 13:49
skrip ringkas php untuk dptkan text 'Tahukah anda' daripada website wikipedia bahasa melayu
<?php
echo tahukah_anda();
function tahukah_anda(){
$rd = rand(1000,7000);
if($rd >= 1000 && $rd <= 2000){
$year = '/Arkib/2008';
}elseif($rd >= 2000 && $rd <= 3000){
$year = '/Arkib/2009';