Skip to content

Instantly share code, notes, and snippets.

View me-shaon's full-sized avatar
💭
Learning...

Ahmed shamim me-shaon

💭
Learning...
View GitHub Profile
@me-shaon
me-shaon / guessing_game.php
Created September 11, 2023 17:06
This is a simple CLI app to guess a number, written as a demo for my students
#! /usr/bin/env php
<?php
// Guessing game CLI app
$options = getopt('h::', ["min::", "max::"]);
if (isset($options['h'])) {
printf("This is a guessing game application");
} else {
$min = (int) ($options['min'] ?? 1);
@me-shaon
me-shaon / longest_common_subsequence.js
Created November 11, 2023 13:34
Longest Common Subsequence (Javascript
module.exports = {
//param A : string
//param B : string
//return an integer
solve : function(A, B){
let rows = A.length, cols = B.length;
let lcs = Array.from({ length: rows + 1 }, () => Array.from({ length: cols + 1 }).fill(0));
for (let i=1;i<=rows;i++) {
for (let j=1;j<=cols;j++) {
@me-shaon
me-shaon / 0_1_knapsack.js
Created November 11, 2023 13:35
0/1 Knapsack (Javascript)
module.exports = {
//param A : array of integers
//param B : array of integers
//param C : integer
//return an integer
solve : function(A, B, C){
let n = A.length;
let maxValue = Array.from({length: C + 1}).fill(0);
for (let i=1; i<=n; i++) {