Skip to content

Instantly share code, notes, and snippets.

View Rex-Ferrer's full-sized avatar

Rex Ferrer Rex-Ferrer

View GitHub Profile
@Rex-Ferrer
Rex-Ferrer / brain.dart
Last active February 26, 2021 22:20
[WIP] OOP practice - Brain Modeling
class Lobe {}
class Temporal implements Lobe {}
class Frontal implements Lobe {
MemoryProcessor processor;
Object process(Effortful memory){
return processor.process(memory);
}
@Rex-Ferrer
Rex-Ferrer / closest_pair.dart
Created November 19, 2020 07:32
Closest Pair
import 'dart:math';
class ClosestPair {
// O(n^2)
static double bruteForce2D(List<Point> list) {
double closest = double.infinity;
for(var i = 0; i < list.length - 1; i++){
for(var j = i + 1; j < list.length; j++){
closest = min(closest, list[i].distanceTo(list[j]));
@Rex-Ferrer
Rex-Ferrer / matrix.dart
Created November 19, 2020 01:25
Matrix Class in Dart [WIP]
class Strassen {
m1_of(List[][] a, List[][] b) {}
m2_of() {}
m3_of() {}
m4_of() {}
m5_of() {}
@Rex-Ferrer
Rex-Ferrer / coin_row.dart
Last active October 27, 2020 19:30
Advanced Algorithms: Dynamic Programming - Coin Row Example
// Advanced Algorithms: Dynamic Programming
// GitHub: https://gist.github.com/Esgrima/4a744b79077da2e43ba00935dca89313
// DartDevPad: https://dartpad.dev/4a744b79077da2e43ba00935dca89313
import 'dart:math' as math;
class CoinRow {
// Coin-row problem: There is a row of n coins whose values are some
// positive integers c1, c2, . . . , cn, not necessarily distinct. The goal is to pick up the
@Rex-Ferrer
Rex-Ferrer / karatsuba.dart
Last active October 27, 2020 18:13
Advanced Algorithms: Dynamic Programming - Karatsuba Multiplication [WIP]
import 'dart:math' as math;
int karatsubaProductOf(int x, int y) {
print("x is $x");
print("y is $y");
int N = math.max(x.bitLength, y.bitLength);
if (N <= 10) {
return x * y;
}
@Rex-Ferrer
Rex-Ferrer / decrease_and_conquer.dart
Last active October 6, 2020 02:10
Advanced Algorithms: Variable Decrease-and-Conquer
// Advanced Algorithms: Decrease and Conquer
// https://gist.github.com/Esgrima/7d49182a728fe0a96d32c23da21919c2
// View and Run at this link:
// https://dartpad.dev/7d49182a728fe0a96d32c23da21919c2
// Utility class of Partitioning algorithms
class Partition {
static int lomuto(List list){
@Rex-Ferrer
Rex-Ferrer / russian_peasant_product.dart
Last active October 27, 2020 19:24
Advanced Algorithms: Russian Peasant Product
int getRussianPeasantProduct(int n, int m, int extra){
int next_n;
int next_m;
int next_extra;
if (n == 1){
return m + extra;
} else if (n % 2 == 0) {
next_n = n / 2 as int;
@Rex-Ferrer
Rex-Ferrer / foo_test.dart
Last active December 9, 2023 16:42
16 Tips for Widget Testing in Flutter
// https://gist.github.com/Esgrima/c0d4bff4b0d3909daf8994410cd659ce
// https://dartpad.dev/c0d4bff4b0d3909daf8994410cd659ce
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:boolean_selector/boolean_selector.dart';
// (TODO: Tip # 1) Consider making frequently used variables/values constants
const _fooConst1 = '';
const _fooConst2 = '';