diff options
| -rw-r--r-- | challenge-071/cheok-yin-fung/common-lisp/ch-1.lsp | 4 | ||||
| -rw-r--r-- | challenge-071/cheok-yin-fung/perl/ch-1.pl | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/challenge-071/cheok-yin-fung/common-lisp/ch-1.lsp b/challenge-071/cheok-yin-fung/common-lisp/ch-1.lsp index 538cf3169e..fe32471396 100644 --- a/challenge-071/cheok-yin-fung/common-lisp/ch-1.lsp +++ b/challenge-071/cheok-yin-fung/common-lisp/ch-1.lsp @@ -1,3 +1,7 @@ +; notes on 10min before deadline: I forgot to implement the uniqueness +; requirement until I saw laurent_r's blog. +; Here the Lisp script hasn't implemented the uniqueness requirement. + (setf n 20) (setf seq () ) (setf peak_eles ()) diff --git a/challenge-071/cheok-yin-fung/perl/ch-1.pl b/challenge-071/cheok-yin-fung/perl/ch-1.pl index a395d02ddc..996474cd7a 100644 --- a/challenge-071/cheok-yin-fung/perl/ch-1.pl +++ b/challenge-071/cheok-yin-fung/perl/ch-1.pl @@ -13,8 +13,13 @@ my @peak_eles = (); if ($ARGV[0]) {$N = $ARGV[0];} else {$N = 10;} -for (1..$N) { - push @seq, 1+int(rand(50)) +while ($#seq < $N) { + my $a = 1+int(rand(50)); + push @seq, $a unless exists $unique{$a} ; + $unique{ $a } = 1; + # notes on 10min before deadline: I forgot to implement the uniqueness + # requirement until I saw laurent_r's blog. + # Therefore, The code of generating the close to his. } sub checkpeak { |
