Skip to main content
Loading...

More Java Posts

public class Daedalus extends Athenian
{
	private Story story;
	public ArrayList<Skill> skills = new ArrayList<Skill>();
	public ArrayList<Athenian> children = new ArrayList<Athenian>();
	
	public Daedalus(Story story, ArrayList<Skill> inherentSkills)
	{
	if(story != null)
	System.out.println("ERROR No one is created with a story.");

	skills.add(inherentSkills);
	}

	public Momento advanceStory(Scene s)
	{
	System.err.println("ERROR Don't know how to proceed...");
	}
}


//██╗  ░█████╗░███╗░░░███╗  ██████╗░░█████╗░███████╗██████╗░░█████╗░██╗░░░░░██╗░░░██╗░██████╗
//██║  ██╔══██╗████╗░████║  ██╔══██╗██╔══██╗██╔════╝██╔══██╗██╔══██╗██║░░░░░██║░░░██║██╔════╝
//██║  ███████║██╔████╔██║  ██║░░██║███████║█████╗░░██║░░██║███████║██║░░░░░██║░░░██║╚█████╗░
//██║  ██╔══██║██║╚██╔╝██║  ██║░░██║██╔══██║██╔══╝░░██║░░██║██╔══██║██║░░░░░██║░░░██║░╚═══██╗
//██║  ██║░░██║██║░╚═╝░██║  ██████╔╝██║░░██║███████╗██████╔╝██║░░██║███████╗╚██████╔╝██████╔╝
//╚═╝  ╚═╝░░╚═╝╚═╝░░░░░╚═╝  ╚═════╝░╚═╝░░╚═╝╚══════╝╚═════╝░╚═╝░░╚═╝╚══════╝░╚═════╝░╚═════╝░
import java.util.Scanner;

/* In Heaven, the seed is tall and the oak small / It's input vital 
	* "The al-Madinatian," verse 236-37 
	* tinyurl.com/17snqkfv
	* email answer to [email protected]
	**/

public class Main
{
	public static void main(String args[])
	{
		int x = 0;
		int a, c, m = 10000;
		
		Scanner in = new Scanner(System.in);
		
		System.out.println("Please enter a seed, maximum 3000000:");
		x = in.nextInt();
		
		System.out.println("Please input a number, maximum 29:");
		a = in.nextInt();
		
		System.out.println("Please input a number, maximum 999999:");
		c = in.nextInt();
		
		char menu = 'y';
		while(menu != 'n')
		{
			x = (a*x + c) % m;
			
			System.out.println("The next number is " + x + "\nWould you like another? (y/n)");
			menu = in.next().charAt(0);
		}
	}
}

//██╗  ░█████╗░███╗░░░███╗  ██████╗░░█████╗░███████╗██████╗░░█████╗░██╗░░░░░██╗░░░██╗░██████╗
//██║  ██╔══██╗████╗░████║  ██╔══██╗██╔══██╗██╔════╝██╔══██╗██╔══██╗██║░░░░░██║░░░██║██╔════╝
//██║  ███████║██╔████╔██║  ██║░░██║███████║█████╗░░██║░░██║███████║██║░░░░░██║░░░██║╚█████╗░
//██║  ██╔══██║██║╚██╔╝██║  ██║░░██║██╔══██║██╔══╝░░██║░░██║██╔══██║██║░░░░░██║░░░██║░╚═══██╗
//██║  ██║░░██║██║░╚═╝░██║  ██████╔╝██║░░██║███████╗██████╔╝██║░░██║███████╗╚██████╔╝██████╔╝
//╚═╝  ╚═╝░░╚═╝╚═╝░░░░░╚═╝  ╚═════╝░╚═╝░░╚═╝╚══════╝╚═════╝░╚═╝░░╚═╝╚══════╝░╚═════╝░╚═════╝░
//Leif Messinger
//Solves wordle
//Needs a list of wordle words, newline separated and 5 characters each

import java.util.*;
import java.io.File;
import java.io.FileNotFoundException;

class WordleSolver {

	public static void printPointer(int position){
		for(int i = 0; i < position; ++i){
			System.out.print(" ");
		}
		System.out.print("^");
	}

	public static void main(String[] args) throws FileNotFoundException{
		if(args.length < 1) return;
		File dictionary = new File(args[0]);
		Scanner sc = new Scanner(dictionary);
		ArrayList<String> possibleWords = new ArrayList<String>();
		while(sc.hasNextLine()){
			possibleWords.add(sc.nextLine());
		}

		Scanner input = new Scanner(System.in);

		while(possibleWords.size() > 0){
			//Choose a word out of the possible words
			final int randomIndex = (int)(Math.random() * possibleWords.size());
			String chosenWord = possibleWords.get(randomIndex);
			possibleWords.remove(randomIndex);

			System.out.println("Is it correct?");
			for(int i = 0; i < chosenWord.length(); ++i){
				System.out.println(chosenWord);
				printPointer(i);
				System.out.println(" y/n?");
				if(input.nextLine().toLowerCase().contains("y")){
					//Filter by correct character
					for(int possibleWord = possibleWords.size() - 1; possibleWord >= 0; --possibleWord){ //Has to be backwards for removing entries, also has to be int not unsigned
						if(possibleWords.get(possibleWord).charAt(i) != chosenWord.charAt(i)){
							possibleWords.remove(possibleWord);
						}
					}
				}
			}
			System.out.println("Is it misplaced?");
			//Stores a count of every letter misplaced
			short[] misplacedCounts = new short[('z'-'a')+1]; //Praise be the garbage collector
			for(int i = 0; i < chosenWord.length(); ++i){
				System.out.println(chosenWord);
				printPointer(i);
				System.out.println(" y/n?");
				if(input.nextLine().toLowerCase().contains("y")){
					//Filter to make sure there's at least as many letters as needed
					++misplacedCounts[(chosenWord.charAt(i) - 'a') - 1];
					for(int possibleWord = possibleWords.size() - 1; possibleWord >= 0; --possibleWord){	//Has to be backwards for removing entries, also has to be int not unsigned
						int count = 0;
						for(int j = 0; j < possibleWords.get(possibleWord).length(); ++j){
							if(possibleWords.get(possibleWord).charAt(j) == chosenWord.charAt(i))
								++count;
						}
						//If there's not enough of the character that we need, then we remove that from the list of possible characters
						if(count < misplacedCounts[(chosenWord.charAt(i) - 'a') - 1]){
							possibleWords.remove(possibleWord);
						}
					}
					//Also filter out words where that letter doesn't belong there
					for(int possibleWord = possibleWords.size() - 1; possibleWord >= 0; --possibleWord){ //Has to be backwards for removing entries, also has to be int not unsigned
						if(possibleWords.get(possibleWord).charAt(i) == chosenWord.charAt(i)){
							possibleWords.remove(possibleWord);
							continue;	//Breaks the current word and moves on in the loop
						}
					}
				}
			}
		}
	}
}