user
A sub-unit square is a square number (product of two identical non-negative integers) that remains a square after having a 1 subtracted from each digit in the square.

E.G.

The number **1** is a sub-unit square. **1** - **1** is **0**, which is also a square, though it's kind-of a degenerate case.

The number **3136** is a sub-unit square. **3136** (**56²**) with unit **1** subtracted from each digit is **2025** (**45²**).

A sub-unit square cannot contain a digit zero (**0**) since zero minus one is negative one. Every known sub-unit square, with the exception of **1**, ends with the digits **36**.

Task

* Find and display at least the first five sub-unit squares.

See also

* OEIS:A061844 - Squares that remain squares if you decrease every digit by 1
assistant
First seven take about 5 seconds with this implementation. The eighth would take several hours at least.

```
my @upper = 1,|(1 .. *).map((* × 2)²);
my @lower = (^∞).map: *²;
my \R = [\+] 0, 1, 10, 100 … *;

my $l = 0;

.say for (gather {
    (^∞).map: -> $u {
        next if @upper[$u].contains: 0;
        my $chars = @upper[$u].chars;
        loop {
            $l++ and next   if @upper[$u] - @lower[$l]  > R[$chars];
            take @upper[$u] if @upper[$u] - @lower[$l] == R[$chars];
            last;
        }
    }
})[^7]

```

Output:

```
1
36
3136
24336
5973136
71526293136
318723477136
```