This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const data: Array<number> = [4, 20, 9, 74, 23, 100, 1, 5, 91]; | |
| function quicksort(data: Array<number>): Array<number> { | |
| if (data.length < 2) { | |
| return data; | |
| } | |
| const pivot: number = data[Math.floor(data.length / 2)]; | |
| const min: Array<number> = data.filter(item => item < pivot); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function binarySearch(value: number, data: Array<number>): number | undefined { | |
| let low: number = 0; | |
| let high: number = data.length - 1; | |
| while (low <= high) { | |
| const mid = Math.floor((low + high) / 2); | |
| if (data[mid] === value) { | |
| return mid; | |
| } else if (data[mid] < value) { | |
| low = mid + 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { | |
| FormEvent, | |
| HTMLAttributes, | |
| HTMLInputTypeAttribute, | |
| RefObject, | |
| useRef, | |
| } from "react"; | |
| import { ZodSchema } from "zod"; | |
| type Field = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import crypto from "crypto"; | |
| export class AES128 { | |
| private iv: NodeJS.ArrayBufferView; | |
| private key: NodeJS.ArrayBufferView; | |
| constructor(key: string, iv: string) { | |
| if (key.length !== 16) { | |
| throw new Error( | |
| "Não foi possível construir o AES128 devido ao key que possui um comprimento diferente de 16." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { edenFetch } from "@elysiajs/eden"; | |
| export interface BaseResponse<T = any> { | |
| success: boolean; | |
| message?: string; | |
| data?: T; | |
| } | |
| export interface ServiceResponse<T = any> { | |
| status: number; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fib = (laps, oldNumber = 1, oldestNumber = 0) => { | |
| if (laps === 0) return oldestNumber; | |
| if (laps === 1) return oldNumber; | |
| const sum = BigInt(oldNumber) + BigInt(oldestNumber); | |
| return fib(laps - 1, sum, oldNumber); | |
| }; | |
| console.time("res"); | |
| console.log(fib(1_000_000)) | |
| console.timeEnd("res"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const factorial = (number) => { | |
| if (number <= 1) return 1; | |
| return BigInt(number) * BigInt(factorial(number - 1)); | |
| } | |
| console.time("res"); | |
| console.log(factorial(31_931)) | |
| console.timeEnd("res"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class HttpRequest { | |
| public baseUrl: string; | |
| constructor(baseUrl: string) { | |
| this.baseUrl = baseUrl; | |
| } | |
| private headerBuilder = (data: object): Headers => { | |
| return new Headers(Object.entries(data)); | |
| }; |
NewerOlder