diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2022-06-08 12:32:45 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-08 12:32:45 +0100 |
| commit | 7e59edfaf725cce91153a2ef5a38671aa804fc29 (patch) | |
| tree | f1eefd3b94f0afc1c56bebde3aeffef821ecf148 /challenge-146 | |
| parent | 0c7f061325cd07213c4bba4f1c34790d98bbab02 (diff) | |
| parent | 471b056ad154010f4c8a1f5bc830b20a3390c665 (diff) | |
| download | perlweeklychallenge-club-7e59edfaf725cce91153a2ef5a38671aa804fc29.tar.gz perlweeklychallenge-club-7e59edfaf725cce91153a2ef5a38671aa804fc29.tar.bz2 perlweeklychallenge-club-7e59edfaf725cce91153a2ef5a38671aa804fc29.zip | |
Merge pull request #6225 from pokgopun/pwc145
pwc145 solution in go
Diffstat (limited to 'challenge-146')
| -rw-r--r-- | challenge-146/pokgopun/go/ch-2.go | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/challenge-146/pokgopun/go/ch-2.go b/challenge-146/pokgopun/go/ch-2.go index b8aea49f0f..a8545314f3 100644 --- a/challenge-146/pokgopun/go/ch-2.go +++ b/challenge-146/pokgopun/go/ch-2.go @@ -2,35 +2,22 @@ package main import ( "fmt" - "log" "os" ) func main() { - samples := [][2]uint{ - [2]uint{3, 5}, - [2]uint{4, 3}, - } + var sample []string if len(os.Args) > 1 { - var sample [2]uint - _, err := fmt.Sscanf(os.Args[1], "%d/%d", &sample[0], &sample[1]) - if err != nil { - log.Fatal(err) + sample = os.Args[1:] + } else { + sample = []string{ + "redivider", + "deific", + "rotors", + "challenge", + "champion", + "christmas", } - samples = [][2]uint{sample} - } - for _, v := range samples { - p := parent(v) - gp := parent(p) - fmt.Printf("Input: member = '%d/%d'\nOutput: parent ='%d/%d' and grandparent = '%d/%d'\n", v[0], v[1], p[0], p[1], gp[0], gp[1]) - } -} - -func parent(s [2]uint) [2]uint { - if s[0] > s[1] { - return [2]uint{s[0] - s[1], s[1]} - } else if s[0] < s[1] { - return [2]uint{s[0], s[1] - s[0]} } - return [2]uint{1, 1} + fmt.Println(sample) } |
