chiark / gitweb /
wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 29 Oct 2022 18:39:08 +0000 (19:39 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 29 Oct 2022 18:39:08 +0000 (19:39 +0100)
analyse [new file with mode: 0755]

diff --git a/analyse b/analyse
new file mode 100755 (executable)
index 0000000..a9cb8f3
--- /dev/null
+++ b/analyse
@@ -0,0 +1,24 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+while (<>) {
+  my @coords = qw(0 0 0);
+  chomp;
+  my $l = $_;
+  print join '', @coords;
+  while ($l =~ s/^.//) {
+    $_ = $&;
+    my $delta = s/[A-Z]/lc $&/e ? +1 : -1;
+    my $i =
+      $& eq 'X' ? 0 :
+      $& eq 'Y' ? 1 :
+      $& eq 'Z' ? 2 :
+      die;
+    $coords[$i] += $delta;
+    print " ", join '', @coords;
+  }
+  print "\n";
+}
+
+STDOUT->error and die $!;