Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Back-end/modulo2/MODULO3/complexidade-de-algoritmos/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "complexidade-algoritmos",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"linear": "clear && tsnd --transpile-only --ignore-watch node_modules ./src/linear",
"polynomial": "clear && tsnd --transpile-only --ignore-watch node_modules ./src/polynomial",
"logarithmic": "clear && tsnd --transpile-only --ignore-watch node_modules ./src/logarithmic",
"exponential": "clear && tsnd --transpile-only --ignore-watch node_modules ./src/exponential"
},
"author": "Labenu",
"license": "ISC",
"devDependencies": {
"@types/node": "^15.3.0",
"ts-node-dev": "^1.1.6",
"typescript": "^4.2.4"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { login } from "./login"

const crackPassword = (
passwordLength: number
) => {

for (let i = 0; i < 10 ** passwordLength; i++) {
console.count()

const token = login(i)
if (token) return token
}
}

crackPassword(4)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const login = (
password: number
) => password === 12345678
? "token"
: undefined
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const printUntil = (n: number) => {
for (let i = 0; i < n; i++) {
console.log({ i })
}
}

printUntil(100)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const binarySearch = (arr: number[], n: number) => {

let start = 0, end = arr.length - 1;

while (start <= end) {
console.count();

let mid = Math.floor((start + end) / 2);

if (arr[mid] === n) return n;

else if (arr[mid] < n)
start = mid + 1;
else
end = mid - 1;
}
}

const item = binarySearch(
[
1, 2, 3, 4, 5, 6, 7, 8,
],
9
)

console.log(item);
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const insertionSort = (array: number[]) => {

for (let j = 1; j < array.length; j++) {
const value = array[j];
let i = j - 1;
while (i >= 0 && array[i] >= value) {
array[i + 1] = array[i];
i--;
}
array[i + 1] = value
}
};

const numbers = [
8, 7, 6, 5, 4, 3, 2, 1,
]

insertionSort(numbers)

console.log(numbers);
14 changes: 14 additions & 0 deletions Back-end/modulo2/MODULO3/complexidade-de-algoritmos/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"sourceMap": true,
"outDir": "./build",
"rootDir": "./src",
"removeComments": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
21 changes: 21 additions & 0 deletions Back-end/modulo2/MODULO3/testes-backend/.rest
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
### CADASTRO

POST http://localhost:3003/users/signup
Content-Type: application/json

{
"name": "Alice",
"email": "alice@lbn.com",
"password": "123456",
"role":"ADMIN"
}

### LOGIN

POST http://localhost:3003/users/login
Content-Type: application/json

{
"email": "alice@lbn.com",
"password": "123456"
}
20 changes: 20 additions & 0 deletions Back-end/modulo2/MODULO3/testes-backend/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/build/src/index.js",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}