Skip to content

Instantly share code, notes, and snippets.

View lucasmonstrox's full-sized avatar
💻
eat(); code(); sleep(); repeat();

Lucas Monstro lucasmonstrox

💻
eat(); code(); sleep(); repeat();
View GitHub Profile
@lucasmonstrox
lucasmonstrox / app.ts
Created January 11, 2024 16:38
app.ts
import { StatusCodes } from 'http-status-codes';
const { id } = req.params;
const bookIndex = books.findIndex((book) => book.id === parseInt(id));
const bookNotFound = bookIndex === -1;
if (bookNotFound) {
res.status(StatusCodes.NOT_FOUND).send();
return;
}
@lucasmonstrox
lucasmonstrox / collatz.js
Last active August 18, 2023 09:16
collatz fastest way
const longestCollatzSequence = limit => {
var numberWithHighestSequence = 3;
var highestSequenceIndex = 8;
/**
* "Uint32Array" automatically fill with "zeros" - avoid copyWithin/loop/map to set array with zero values
*
* Save between 20~25 ms
*/
var arrayOfSequences = new Int32Array(limit);
arrayOfSequences[1] = 1;