Probably, but it was a requisite in case the board had too few filled squares to have one solution.Anonymously Famous wrote:Aren't properly made Sudoku boards supposed to only have one solution?
I was looking at my games folder today and I was wondering what to play. Not really having an idea I wished that I could choose one at random. Then it hit me, what if I made a program that did just that?
So I did, didn't take too long thanks to google. I present to you a random game chooser:
Code: Select all
import java.util.List;
import java.util.ArrayList;
import java.util.Random;
import java.io.File;
import java.io.IOException;
public class randomSelect {
List<String> fileFolder = new ArrayList<String>(1);
String path;
public static void main(String[] args) throws IOException{
randomSelect work = new randomSelect();
work.findFiles();
work.startFile();
}
public void findFiles(){
path = "C:\\Users\\Shai'tan\\Desktop\\Games";
String files;
File folder = new File(path);
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++)
{
if (listOfFiles[i].isFile())
{
files = listOfFiles[i].getName();
if (files.endsWith(".lnk") || files.endsWith(".url"))
{
fileFolder.add(files);
}
}
}
}
public void startFile() {
try{String runFile;
Random randomGenerator = new Random();
int index = randomGenerator.nextInt(fileFolder.size());
runFile = fileFolder.get(index);
String[] runThis = {"cmd", "/C",
"start \"\" \"C:\\Users\\Shai\'tan\\Desktop\\Games\\"+runFile+"\""};
Process p = Runtime.getRuntime().exec(runThis);
}catch(Exception e){
e.printStackTrace();}
}
}1. Have a folder with shortcuts for games. (They usually end with .lnk or .url (Steam) )
2. Set the path to said folder equal to the path String in the program, add a \ for each \ in the path.
3. Javac randomSelect
4. Java randomSelect
findFiles is something I found on the internet, so I take no credit for that.








