여자 친구가 Wordle에서 부정 행위를 할 수 있도록 나쁜 코드를 작성하는 데 오후를 낭비하는 방법...

5228 단어 csharpwordle
제목에서 알 수 있듯이 나는 wordle에서 내 GF 치트를 돕기 위해 이것을 썼습니다.

코드에 주석이 달려 있습니까? 안돼!
오류를 확인하고 있습니까? 거의!
키가 추가될 때 키 순서를 유지하기 위해 사전에 잘못 의존하고 있습니까? 예!
그리고 내가 goto 문과 너무 많은 전역 변수를 사용한 것을 잊지 말자!

그녀가 사용하고 있는 앱은 Android Lion Studios Wordle 앱이며, 어떤 단어 목록을 사용하고 있는지 모르겠습니다. 내가 찾은 가장 가까운 단어는 NASPA NSWL2020 단어 목록이지만 앱이 인식하지 못하는 단어가 해당 목록에 표시됩니다. (참고로 New York Times는 Collins 단어 목록을 사용합니다)

첫 번째 단어가 "reads"이고 올바른 위치에 있는 'a'와 함께 'r'과 'a'가 있음을 보여줍니다.
매개변수는 다음과 같이 입력됩니다.

wordlesolver ra ed 11a11 r1

첫 번째 매개변수: 단어의 문자를 나타냅니다.
두 번째 매개변수: 단어가 아닌 문자를 나타냅니다.
세 번째 매개변수: 단어의 문자 위치를 표시합니다.
넷째 이상: 지정된 위치에 없는 문자를 표시합니다.

예를 들어 wordlesolver 0 0 11a11 r1과 같이 '0'을 입력하면 첫 번째 및 두 번째 매개변수를 건너뛸 수 있습니다.
세 번째 매개변수를 완전히 건너뛸 수 있으며 표시된 위치에 없는 여러 문자를 나타내기 위해 계속해서 2자 정보를 추가할 수 있습니다. 예:
wordlesolver ra ed r1 t2 g4

wordlesolver ril eadspotf 11111 r1 i2 l2 l3 i3 r4는 "가사"라는 결과를 생성합니다.

말 그대로 위쪽 화살표를 사용하여 마지막 명령을 가져오고 추가 정보를 추가합니다.

예, 매개 변수는 단어에 포함된 문자를 나타내는 숫자와 함께 단어를 나열하고 올바른 위치에 있는 방법으로 훨씬 더 잘 구문 분석할 수 있지만, 이것은 내가 기꺼이 투입한 만큼의 노력입니다. .

추천 단어는 다음과 같은 방법으로 생성됩니다...
첫 번째 #은 사용되지 않았으며 가능한 솔루션 목록에 있는 단어의 문자 수입니다. 나머지 숫자는 단어에 대해 생성한 문자 빈도 점수입니다. 단어는 점수 순서대로 나열됩니다. 이론상으로는 한 단어만 나열하면 되지만 앱에서 가끔 단어를 인식하지 못하기 때문에 여러 단어가 나열됩니다.

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static Dictionary<string, int> word_dict = File.ReadAllLines(@"c:\a\words.txt").Distinct().OrderBy(x => x).ToDictionary(x => x, x => 0);
    static Dictionary<char, int> letter_dict = new() { { 'a', 0 }, { 'b', 0 }, { 'c', 0 }, { 'd', 0 }, { 'e', 0 }, { 'f', 0 }, { 'g', 0 }, { 'h', 0 }, { 'i', 0 }, { 'j', 0 }, { 'k', 0 }, { 'l', 0 }, { 'm', 0 }, { 'n', 0 }, { 'o', 0 }, { 'p', 0 }, { 'q', 0 }, { 'r', 0 }, { 's', 0 }, { 't', 0 }, { 'u', 0 }, { 'v', 0 }, { 'w', 0 }, { 'x', 0 }, { 'y', 0 }, { 'z', 0 } };
    static List<string> include = new();

    static void ParseArgs(string[] args)
    {
        int len = args.Length;

        foreach (string word in word_dict.Keys)
        {
            if (len > 2 && args[2].Length == 5)
                for (int j = 0; j < 5; j++)
                    if (char.IsLetter(args[2][j]))
                        if (word[j] != args[2][j])
                            goto end;

            if (len > 0 && args[0] != "0")
                for (int j = 0; j < args[0].Length; j++)
                    if (!word.Contains(args[0][j]))
                        goto end;

            if (len > 1 && args[1] != "0")
                for (int j = 0; j < args[1].Length; j++)
                    if (word.Contains(args[1][j]))
                        goto end;

            if (len > 3)
                for (int j = 0; j < len - 3; j++)
                    if (word[args[j + 3][1] - '0' - 1] == args[j + 3][0])
                        goto end;

            include.Add(word);

        end:;
        }
    }


    static void GetSolutions(string first)
    {
        foreach (string word in include)
            for (int i = 0; i < 5; i++)
                if (!first.Contains(word[i]))
                    letter_dict[word[i]]++;

        letter_dict = letter_dict.Where(x => x.Value > 0).OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

        if (include.Count <= 20)
        {
            Console.WriteLine("All possible solutions: ");
            foreach (string item in include)
                Console.Write($"{item} ");
        }
        else
            Console.Write($"There are {include.Count} possible solutions. ");

        Console.WriteLine("\n");
    }


    static void GetSuggestedWords()
    {
        foreach (string word in word_dict.Keys)
            foreach (char item in letter_dict.Keys.Distinct())
                if (word.Contains(item))
                    word_dict[word] += letter_dict[item] + 100000;

        word_dict = word_dict.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

        if (word_dict[word_dict.Keys.First()] >= 200000)
        {
            Console.WriteLine("Suggested word / Word score:");
            int count = 0;

            foreach (string item in word_dict.Keys)
                if (word_dict[item]! >= 200000)
                {
                    Console.Write("{0} {1} ", item, word_dict[item]);
                    count++;
                    if (count == 9)
                        break;
                }
        }

        Console.WriteLine("\n");
    }


    static void Main(string[] args)
    {
        Console.Clear();

        if (args.Length == 0)
        {
            args = new string[1];
            args[0] = "0";
        }

        ParseArgs(args);
        GetSolutions(args[0]);
        GetSuggestedWords();
    }

좋은 웹페이지 즐겨찾기