I did this project. I read your approach and copied it. I did not look at your code (maybe a little bit, but not enough to understand something and not to copy something).
Also my strong recommendation for anybody else who wants to follow this approach, do not look at the code. You have the blog explaining how it works. Write your own algorithm. If you are stuck, printf is your friend. You should get it to work over some way with only that, even if it's not sorting correctly yet. If it's not sorting correctly, use the visualizer. Very, very useful. Take small samples, like only 5 numbers, maybe 10 or 20 depending on the problem, but in a range that you can still manually follow what it does.
So with the visualizer, if I saw that at some point it was moving elements in a way that should not happen, I used the stack size to print the information I needed only for that part. I got it to work, just had too many moves for 500 numbers.
That was the first time that I downloaded this repo and used the visualizer on both to compare them step by step. Mine was doing pretty much the exact same thing. And then there were steps where mine was taking longer moves. Helped me to check what the moves were at that point and why it was taking them (wrong if condition of course...)
So now I have my own version of this algo, I think mine is even a little bit better. Definitely faster. I think because of checking duplicates. Wrote me a test script to run the program like 100 times with 500 random numbers and calculated the average amount of moves, giving me the max and min amount and the time it took to run all of them.
Still have to do some refactoring in the following days to match the norm tho. Also, my project has the same small issue that it is possible to go over 5500 moves for 500 numbers, same as this repo does. I have some ideas that could possibly solve that. One harder than the other. Don't know if that is worth the effort since my average is like 5100 operations. One might not be that hard, maybe I give it a try.
If anybody still wants to look at the code, even tho I strongly discourage you if you still plan on doing the project yourself, here is my repo