JSFiddle - React, Tailwind, and code Playground
by Hari Menon
HTML
<iframe width="800" height="500" frameborder="0" src="https://pythontutor.com/iframe-embed.html#code=const%20sorted%20%3D%20%5B1,%204,%205,%206,%207,%2010,%2011,%2012,%2015,%2016,%2019%5D%3B%0Aconst%20max%20%3D%2019%3B%0Aconst%20size%20%3D%20sorted.length%3B%0Aconst%20connections%20%3D%20%5B%5D%3B%0Aconst%20permute%20%3D%20function%20%28connection,%20index%29%20%7B%0A%20%20const%20edge%20%3D%20connection%5Bconnection.length%20-%201%5D%3B%0A%20%20if%20%28edge%20%3D%3D%3D%20max%29%20%7B%0A%20%20%20%20connections.push%28connection.slice%28%29.join%28'-'%29%29%3B%0A%20%20%7D%20else%20%7B%0A%20%20%20%20if%20%28%28index%20%3C%20size%29%20%26%26%20%5Bedge%20%2B%201,%20edge%20%2B%202,%20edge%20%2B%203%5D.includes%28sorted%5Bindex%5D%29%29%20%7B%0A%20%20%20%20%20%20connection.push%28sorted%5Bindex%5D%29%3B%0A%20%20%20%20%20%20permute%28connection,%20index%20%2B%201%29%3B%0A%20%20%20%20%7D%0A%20%20%20%20if%20%28%28index%20%2B%201%20%3C%20size%29%20%26%26%20%5Bedge%20%2B%202,%20edge%20%2B%203%5D.includes%28sorted%5Bindex%20%2B%201%5D%29%29%20%7B%0A%20%20%20%20%20%20connection.push%28sorted%5Bindex%20%2B%201%5D%29%3B%0A%20%20%20%20%20%20permute%28connection,%20index%20%2B%202%29%3B%0A%20%20%20%20%7D%0A%20%20%20%20if%20%28%28index%20%2B%202%20%3C%20size%29%20%26%26%20sorted%5Bindex%20%2B%202%5D%20%3D%3D%3D%20edge%20%2B%203%29%20%7B%0A%20%20%20%20%20%20connection.push%28sorted%5Bindex%20%2B%202%5D%29%3B%0A%20%20%20%20%20%20permute%28connection,%20index%20%2B%203%29%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20connection.pop%28%29%3B%0A%7D%3B%0A%0Apermute%28%5B0%5D,%200%29%3B%0A&codeDivHeight=400&codeDivWidth=350&curInstr=11&origin=opt-frontend.js&py=js&rawInputLstJSON=%5B%5D"> </iframe>