349 Langton s ant.pl 409 B

12345678910111213141516171819
  1. #!/usr/bin/perl
  2. # Author: Daniel "Trizen" Șuteu
  3. # License: GPLv3
  4. # Website: https://github.com/trizen
  5. # Solved on paper:
  6. #
  7. # (10^18 - 11235 - 37) / 104 * 12 + 868
  8. #
  9. # where 104 is the number of moves to complete a cycle and 12 is the number of new black squares per cycle.
  10. # https://projecteuler.net/problem=349
  11. use 5.010;
  12. use Math::AnyNum qw(:overload);
  13. say ((10**18 - 11235 - 37) / 104 * 12 + 868);