aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-030/pokgopun/README1
-rw-r--r--challenge-030/pokgopun/go/ch-1.go22
-rw-r--r--challenge-030/pokgopun/go/ch-2.go23
3 files changed, 46 insertions, 0 deletions
diff --git a/challenge-030/pokgopun/README b/challenge-030/pokgopun/README
new file mode 100644
index 0000000000..33dfd303a4
--- /dev/null
+++ b/challenge-030/pokgopun/README
@@ -0,0 +1 @@
+Solution by PokGoPun
diff --git a/challenge-030/pokgopun/go/ch-1.go b/challenge-030/pokgopun/go/ch-1.go
new file mode 100644
index 0000000000..eb0201bc1d
--- /dev/null
+++ b/challenge-030/pokgopun/go/ch-1.go
@@ -0,0 +1,22 @@
+package main
+
+// Write a script to list dates for Sunday Christmas between 2019 and 2100. For example, 25 Dec 2022 is Sunday.
+import (
+ "fmt"
+ "time"
+)
+
+const debug = 0
+
+func main() {
+ startY := 2019
+ endY := 2100
+ for y := startY; y <= endY; y++ {
+ t := time.Date(y, 12, 25, 0, 0, 0, 0, time.UTC)
+ if t.Weekday() == time.Sunday {
+ fmt.Println(t.Format("2 Jan 2006 is Monday"))
+ } else if debug == 1 {
+ fmt.Println("...skipping", t.Format("2 Jan 2006 is Monday"))
+ }
+ }
+}
diff --git a/challenge-030/pokgopun/go/ch-2.go b/challenge-030/pokgopun/go/ch-2.go
new file mode 100644
index 0000000000..8d5f287ccd
--- /dev/null
+++ b/challenge-030/pokgopun/go/ch-2.go
@@ -0,0 +1,23 @@
+/*
+Write a script to print all possible series of 3 positive numbers, where in each series at least one of the number is even and sum of the three numbers is always 12. For example, 3,4,5.
+*/
+// (odd + odd) + odd => (even) + odd => odd, thus three numbers that sum to an even number cannot be all odd, no need to care about the even number
+// Assume numbers in series can be duplicated and unordered as none of there contraints are mentioned
+package main
+
+import (
+ "bufio"
+ "fmt"
+ "os"
+)
+
+func main() {
+ w := bufio.NewWriter(os.Stdout)
+ n := 12
+ for i := 0; i <= n; i++ {
+ for j := 0; j <= 12-i; j++ {
+ fmt.Fprintf(w, "%d, %d, %d\n", i, j, 12-i-j)
+ }
+ }
+ w.Flush()
+}