From c548154f6ebd3058a662bd8ec3c1cf38d4e34513 Mon Sep 17 00:00:00 2001 From: "masoudsadeghi.dev" Date: Fri, 11 Aug 2023 20:06:29 -0700 Subject: [PATCH 1/2] add mayday solution in go programming language --- strings/tfcctf2023-MAYDAY/solve-masoud.go | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 strings/tfcctf2023-MAYDAY/solve-masoud.go diff --git a/strings/tfcctf2023-MAYDAY/solve-masoud.go b/strings/tfcctf2023-MAYDAY/solve-masoud.go new file mode 100644 index 0000000..a0dda3b --- /dev/null +++ b/strings/tfcctf2023-MAYDAY/solve-masoud.go @@ -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) +} From 23bbbe39806f32022cdcac2c02f08f5e5d6bb63c Mon Sep 17 00:00:00 2001 From: "masoudsadeghi.dev" Date: Sat, 12 Aug 2023 16:02:36 -0700 Subject: [PATCH 2/2] added solve-masoud.go file, solution for two-digits-no-zero question --- .../solve-masoud.go | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 math/111-999-two-digits-no-zero/solve-masoud.go diff --git a/math/111-999-two-digits-no-zero/solve-masoud.go b/math/111-999-two-digits-no-zero/solve-masoud.go new file mode 100644 index 0000000..d319a50 --- /dev/null +++ b/math/111-999-two-digits-no-zero/solve-masoud.go @@ -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) +}