Skip to content

Instantly share code, notes, and snippets.

View vvgomes's full-sized avatar
πŸ¦–

Vinicius Vieira Gomes vvgomes

πŸ¦–
View GitHub Profile
;; The goal of this program is to draw a pyramid in the terminal with a given height.
;;
;; Examples:
;;
;; ↓ height = 1
;;
;; βˆ†
;;
;; ↓ height = 2
;;
/*
A toy implementation of the Resequencer pattern from Enterprise Integration Patterns.
https://www.enterpriseintegrationpatterns.com/patterns/messaging/Resequencer.html
*/
const createResequencer = (destination) => {
const buffer = {};
let next = 1;
/*
The goal of this exercise is to render an org chart
in your terminal output based on a list of manager-
employee relationships.
Given the following relationships:
[
{ managerId: 1, employeeId: 2 },
(function sayHello(count = 50) {
if (count === 0) return;
console.log("hello world");
sayHello(count - 1);
})();
const ROMAN_VALUES = {
I: 1,
V: 5,
X: 10,
L: 50,
C: 100,
D: 500,
M: 1000
};
@vvgomes
vvgomes / wordle.js
Created February 25, 2022 16:08
Wordle
const words = require("./words.json");
const readline = require("readline");
const EVALUATION = {
GOOD: "\x1b[32mβ– \x1b[0m",
CLOSE: "\x1b[33mβ– \x1b[0m",
BAD: "\x1b[31mβ– \x1b[0m"
};
const evaluateChar = (wordChars) =>
/*
Monte Carlo Simulation for 🎲 🎲
Example output for 1,000,000 simulations
2: ⬜⬜⬜
3: ⬜⬜⬜⬜⬜
4: ⬜⬜⬜⬜⬜⬜⬜
5: ⬜⬜⬜⬜⬜⬜⬜⬜⬜
6: ⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
// definitions
const toLines = logs => logs.split("\n");
const notEmpty = line => line.trim();
const toParts = line => line.split(" ");
const toLogEntry = parts => ({
path: parts[parts.length - 2],
status: parseInt(parts[parts.length - 1])
});
@vvgomes
vvgomes / pyramid.js
Last active February 25, 2022 15:52
/*
height = 6
.....βˆ†
....βˆ†βˆ†βˆ†
...βˆ†βˆ†βˆ†βˆ†βˆ†
..βˆ†βˆ†βˆ†βˆ†βˆ†βˆ†βˆ†
.βˆ†βˆ†βˆ†βˆ†βˆ†βˆ†βˆ†βˆ†βˆ†
βˆ†βˆ†βˆ†βˆ†βˆ†βˆ†βˆ†βˆ†βˆ†βˆ†βˆ†
/*
[1] => 1
[1, 2]
[4, 5] => 1, 2, 5, 4
[1, 2, 3]
[4, 5, 6]
[7, 8, 9] => 1, 2, 3, 6, 9, 8, 7, 4, 5