aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-148/pokgopun/README1
-rw-r--r--challenge-148/pokgopun/go/ch-1.go19
-rw-r--r--challenge-148/pokgopun/go/ch-2.go7
-rw-r--r--challenge-148/pokgopun/go/vendor/github.com/divan/num2words/.travis.yml8
-rw-r--r--challenge-148/pokgopun/go/vendor/github.com/divan/num2words/LICENSE20
-rw-r--r--challenge-148/pokgopun/go/vendor/github.com/divan/num2words/README.md29
-rw-r--r--challenge-148/pokgopun/go/vendor/github.com/divan/num2words/num2words.go119
-rw-r--r--challenge-148/pokgopun/go/vendor/modules.txt5
8 files changed, 208 insertions, 0 deletions
diff --git a/challenge-148/pokgopun/README b/challenge-148/pokgopun/README
new file mode 100644
index 0000000000..33dfd303a4
--- /dev/null
+++ b/challenge-148/pokgopun/README
@@ -0,0 +1 @@
+Solution by PokGoPun
diff --git a/challenge-148/pokgopun/go/ch-1.go b/challenge-148/pokgopun/go/ch-1.go
new file mode 100644
index 0000000000..d387fd2e5b
--- /dev/null
+++ b/challenge-148/pokgopun/go/ch-1.go
@@ -0,0 +1,19 @@
+package main
+
+import (
+ "fmt"
+ "regexp"
+
+ "github.com/divan/num2words"
+)
+
+func main() {
+ eban := []int{}
+ re := regexp.MustCompile(`[eE]`)
+ for i := 1; i <= 100; i++ {
+ if !re.MatchString(num2words.Convert(i)) {
+ eban = append(eban, i)
+ }
+ }
+ fmt.Println(eban)
+}
diff --git a/challenge-148/pokgopun/go/ch-2.go b/challenge-148/pokgopun/go/ch-2.go
new file mode 100644
index 0000000000..d8fa929218
--- /dev/null
+++ b/challenge-148/pokgopun/go/ch-2.go
@@ -0,0 +1,7 @@
+package main
+
+import "fmt"
+
+func main() {
+ fmt.Println("hello")
+}
diff --git a/challenge-148/pokgopun/go/vendor/github.com/divan/num2words/.travis.yml b/challenge-148/pokgopun/go/vendor/github.com/divan/num2words/.travis.yml
new file mode 100644
index 0000000000..03ca914415
--- /dev/null
+++ b/challenge-148/pokgopun/go/vendor/github.com/divan/num2words/.travis.yml
@@ -0,0 +1,8 @@
+language: go
+go:
+ - 1.8.3
+ - 1.9
+
+
+script:
+ - go test -v .
diff --git a/challenge-148/pokgopun/go/vendor/github.com/divan/num2words/LICENSE b/challenge-148/pokgopun/go/vendor/github.com/divan/num2words/LICENSE
new file mode 100644
index 0000000000..635f49f003
--- /dev/null
+++ b/challenge-148/pokgopun/go/vendor/github.com/divan/num2words/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2013 Ivan Daniluk
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/challenge-148/pokgopun/go/vendor/github.com/divan/num2words/README.md b/challenge-148/pokgopun/go/vendor/github.com/divan/num2words/README.md
new file mode 100644
index 0000000000..8197c11925
--- /dev/null
+++ b/challenge-148/pokgopun/go/vendor/github.com/divan/num2words/README.md
@@ -0,0 +1,29 @@
+num2words
+=========
+
+[![Build Status](https://travis-ci.org/divan/num2words.svg?branch=master)](https://travis-ci.org/divan/num2words)
+[![GoDoc](https://godoc.org/github.com/divan/num2words?status.svg)](https://godoc.org/github.com/divan/num2words)
+
+num2words - Numbers to words converter in Go (Golang)
+
+## Usage
+
+First, import package num2words
+
+```import github.com/divan/num2words```
+
+Convert number
+```go
+ str := num2words.Convert(17) // outputs "seventeen"
+ ...
+ str := num2words.Convert(1024) // outputs "one thousand twenty four"
+ ...
+ str := num2words.Convert(-123) // outputs "minus one hundred twenty three"
+```
+
+Convert number with " and " between number groups:
+```go
+ str := num2words.ConvertAnd(514) // outputs "five hundred and fourteen"
+ ...
+ str := num2words.ConvertAnd(123) // outputs "one hundred and twenty three"
+```
diff --git a/challenge-148/pokgopun/go/vendor/github.com/divan/num2words/num2words.go b/challenge-148/pokgopun/go/vendor/github.com/divan/num2words/num2words.go
new file mode 100644
index 0000000000..dc86854c6b
--- /dev/null
+++ b/challenge-148/pokgopun/go/vendor/github.com/divan/num2words/num2words.go
@@ -0,0 +1,119 @@
+// Package num2words implements numbers to words converter.
+package num2words
+
+import "math"
+
+// how many digit's groups to process
+const groupsNumber int = 4
+
+var _smallNumbers = []string{
+ "zero", "one", "two", "three", "four",
+ "five", "six", "seven", "eight", "nine",
+ "ten", "eleven", "twelve", "thirteen", "fourteen",
+ "fifteen", "sixteen", "seventeen", "eighteen", "nineteen",
+}
+var _tens = []string{
+ "", "", "twenty", "thirty", "forty", "fifty",
+ "sixty", "seventy", "eighty", "ninety",
+}
+var _scaleNumbers = []string{
+ "", "thousand", "million", "billion",
+}
+
+type digitGroup int
+
+// Convert converts number into the words representation.
+func Convert(number int) string {
+ return convert(number, false)
+}
+
+// ConvertAnd converts number into the words representation
+// with " and " added between number groups.
+func ConvertAnd(number int) string {
+ return convert(number, true)
+}
+
+func convert(number int, useAnd bool) string {
+ // Zero rule
+ if number == 0 {
+ return _smallNumbers[0]
+ }
+
+ // Divide into three-digits group
+ var groups [groupsNumber]digitGroup
+ positive := math.Abs(float64(number))
+
+ // Form three-digit groups
+ for i := 0; i < groupsNumber; i++ {
+ groups[i] = digitGroup(math.Mod(positive, 1000))
+ positive /= 1000
+ }
+
+ var textGroup [groupsNumber]string
+ for i := 0; i < groupsNumber; i++ {
+ textGroup[i] = digitGroup2Text(groups[i], useAnd)
+ }
+ combined := textGroup[0]
+ and := useAnd && (groups[0] > 0 && groups[0] < 100)
+
+ for i := 1; i < groupsNumber; i++ {
+ if groups[i] != 0 {
+ prefix := textGroup[i] + " " + _scaleNumbers[i]
+
+ if len(combined) != 0 {
+ prefix += separator(and)
+ }
+
+ and = false
+
+ combined = prefix + combined
+ }
+ }
+
+ if number < 0 {
+ combined = "minus " + combined
+ }
+
+ return combined
+}
+
+func intMod(x, y int) int {
+ return int(math.Mod(float64(x), float64(y)))
+}
+
+func digitGroup2Text(group digitGroup, useAnd bool) (ret string) {
+ hundreds := group / 100
+ tensUnits := intMod(int(group), 100)
+
+ if hundreds != 0 {
+ ret += _smallNumbers[hundreds] + " hundred"
+
+ if tensUnits != 0 {
+ ret += separator(useAnd)
+ }
+ }
+
+ tens := tensUnits / 10
+ units := intMod(tensUnits, 10)
+
+ if tens >= 2 {
+ ret += _tens[tens]
+
+ if units != 0 {
+ ret += "-" + _smallNumbers[units]
+ }
+ } else if tensUnits != 0 {
+ ret += _smallNumbers[tensUnits]
+ }
+
+ return
+}
+
+// separator returns proper separator string between
+// number groups.
+func separator(useAnd bool) string {
+ if useAnd {
+ return " and "
+ }
+ return " "
+}
diff --git a/challenge-148/pokgopun/go/vendor/modules.txt b/challenge-148/pokgopun/go/vendor/modules.txt
new file mode 100644
index 0000000000..a8da285050
--- /dev/null
+++ b/challenge-148/pokgopun/go/vendor/modules.txt
@@ -0,0 +1,5 @@
+# github.com/divan/num2words v0.0.0-20170904212200-57dba452f942
+## explicit
+github.com/divan/num2words
+# github.com/smartystreets/goconvey v1.7.2
+## explicit; go 1.16