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.

Perl 6Advent Calendar 2017

Day 4

Advent of Code day2をPerl 6で

Posted at

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

例によって投稿がなかったのでAdvent of Code day2の私の回答を貼っておきます。

use v6;

$*IN.lines>>.split("\t",:skip-empty)\
>>.Int\
>>.sort\
.map({.[+$_ - 1] - .[0]})\ # (#1)
.sum\
.say;
  • ポイント
    • mapの中で同じ配列を2回参照したい場合は.$_を使いましょう
    • ., $_* は使いどころが異なるので注意しましょう。

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

明日は、AnaTofuZさんの『Perl6のdebugの小ネタについて』です。
お楽しみに!

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?