Skip to content

Instantly share code, notes, and snippets.

View iamcrypticcoder's full-sized avatar

Mahbubur Rahman iamcrypticcoder

View GitHub Profile
import Foundation
class CommandExecutor {
var nextCommands = [Command]()
var executedCommands = [Command]()
init() {
}
import Foundation
var book1: Book = Book()
var executor: CommandExecutor = CommandExecutor()
executor.addCommand(BuyCommand(book1))
executor.runCommand()
print("Current owner: \(book1.currentOwner!)")
executor.addCommand(GiftFriendCommand(book1, "Mahbub"))
executor.addCommand(SellCommand(book1))
public class SupplierDemo {
static class Car {
String brand;
int engineCC;
int wheelCount;
int price;
public Car(String brand, int engineCC, int wheelCount, int price) {
this.brand = brand;
public class PredicateDemo {
static class Person {
String name;
int age;
String gender;
public Person(String name, int age, String gender) {
this.name = name;
this.age = age;
public class ConsumerDemo {
static class Point {
Double x, y;
public Point(Double x, Double y) {
this.x = x;
this.y = y;
}
}
public class FunctionDemo {
static Function<String, String> shortName = (s) -> {
if (null == s || s.length() == 0) return "Unknown";
String[] splits = s.split(" ");
String ret = splits[0];
if (splits.length >= 2) ret += " " + splits[1].substring(0, 1) + ".";
return ret;
};

Keybase proof

I hereby claim:

  • I am iamcrypticcoder on github.
  • I am iamcrypticcoder (https://keybase.io/iamcrypticcoder) on keybase.
  • I have a public key ASCEE1AUMNw-7QclSaZp30EoHUelXP_QpgAdXa7vayfthQo

To claim this, I am signing this object:

@iamcrypticcoder
iamcrypticcoder / sigma_calculation_naive.cpp
Created February 28, 2019 05:57
Sigma calculation in naive approach
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
#define READ(x) freopen(x, "r", stdin)
#define WRITE(x) freopen(x, "w", stdout)
#define PB push_back
@iamcrypticcoder
iamcrypticcoder / sigma_calculation_efficient.cpp
Created February 28, 2019 06:00
Sigma calculation in efficient way
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
#define READ(x) freopen(x, "r", stdin)
#define WRITE(x) freopen(x, "w", stdout)
#define PB push_back
#include <iostream>
#include <math.h>
using namespace std;
#define FOR(i, L, U) for(int i=(int)L; i<=(int)U; i++)
#define FORD(i, U, L) for(int i=(int)U; i>=(int)L; i--)
#define READ(x) freopen(x, "r", stdin)
#define WRITE(x) freopen(x, "w", stdout)