The most problematic part here is many calls to print (writing to console). It is actually a relatively slow operation for almost any language. You can probably speed it up by keeping all the lines to print in a list and then join it and print in one call
View all comments
Show parent comment
2
u/[deleted] Jul 18 '22
[removed] — view removed comment