0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Advent of Code day1をPerl 6で

Last updated at Posted at 2017-12-03

こんにちは、2日目の投稿になります

投稿がなかったのでAdvent of Code day1の私の回答を張っておきます。

  • ソースコード
use v6;                                                                            
                                                                                   
my @a = $*IN.slurp.trim.comb; # (#1)                                                    
say (|@a.tail(+@a - 1),@a[0] Z @a)\ # (#2)                                               
.map(-> ($a, $b) { $a == $b ?? $a !! 0 })\                                         
.sum; 
  • ポイント
    • 文字列から、文字単位のリストを作りたいならcombを使います (#1)
    • | を使うと平たん化ができます (#2)

以上、2日目の投稿でした。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?