Games and Algorithms

https://sttronn.github.io/8-TILES/

Count Inversion

Well so if we can change the inversion by an even number that implies if we start with odd number of inversions we cannot reach 0 inversion which is the desirable state as odd +/- even is odd. So all we need to do is count the inversion if its odd the board is not solvable.

for (int i=0;i<n;i++)
for (int j=i+1;j<n;j++)
if (arr[i]>arr[j]) inv++

A* Search (Solver)

Tech Stack

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rishav Thakur

Rishav Thakur

Frontend @Groww. Likes music, reading and making stuff in between