Click here for USACO solutions! …just kidding. (You still have until the end of today to take it!)

7
Click here for USACO solutions! …just kidding. (You still have until the end of today to take it!)

Transcript of Click here for USACO solutions! …just kidding. (You still have until the end of today to take it!)

Page 1: Click here for USACO solutions! …just kidding. (You still have until the end of today to take it!)

Click here for USACO

solutions!…just kidding.

(You still have until the end of today to take it!)

Page 2: Click here for USACO solutions! …just kidding. (You still have until the end of today to take it!)

Introduction to Artificial Intelligence

• Branch of computer science• Goal of AI – to figure out what to do when you

don’t know what to doo “Uncertainty management”o AI program (“intelligent agent”) gets input from environment via

“sensors,” affects its environment through “actuators” (output)o Perception action cycle: Loop of sensor input, decisions, actuator

outputo AI = How to map sensors to actuators

Page 3: Click here for USACO solutions! …just kidding. (You still have until the end of today to take it!)

Applications of AI• Robotics

o Often associated with AIo Translating input from sensors into output (motors, speakers, etc.)

• Gameso Playing games (e.g. chess)o Making game actors/characters feel more natural

• Interneto Web crawlers (search engines), spam filters, recommendations, etc.

• Financeo Predicts price fluctuation for stocks, bonds, commodities, etc.o Helps make trading decisions

• Medicineo Suggest diagnoses given list of symptomso Monitor intensive care patients or long-term medication

Page 4: Click here for USACO solutions! …just kidding. (You still have until the end of today to take it!)

Machine Translation• Utilizes machine learning extensively• Translator is fed many, many examples of

already-translated text (such as a news article in two languages)o Builds translation model by figuring out which phrases correspond to

whicho Ex: “My name is” appears in English wherever “Je m’appelle” does in

French

• Google Translate does this for 50+ languageso Constantly improved by user feedback

Page 5: Click here for USACO solutions! …just kidding. (You still have until the end of today to take it!)

Spam Filtering• Also relies on machine learning• Analyzes messages for “spam-like” words/phrases

o Figures out which words are most indicative of spam (e.g. “Viagra”) based on past messages

o Bayesian probability/inference

• Other known “spam-like” qualitieso Known spammer IPo Emailed person before?o Addresses recipient by name?

Page 6: Click here for USACO solutions! …just kidding. (You still have until the end of today to take it!)

PotW - Cow Vegas• In an effort to swindle his cows, Farmer John has devised a (not so)

brilliant game to play against Bessie. Bessie, compensating for her bovine intelligence, pays you with milk to write a program that helps play for her.

• The game begins with n stacks of coins and mi coins in each stack, and Farmer John graciously lets Bessie go first. If each player takes 1 to k coins from one stack on each turn, and the player who takes the last coin out of all stacks wins, determine who will win assuming optimal play.

• Sample Input: 1 2 (one stack, take up to two) 6 (the stack has one coin)• Sample Output: John (either “John” or “Bessie”)• For 15 points, solve the problem for n=1 (1 stack of coins).• For 15 more points, solve the problem for 1 < n < 1,000,000• All integers in the input are less than 1,000,000 in magnitude.

Page 7: Click here for USACO solutions! …just kidding. (You still have until the end of today to take it!)

HintsSample Input #2:                 Sample Output #2:

3 3                                        John3 6 9

Sample Input #3:                 Sample Output #3:

3 2                                        Bessie1 1 1

• Try to find a pattern for the basic problem• Use Sprague-Grundy impartial game theory for the extension

o Sprague-Grundy theory gives each pile of coins a "nimber"• not necessarily equal to the number of coins

o The nimber of a state is equal to the minimum-exclusion of the nimbers of states reachable from the state

o Nimber = zero: losing state, otherwise: winning stateo XOR nimbers together to combine multiple states (piles)o Consult Google for details

• Final solution is actually very simple