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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1,012 changes: 1,012 additions & 0 deletions logic-exercises/d15-anagrama/anagrama/package-lock.json

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions logic-exercises/d15-anagrama/anagrama/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"scripts": {
"index": "clear && tsnd --transpile-only --ignore-watch node_modules ./src/index.ts"
},
"devDependencies": {
"@types/node": "^15.3.0",
"ts-node-dev": "^1.1.6",
"typescript": "^4.2.4"
}
}
32 changes: 32 additions & 0 deletions logic-exercises/d15-anagrama/anagrama/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const testAnagramString = (s: string, t: string) => {
let stringS: any = {}

if(s.length !== t.length){
return false;
}

for(let char of s){
stringS[char] = (stringS[char] || 0) + 1;
}

for(let char of t){
if (!stringS[char]){
stringS--;
return false;
}

}

return true
}


console.log(testAnagramString('anagrama', 'nagarama'))

//OU

function testAnagramStringSimplificada(s: string, t: string) {
return s.split("").sort().join("") === t.split("").sort().join("")
}

console.log(testAnagramStringSimplificada('anagrama', 'nagarama'))
14 changes: 14 additions & 0 deletions logic-exercises/d15-anagrama/anagrama/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
}
}