843: Guess the Word

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px "Helvetica Neue"; color: #454545 }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px "Helvetica Neue"; color: #454545; min-height: 14.0px }
p.p3 { margin: 0.0px 0.0px 2.0px 0.0px; font: 14.0px "Helvetica Neue"; color: #454545 }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px "Helvetica Neue"; color: #e4af0a }

This problem is an interactive problem new to the LeetCode platform.

We are given a word list of unique words, each word is 6 letters long, and one word in this list is chosen as secret.

You may call master.guess(word) to guess a word.  The guessed word should have type string and must be from the original list with 6 lowercase letters.

This function returns an integer type, representing the number of exact matches (value and position) of your guess to the secret word.  Also, if your guess is not in the given wordlist, it will return -1 instead.

For each test case, you have 10 guesses to guess the word. At the end of any number of calls, if you have made 10 or less calls to master.guess and at least one of these guesses was the secret, you pass the testcase.

Besides the example test case below, there will be 5 additional test cases, each with 100 words in the word list.  The letters of each word in those testcases were chosen independently at random from ‘a‘ to ‘z‘, such that every word in the given word lists is unique.

Example 1:

Input: secret = "acckzz", wordlist = ["acckzz","ccbazz","eiowzz","abcczz"]

Explanation:

master.guess("aaaaaa") returns -1, because "aaaaaa" is not in wordlist.

master.guess("acckzz") returns 6, because "acckzz" is secret and has all 6 matches.

master.guess("ccbazz") returns 3, because "ccbazz" has 3 matches.

master.guess("eiowzz") returns 2, because "eiowzz" has 2 matches.

master.guess("abcczz") returns 4, because "abcczz" has 4 matches.

We made 5 calls to master.guess and one of them was the secret, so we pass the test case.

Note:  Any solutions that attempt to circumvent the judge will result in disqualification.

https://leetcode.com/problems/guess-the-word/discuss/133862/Random-Guess-and-Minimax-Guess-with-Comparison

原文地址:https://www.cnblogs.com/tobeabetterpig/p/10036126.html

时间: 2024-10-14 23:12:01

843: Guess the Word的相关文章

Leetcode 843. Guess the Word

Problem: This problem is an interactive problem new to the LeetCode platform. We are given a word list of unique words, each word is 6 letters long, and one word in this list is chosen as secret. You may call master.guess(word) to guess a word.  The

843. Guess the Word —— weekly contest 86

题目链接:https://leetcode.com/problems/guess-the-word/description/ 占坑 据说要用启发式算法,可参考下述答案进行学习:https://leetcode.com/problems/guess-the-word/discuss/133862/Random-Guess-and-Minimax-Guess-with-Comparison 原文地址:https://www.cnblogs.com/jinjin-2018/p/9098158.html

c# word 操作

1 public class WordOperate 2 { 3 4 #region 新建Word文档 5 /// <summary> 6 /// 动态生成Word文档并填充内容 7 /// </summary> 8 /// <param name="dir">文档目录</param> 9 /// <param name="fileName">文档名</param> 10 /// <ret

jacob 操作word

1. 首先下载jacob-1.18.zip,解压后有两个文件jacob.jar 和 jacob.dll.需要把jacob.jar放到你工程的classpath中并且把jacob.dll放到jdk的bin目录下(D:\Program Files\Java\jdk1.8.0_101\bin)目录下或者系统的system32其他相应的目录下. 2.下面是提供的工具类 1 package com.erqiao.rc.util; 2 3 import com.jacob.activeX.ActiveXCo

POI加dom4j将数据库的数据按一定格式生成word文档

一:需求:将从数据库查处来的数据,生成word文档,并有固定的格式.(dom4j的jar包+poi的jar包) 二:解决:(1)先建立固定格式的word文档(2007版本以上),另存成为xml文件,作为模板.(修改xml节点,添加属性,用于标示要填固定数据的节点) (2)dom4j解析模板xml文件,将文件读入内存,并把数据库数据写入内存的xml模型中 (3)利用poi将内存中的含有数据库内容的xml模型转换成word内存模型,利用输出流输出word文档 三:DEMO [1]模板的word文档

jacob操作word (转)

1 /** 2 * 感觉很厉害的样子就转了,原帖地址:http://wang-ping001.iteye.com/blog/1452057 3 */ 4 package com.xaeds.taecs.common.util; 5 6 import com.jacob.activeX.ActiveXComponent; 7 import com.jacob.com.Dispatch; 8 import com.jacob.com.Variant; 9 10 /** 11 * @author Ad

【小丸类库系列】Word操作类

1 using Microsoft.Office.Interop.Word; 2 using System; 3 using System.Collections.Generic; 4 using System.Drawing; 5 using System.IO; 6 using System.Linq; 7 using System.Reflection; 8 using System.Text.RegularExpressions; 9 10 namespace OtaReportTool

c#(.net) 导出 word表格

做了差不多一周的导出Word,现在把代码贴出来   : ExportWord.cs 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Data; 6 using System.IO; 7 8 9 /// <summary> 10 ///DaoChuWord 的摘要说明 11 /// </summary> 12 publ

使用freemarker插入多行数据到word中

使用freemarker向word中插入多列表格,需要以下条件 1)需要在模板中加入<#list listTest as listKey>标签,标识插入多行 1 <#-- 由于要插入多行数据,使用这个标签标识 --> 2 <#list listTest as listKey> 3 <w:tr w:rsidR="00B137A1" w:rsidTr="00B137A1"> 4 <w:tc> 5 <w:t