Skip to content

Instantly share code, notes, and snippets.

View ibedwi's full-sized avatar
📚
Learning

Ibe Dwi ibedwi

📚
Learning
View GitHub Profile
@ibedwi
ibedwi / printRange.py
Last active February 13, 2018 13:28
Print All number in range defined
from __future__ import print_function
# PRINT VALUE FROM S to N
s = int(raw_input())
n = int(raw_input())
print(*range(s,n+1),sep=' ')
@ibedwi
ibedwi / matrixInverse.m
Created February 14, 2018 13:07
A singular or ill-conditioned matrix doesn't have inverse. But we can approximate its inverse using SVD.
% m is the matrix
% to check if a matrix has inverse or not, use det().
if det(m)~=0
% The matrix has inverse
minv = inv(m);
else
% The matrix doesn't has inverse
% Approximate the inverse using SVD
[U,S,V] = svd(m);
static int productOfSubsetSums(int arr[], int n)
{
int ans = 1;
for (int i = 0; i < n; ++i )
ans = ans * (arr[i] + 1);
return ans-1;
}
@ibedwi
ibedwi / subsetPython.py
Created February 18, 2018 12:33
Find all possible subset in set a
# Example :
# a = [1,2,3]
# x = subset(a) * x=> [[], [3], [2], [2, 3], [1], [1, 3], [1, 2], [1, 2, 3]]
# x.sort() * x => [[], [1], [1, 2], [1, 2, 3], [1, 3], [2], [2, 3], [3]]
def subset(a):
if a == []:
return [[]]
i = subset(a[1:])
% Get list of all JPG files in this directory
% DIR returns as a structure array. You will need to use () and . to get
% the file names.
imagefiles = dir('*.jpg');
nfiles = length(imagefiles); % Number of files found
for ii=1:nfiles
currentfilename = imagefiles(ii).name;
currentimage = imread(currentfilename);
images{ii} = currentimage;
@ibedwi
ibedwi / kelompokkanKelasData.m
Created February 28, 2018 06:55
Code matlab untuk mencari data dengan kelas tertentu dari kumpulan data.
% Misal kita memiliki matriks data dengan 3 atribut dan kelas dari data
% Misal nama matriks data adalah 'data_latih'
% matriks data akan berbentuk seperti ini :
% Atribut1 | Atribut2 | Atribut 3| Kelas |
% a1 | a2 | a3 | 0 |
% b1 | b2 | b3 | 0 |
% c1 | c2 | c3 | 0 |
% d1 | d2 | d3 | 1 |
% e1 | e2 | e3 | 1 |
% f1 | f2 | f3 | 2 |
@ibedwi
ibedwi / histogramAlgorithm
Created March 1, 2018 02:22
Algorithm for making histogram.
histogram(pic) := | for bright in 0..255
| pixels_at_level_bright = 0
| for x in 0 .. cols(pic) - 0
| for y in 0 .. rows(pic) - 1
| | level = pic(y,x)
| | pixels_at_level(level) = pixels_at_level(level) + 1
| pixels_at_level
@ibedwi
ibedwi / pythonRoundToMultipleOfNumber.py
Created March 8, 2018 02:10
Round some number into its multiple of number, example round 47 to multiple of 5 will produce 50.
def myround(x, base=5):
return int(base * round(float(x)/base))
@ibedwi
ibedwi / index.html
Last active March 15, 2018 18:08
Tribute Page - Free Code Camp Project
<body>
<div class="container">
<div class="well">
<h1 class="text-center"> John Lasseter</h1>
<h3 class="text-center"> The Man behind Pixar </h2>
<div class="text-center">
<img src="https://upload.wikimedia.org/wikipedia/commons/1/17/John_Lasseter_2_cropped_2009.jpg" />
</div>
<!-- content goes here -->
<div>
@ibedwi
ibedwi / noiseGaussian.m
Last active March 12, 2018 08:28
Example of image-noise using MATLAB library.
% Read Image
img = imread('....');
% Create Noise Image
noiseGaussianImage = imnoise(img,'gaussian');