Skip to content

Instantly share code, notes, and snippets.

View morphdhitia's full-sized avatar

Ekky Cahyadhitia morphdhitia

View GitHub Profile
@morphdhitia
morphdhitia / Konversi.php
Last active December 28, 2016 09:12
Konversi Romawi ke Desimal & Desimal ke Romawi dalam 1 function.
<?php
/*
The easy way to Convert Decimal to Roman and Roman to Decimal;
*/
function ConvertRomawiToDecimal($input){
// Kemungkinan untuk konversi romawi ke desimal ataupun sebaliknya.
$possibility = array(
'M' => '1000',
'CM' => '900',
<?php
/*
The function for checking characters which appers once in string;
*/
function AppearsOnce($input){
if(!ctype_digit($input)){
return "Must be all numbers! ";
@morphdhitia
morphdhitia / OwnBreacrumbs.js
Created January 31, 2017 05:15
Stupid helper for creating breadcrumbs
const Breadcrumbs = function(title){
this.title = title;
this.breadLists = '';
}
Breadcrumbs.prototype.add = function(title, url){
var breadArray = [];
@morphdhitia
morphdhitia / ValidationParentesis.js
Created February 21, 2017 11:31
How to validate Parentesis in javascript
function ValidationParentesis(string){
return !string.split('').reduce(function(prev, char){
if(prev < 0) { return prev; }
if(char === '('){ return ++prev };
if(char === ')'){ return --prev};
return prev;
},0);
}
var desks = [
{ type: 'sitting' },
{ type: 'standing' },
{ type: 'sitting' },
{ type: 'sitting' },
{ type: 'standing' }
];
var deskTypes = desks.reduce(function(sum, desk) {
sum[desk.type] += 1;
@morphdhitia
morphdhitia / self-number.js
Created June 20, 2017 05:18
the easy way to show all self-number and sum it!
// Creating a function called MagicSelfNumber
var MagicSelfNumber = function(max){
//creating an array with defined index
this.arrayTemp = Array.apply(null, {length: max}).map(Number.call, Number);
this.selfNumber;
}
//this proto function is for finding all self-numbers
MagicSelfNumber.prototype.selfNumber = function(){
@morphdhitia
morphdhitia / gunmanSurvivor.js
Created June 20, 2017 05:19
How many gunmen that survive in the box
//creating a function call SurvivorGunMen
var SurvivorGunMen = function(){
this.wall = 'wall';
this.space= undefined;
this.gunman = 'Gunman';
this.room;
this.countGunmen = 0;
}
// this proto func is for creating a new room for gunmen