LET'S HACK THIS !!!

Hi friends, let's talk something about hacking as this is Hackety hack. Have you ever thought of breaking somebody’s password? Today, I will be telling you that.

The situation is like; you know that your friend’s password is made up of the letters { J, O, H, N }, but you don’t know the order in which they are used and you want his password. Your task is to determine his password. You have been only given a computer to do that.

HINT: Print all the permutations that can be made out using these 6 letters. And constantly feed the output to the email id whose password is to be known. So you have to write a program to generate all the permutations of these alphabets.

# CODE

This program is written in C++. Compiled using Borland 5.5 C++ compiler.

```#include
#include
#include
/* function to swap array elements */
void swap (char v[], int i, int j)
{
char t;
t = v[i];
v[i] = v[j];
v[j] = t;
}
/* recursive function to generate permutations */
void perm (char v[], int n, int i)
{
/* this function generates the permutations of the array
* from element i to element n-1
*/
int	j;
/* if we are at the end of the array, we have one permutation
* we can use (here we print it; you could as easily hand the
* array off to some other function that uses it for something
*/
if (i == n)
{
for (j=0; j"%c ", v[j]);
printf ("\n");
} else
/* recursively explore the permutations starting
* at index i going through index n-1
*/
for (j=i; j
/* try the array with i and j switched */
swap (v, i, j);
perm (v, n, i+1);
/* swap them back the way they were */
swap (v, i, j);
}
}
/* little driver function to print perms of first 5 integers */
int main ()
{
char v[]="JOHN";
int i;
perm (v,4,0);
getch();
return 0;
}```

# Sample Output

```JOHN
JONH
JHON
JHNO
OJHN
OJNH
OHJN
OHNJ
ONHJ
ONJH
HOJN
HONJ
HJON
HJNO
HNOJ
HNJO
NOHJ
NOJH
NHOJ
NHJO
NJOH
NJHO```

Non-profit Tax ID # 203478467