user
```
              There is a fine line between numerator and denominator.       ─── anonymous

```

A method to   "reduce"   some reducible fractions is to   *cross out*   a digit from the
numerator and the denominator.   An example is:

```
       16                                                  16
      ────     and then (simply) cross─out the sixes:      ────
       64                                                  64

```

resulting in:

```
        1
       ───    
        4

```

Naturally,   this "method" of reduction must reduce to the proper value   (shown as a fraction).

This "method" is also known as   *anomalous cancellation*   and also   *accidental cancellation*.

(Of course,   this "method" shouldn't be taught to impressionable or gullible minds.)        😇

Task

Find and show some fractions that can be reduced by the above "method".

:   * show 2-digit fractions found   (like the example shown above)
    * show 3-digit fractions
    * show 4-digit fractions
    * show 5-digit fractions   (and higher)       *(optional)*
    * show each (above) n-digit fractions separately from other different n-sized fractions, don't mix different "sizes" together
    * for each "size" fraction,   only show a dozen examples   (the 1st twelve found)
    * (it's recognized that not every programming solution will have the same generation algorithm)
    * for each "size" fraction:

    :   :   * show a count of how many reducible fractions were found.   The example (above) is size **2**
            * show a count of which digits were crossed out   (one line for each different digit)

    * for each "size" fraction,   show a count of how many were found.   The example (above) is size **2**
    * show each n-digit example   (to be shown on one line):

    :   :   * show each n-digit fraction
            * show each reduced n-digit fraction
            * show what digit was crossed out for the numerator and the denominator

Task requirements/restrictions
:   * only proper fractions and their reductions   (the result)   are to be used   (no vulgar fractions)
    * only positive fractions are to be used   (no negative signs anywhere)
    * only base ten integers are to be used for the numerator and denominator
    * no zeros   (decimal digit)   can be used within the numerator or the denominator
    * the numerator and denominator should be composed of the same number of digits
    * no digit can be repeated in the numerator
    * no digit can be repeated in the denominator
    * (naturally)   there should be a shared decimal digit in the numerator   *and*   the denominator
    * fractions can be shown as   16/64   (for example)

Show all output here, on this page.

Somewhat related task
:   * Farey sequence       (It concerns fractions.)

References
:   * Wikipedia entry:   proper and improper fractions.
    * Wikipedia entry:   anomalous cancellation and/or accidental cancellation.
assistant
(formerly Perl 6)

**Works with**: Rakudo version 2019.07.1

Anomalous Cancellation

```
my %reduced;
my $digits = 2..4;

for $digits.map: * - 1 -> $exp {
    my $start = sum (0..$exp).map( { 10 ** $_ * ($exp - $_ + 1) });
    my $end   = 10**($exp+1) - sum (^$exp).map( { 10 ** $_ * ($exp - $_) } ) - 1;

    ($start ..^ $end).race(:8degree, :3batch).map: -> $den {
        next if $den.contains: '0';
        next if $den.comb.unique <= $exp;

        for $start ..^ $den -> $num {
            next if $num.contains: '0';
            next if $num.comb.unique <= $exp;

            my $set = ($den.comb.head(* - 1).Set ∩ $num.comb.skip(1).Set);
            next if $set.elems < 1;

            for $set.keys {
                my $ne = $num.trans: $_ => '', :delete;
                my $de = $den.trans: $_ => '', :delete;
                if $ne / $de == $num / $den {
                    print "\b" x 40, "$num/$den:$_ => $ne/$de";
                    %reduced{"$num/$den:$_"} = "$ne/$de";
                }
            }
        }
    }


    print "\b" x 40, ' ' x 40, "\b" x 40;

    my $digit = $exp +1;
    my %d = %reduced.pairs.grep: { .key.chars == ($digit * 2 + 3) };
    say "\n({+%d}) $digit digit reduceable fractions:";
    for 1..9 {
        my $cnt = +%d.pairs.grep( *.key.contains: ":$_" );
        next unless $cnt;
        say "  $cnt with removed $_";
    }
    say "\n  12 Random (or all, if less) $digit digit reduceable fractions:";
    say "    {.key.substr(0, $digit * 2 + 1)} => {.value} removed {.key.substr(* - 1)}"
      for %d.pairs.pick(12).sort;
}

```

Sample output:

```
(4) 2 digit reduceable fractions:
  2 with removed 6
  2 with removed 9

  12 Random (or all, if less) 2 digit reduceable fractions:
    16/64 => 1/4 removed 6
    19/95 => 1/5 removed 9
    26/65 => 2/5 removed 6
    49/98 => 4/8 removed 9

(122) 3 digit reduceable fractions:
  9 with removed 3
  1 with removed 4
  6 with removed 5
  15 with removed 6
  16 with removed 7
  15 with removed 8
  60 with removed 9

  12 Random (or all, if less) 3 digit reduceable fractions:
    149/298 => 14/28 removed 9
    154/352 => 14/32 removed 5
    165/264 => 15/24 removed 6
    176/275 => 16/25 removed 7
    187/286 => 17/26 removed 8
    194/291 => 14/21 removed 9
    286/385 => 26/35 removed 8
    286/682 => 26/62 removed 8
    374/572 => 34/52 removed 7
    473/572 => 43/52 removed 7
    492/984 => 42/84 removed 9
    594/693 => 54/63 removed 9

(660) 4 digit reduceable fractions:
  14 with removed 1
  25 with removed 2
  92 with removed 3
  14 with removed 4
  29 with removed 5
  63 with removed 6
  16 with removed 7
  17 with removed 8
  390 with removed 9

  12 Random (or all, if less) 4 digit reduceable fractions:
    1348/4381 => 148/481 removed 3
    1598/3196 => 158/316 removed 9
    1783/7132 => 178/712 removed 3
    1978/5934 => 178/534 removed 9
    2971/5942 => 271/542 removed 9
    2974/5948 => 274/548 removed 9
    3584/4592 => 384/492 removed 5
    3791/5798 => 391/598 removed 7
    3968/7936 => 368/736 removed 9
    4329/9324 => 429/924 removed 3
    4936/9872 => 436/872 removed 9
    6327/8325 => 627/825 removed 3
```