AI Assignment: Generating and Validating Blurbs - Semester 1

Verified

Added on  2019/09/16

|1
|308
|208
Homework Assignment
AI Summary
This assignment involves creating a program to generate and validate strings based on a specific grammar. The first part of the assignment requires writing a program to generate 10 random 'Blurbs', which are defined recursively in terms of 'Whoozits' and 'Whatzits'. 'Whoozits' consist of an 'x' followed by one to ten 'y's, while 'Whatzits' consist of a 'q' followed by either a 'z' or a 'd', followed by a 'Whoozit'. The second part requires writing a program that takes a string as input and checks whether it is a valid 'Blurb'. The program should continue to prompt the user for input until 'DONE' is entered. The solution likely involves recursive functions to parse and validate the structure of the strings based on the defined grammar, and provides a framework for understanding and implementing the concepts of language generation and validation using programming.
Document Page
Q1: [JF edited] In the language of an alien race, all words take the form of Blurbs. A Blurb is a Whoozit followed by
between zero and ten Whatzits. A Whoozit is the character 'x' followed by between one and ten 'y's. A Whatzit is a 'q'
followed by either a 'z' or a 'd', followed by a Whoozit. Design and implement a recursive program that generates 10
random Blurbs in this alien language. (Hint: start by trying to generate Whoozits, Whatzits, and Blurbs by hand and on
paper. Be sure to follow that order. Once you have a feeling for the structure of the language, then start to think about how
you might program it.) [15 points]
Sample Output:
Q2: Considering the language just discussed, write a program that reads a string from the user, and checks whether or not
is a valid sentence. If it is valid, it prints "The word is fine.", otherwise it prints "The word is a mess!" The program should
loop and ask the user for new input until they enter DONE. (Hint: try Whoozits first, followed by Whatzits, and then Blurbs.
For each method, test it by running it on known valid strings generated by the methods you had to write for Q1.) Note: if it
helps you, you can omit checking for the maximum number of times Whatzits or 'y's occur (e.g., "between one and ten"
becomes "one or more"). [20 points]
Sample Output:
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
[object Object]