J, 75 73 67 bytes
(>:@][[echo@}:^:((~.-:}:)*{.={:)@]1&((,i.@{:(1#.[#~0=|){:)@]))^:_&1
Prints infinitely.
Note: TIO has +3 in the byte count because I changed infinite _ iteration to 9999 times.
Jonah
- 34.1k
- 4
- 41
- 95
Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange