aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-134/ealvar3z/go/ch-2.go41
-rw-r--r--challenge-134/ealvar3z/python/ch-1.py7
2 files changed, 48 insertions, 0 deletions
diff --git a/challenge-134/ealvar3z/go/ch-2.go b/challenge-134/ealvar3z/go/ch-2.go
new file mode 100644
index 0000000000..d04a1b29a6
--- /dev/null
+++ b/challenge-134/ealvar3z/go/ch-2.go
@@ -0,0 +1,41 @@
+package main
+
+import (
+ "fmt"
+ "log"
+ "sort"
+
+ "github.com/ealvar3z/pwc"
+)
+
+func main() {
+ for {
+ var i, j int
+ k, err := fmt.Scanf("%d %d", &i, &j)
+ if k != 2 || err != nil {
+ log.Println(err)
+ }
+
+ count := 0
+ seen := map[int]bool{}
+ for p := 1; p <= i; p++ {
+ for q := 1; q <= j; q++ {
+ if _, ok := seen[p*q]; !ok {
+ count++
+ seen[p*q] = true
+ }
+ }
+ }
+
+ //now let's create & sort an array with our map keys
+ distincts := make([]int, 0, len(seen))
+ for k := range seen {
+ distincts = append(distincts, k)
+ }
+ sort.Ints(distincts)
+
+ fmt.Printf("The count is %d\n", count)
+ fmt.Printf("The distinct values are: %d\n", distincts)
+ pwc.PrintTable(distincts, i, j, false)
+ }
+}
diff --git a/challenge-134/ealvar3z/python/ch-1.py b/challenge-134/ealvar3z/python/ch-1.py
new file mode 100644
index 0000000000..73701409f8
--- /dev/null
+++ b/challenge-134/ealvar3z/python/ch-1.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+
+from itertools import permutations
+
+ans = [int(''.join(d)) for d in permutations('0123456789', 10) if d[0] != '0']
+
+print(ans[:5])