diff options
| author | Ryan Thompson <i@ry.ca> | 2022-05-28 17:43:29 -0600 |
|---|---|---|
| committer | Ryan Thompson <i@ry.ca> | 2022-05-28 17:43:29 -0600 |
| commit | bb0d10f534cdf08608a396cf10c5a443b7c5a89f (patch) | |
| tree | db1786616aedb06d07cc1c737999eba58b8d93de | |
| parent | c380cb7208d70aef788ea6b9272aba8face3482a (diff) | |
| parent | 172638a357ff0fefa265d6e694b654fd65c05c7d (diff) | |
| download | perlweeklychallenge-club-bb0d10f534cdf08608a396cf10c5a443b7c5a89f.tar.gz perlweeklychallenge-club-bb0d10f534cdf08608a396cf10c5a443b7c5a89f.tar.bz2 perlweeklychallenge-club-bb0d10f534cdf08608a396cf10c5a443b7c5a89f.zip | |
Merge remote-tracking branch 'upstream/master'
118 files changed, 5036 insertions, 2367 deletions
diff --git a/challenge-002/pokgopun/README b/challenge-002/pokgopun/README new file mode 100644 index 0000000000..33dfd303a4 --- /dev/null +++ b/challenge-002/pokgopun/README @@ -0,0 +1 @@ +Solution by PokGoPun diff --git a/challenge-002/pokgopun/go/ch-1.go b/challenge-002/pokgopun/go/ch-1.go new file mode 100644 index 0000000000..080fb3cec9 --- /dev/null +++ b/challenge-002/pokgopun/go/ch-1.go @@ -0,0 +1,36 @@ +// Write a script or one-liner to remove leading zeros from positive numbers. +// Assume number can be float and zero +package main + +import ( + "bufio" + "fmt" + "log" + "os" + "strconv" + "strings" +) + +func main() { + if len(os.Args) > 1 { + w := bufio.NewWriter(os.Stdout) + var ( + f float64 + err error + ) + for _, v := range os.Args[1:] { + //fmt.Println(strings.TrimLeft(v, "0")) + f, err = strconv.ParseFloat(v, 64) + if err != nil || f < 0 { + log.Fatal("Not a positive number") + } + if f != 0 { + v = strings.TrimLeft(v, "0") + } + w.WriteString(v + "\n") + } + w.Flush() + } else { + fmt.Println("Enter number to have its leading zeros removed") + } +} diff --git a/challenge-002/pokgopun/go/ch-2.go b/challenge-002/pokgopun/go/ch-2.go new file mode 100644 index 0000000000..cc68633dda --- /dev/null +++ b/challenge-002/pokgopun/go/ch-2.go @@ -0,0 +1,50 @@ +// Write a script that can convert integers to and from a base35 representation, using the characters 0-9 and A-Y. +package main + +import ( + "errors" + "fmt" + "log" + "math/big" |
