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
22 changes: 22 additions & 0 deletions math/111-999-two-digits-no-zero/solve-masoud.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"fmt"
"strconv"
"strings"
)

func main() {
counter := 0
for i := 111; i < 999; i++ {
str := strconv.Itoa(i)
if !strings.Contains(str, "0") {
if (str[0] == str[1] && str[0] != str[2]) ||
(str[0] == str[2] && str[0] != str[1]) ||
(str[1] == str[2] && str[0] != str[1]) {
counter++
}
}
}
fmt.Println("result is ", counter)
}
43 changes: 43 additions & 0 deletions strings/tfcctf2023-MAYDAY/solve-masoud.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package main

import (
"fmt"
"strings"
)

// The input string containing a series of words
const INPUT = "Whiskey Hotel Four Tango Dash Alpha Romeo Three Dash Yankee Oscar Uniform Dash Sierra One November Kilo India November Golf Dash Four Bravo Zero Uniform Seven"

func main() {
answer := ""
// map for convert numbers
numbers := map[string]string{
"Zero": "0",
"One": "1",
"Tow": "2",
"Three": "3",
"Four": "4",
"Five": "5",
"Six": "6",
"Seven": "7",
"Eight": "8",
"Nine": "9",
}

// Split the string to get words
parts := strings.Split(INPUT, " ")
/*
create answer
if number is exist in map append numeric value
if not exist in map just append first character
*/
for i := 0; i < len(parts); i++ {
value, contain := numbers[parts[i]]
if contain {
answer += value
} else {
answer += string(parts[i][0])
}
}
fmt.Println(answer)
}