Skip to content

Instantly share code, notes, and snippets.

@am0c
Created February 11, 2011 13:56
Show Gist options
  • Select an option

  • Save am0c/822372 to your computer and use it in GitHub Desktop.

Select an option

Save am0c/822372 to your computer and use it in GitHub Desktop.
jubeat 隅田川夏恋歌 highlight
#!/usr/bin/env perl
#
# 隅田川夏恋歌
# ************
#
#
use strict;
use warnings;
sub get_line {
my @lines;
while (my $line = <DATA>) {
last if $line =~ /^$/;
push @lines, $line;
}
join '', @lines;
}
while (my $line = get_line) {
my ($num, $pos);
$line =~ s{.}{
$pos++ if $& eq "." or $& eq "M";
$num |= 2 ** ($pos-1) if $& eq "M";
}xeg;
print $num, " ";
}
__DATA__
M...
....
....
....
.M..
M...
....
....
....
.M..
....
....
..M.
....
M...
....
....
..M.
.M..
....
...M
....
....
M...
....
....
..M.
....
....
...M
....
.M..
....
....
...M
..M.
....
....
....
...M
M...
....
....
....
.M..
M...
....
....
....
.M..
....
....
..M.
....
M...
....
....
..M.
.M..
....
....
....
..M.
....
....
....
...M
..M.
....
....
....
...M
...M
....
....
M...
.M..
M...
....
....
M...
....
....
....
..M.
....
M...
....
....
....
...M
..M.
....
.M..
....
....
....
...M
....
.M..
.M..
M...
....
....
..M.
....
....
....
....
....
.M..
....
....
....
....
...M
M...
....
....
....
....
..M.
....
....
....
....
....
.M..
....
.M..
....
....
....
....
..M.
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment