QDBordtoshred / WEni

MIT License
0 stars 0 forks source link

FRQ #2 #19

Open QDBordtoshred opened 8 months ago

QDBordtoshred commented 8 months ago

HiddenWord

public class HiddenWord {
    private String hiddenWord;

    public HiddenWord(String word) {
        hiddenWord = word;
    }

    public String getHint(String guess) {
        StringBuilder hint = new StringBuilder();

        for (int i = 0; i < hiddenWord.length(); i++) {
            char guessChar = guess.charAt(i);
            char hiddenChar = hiddenWord.charAt(i);

            if (guessChar == hiddenChar) {
                hint.append(hiddenChar);  // Matching letter
            } else if (hiddenWord.indexOf(guessChar) != -1) {
                hint.append("+");  // Letter in a different position
            } else {
                hint.append("*");  // Letter not in the hidden word
            }
        }

        return hint.toString();
    }
}
public class Main {
    public static void main(String[] args) {
        HiddenWord puzzle = new HiddenWord("HARPS");

        // Test cases
        System.out.println(puzzle.getHint("AAAAA"));  // Output: "+A+++" 
        System.out.println(puzzle.getHint("HELLO"));  // Output: "H****"
        System.out.println(puzzle.getHint("HEART"));  // Output: "H*++*"
        System.out.println(puzzle.getHint("HARMS"));  // Output: "HAR*S"
        System.out.println(puzzle.getHint("HARPS"));  // Output: "HARPS"
    }
}
aidenhuynh commented 8 months ago

Comments:

The requirement for assignment is a Jupyter Notebook that runs the code, correctly identifying the FRQ type, and a reflection for the problem.

Score:

0.6/0.9

VINERAJ commented 8 months ago

Your code should be in a Jupyter Notebook, and you show have an issue with the connection between the FRQ and PBL. For this FRQ, I will give you a score of 0.63/0.9