Skip to content

Instantly share code, notes, and snippets.

View GabrielModog's full-sized avatar
🤠

Gabriel Tavares GabrielModog

🤠
View GitHub Profile
function findUniq(arr) {
const normalize = (str) =>
[...new Set(str.toLowerCase().replace("/s+/g", ""))].sort().join();
const map = arr.map(normalize).reduce((a, c) => {
a[c] = (a[c] || 0) + 1;
return a;
}, {});
const uniqueChar = Object.keys(map).find((k) => map[k] === 1);
package kata
import "strings"
func FindShortWord(s string) int {
words := strings.Split(s, " ")
lastWord := words[0]
for i := range words {
currentWord := words[i]
function sumExcelColumns(cols, column){
const result = Object.entries(cols) // output: [["A", 0], ["B", 1], ...]
if(!column || column.length <= 0) {
return new Error("Insufficient arguments. Check out to empty string or add a valid argument.")
}
if(column.length === 1) {
for(let i = 0; i < result.length; i++) {
if(result[i][0] === column) {
[1, 2] === [1, 2]
false
[1, 2, 3] == [1, 2, 3]
false
typeof [1, 2, 3]
"object"
typeof [1, 2, 3] == [1, 2, 3]
false
typeof ([1, 2, 3] == [1, 2, 3])
"boolean"
function isPalindrome(str){
if(str.length <= 1) return true
let end = str.length - 1
str = str.toLowerCase()
for(let start = 0; start < end; start++) {
if(str[start] !== str[end])
return false
package main
import "fmt"
func main() {
nums := [7]int{2, 3, 5, 3, 7, 11, 13}
m := map[int]bool{}
for i := 0; i < len(primes); i++ {
m[primes[i]] = true
function alphabetPosition(text) {
let result = []
for(let i = 0; i < text.length; i++) {
let code = text.toLowerCase().charCodeAt(i)
if(code > 96 && code < 123) result.push(code - 96)
}
return result.join(" ")
}
.model small
.data
count1 db 2
.code
main proc
move dl, count1
add dl, 48
mov ah, 2h ;code for print char
int 21h ;prints value of "dl"
endp
@GabrielModog
GabrielModog / edit-distance-wagner-fischer.js
Created January 18, 2024 08:39
Wagner–Fischer_algorithm - Edit Distance with Javascript
// https://en.wikipedia.org/wiki/Wagner–Fischer_algorithm
function editDistance(str1, str2) {
const distance = []
for(let i = 0; i <= str1.length + 1; i++) {
distance[i] = [i]
}
for(let i = 0; i <= str2.length + 1; i++) {
  • {} curly brackets or braces
  • [] square brackets or brackets
  • () round brackets or parentheses
  • <> angle brackets or chevrons
  • ; semicolon
  • : colon
  • . dot or point
  • , comma
  • "" quotation marks
  • \ backslash