diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-10-20 07:53:26 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-20 07:53:26 +0100 |
| commit | 703fcf238c31f42d6ad6c39204e3c6d2bf7f5bfb (patch) | |
| tree | b5abc8a42973b4ddd35232633c9547e89403fa01 | |
| parent | ef61f556b3a507320d94c9683d9510fe3c065ec0 (diff) | |
| parent | b5ed8b68d5948aaded9f4e41f700ba13b7de9bae (diff) | |
| download | perlweeklychallenge-club-703fcf238c31f42d6ad6c39204e3c6d2bf7f5bfb.tar.gz perlweeklychallenge-club-703fcf238c31f42d6ad6c39204e3c6d2bf7f5bfb.tar.bz2 perlweeklychallenge-club-703fcf238c31f42d6ad6c39204e3c6d2bf7f5bfb.zip | |
Merge pull request #5059 from ealvar3z/branch-for-challenge-134
pushing to sync w/ upstream
| -rw-r--r-- | challenge-134/ealvar3z/go/ch-2.go | 41 | ||||
| -rw-r--r-- | challenge-134/ealvar3z/python/ch-1.py | 7 |
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]) |
