JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public class LeAndBo
{
public static void main(String[] args) {
String abc="abcde";
System.out.println("[a][b][c][d][e]");
for(int i=0;i<4;i++){
//the random part
int rnd=(int)(Math.random()*(abc.length()));
//had to make substrings because the string class has no remove char method
if(rnd==0){
abc=abc.substring(1);
}else if(abc.length()-1==rnd){
abc=abc.substring(0,abc.length()-1);
}else{
abc=abc.substring(0,rnd)+abc.substring(rnd+1);
}
// just some code, so that i can include the boxes; could have been smother without converting if string was iterable
for(char z: abc.toCharArray()){
System.out.print("["+z+"]");
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run