This commit is contained in:
Jidong Xiao
2025-02-27 17:41:48 -05:00
committed by JamesFlare1212
parent 4df57b18b3
commit a37e7408b7
21 changed files with 0 additions and 1624 deletions

View File

@@ -1,126 +0,0 @@
**Special Note 1: A correct program does not necessarily pass all the test cases for this assignment, as Submitty may let you fail a test case if your program is not fast enough or consumes too much memory.**
**Special Note 2: For this assignment, we will not deduct points if you use data structures which have not been learned in this class. However, students who passed all test cases last semester did not use any of such data structures. In other words, using only data structures we have learned so far, is sufficient to pass all test cases.**
# Homework 6 — Inverse Word Search Recursion
In this homework we will build an inverse word search program using the techniques of recursion.
The goal is to construct a grid of letters that one can search to find specific words. Understanding the non-linear word
search program from Lectures 12 will be helpful in thinking about how you will solve this problem.
We strongly urge you to study and play with that program, including tracing through its behavior using a
debugger or cout statements or both. Please read the entire handout before beginning your implementation.
## Your Tasks
For this assignment, you will be given the dimensions (width and height) of a word search puzzle, a set of
words that should appear in the grid (forwards, backwards, up, down, or along any diagonal), and optionally
a set of words that should not appear anywhere in the grid. Each grid cell will be assigned one of the 26
lowercase letters. Note that unlike the non-linear word search problem we discussed in class, we will only
allow words that appear in a straight line (including diagonals). Your task is to output all unique word
search grids that satisfy the requirements. Rotations and mirroring of the board will be considered unique
solutions.
Your program should expect three command line arguments, the name of the input file, the name of the
output file, and a string:
```console
inverse_word_search.exe puzzle2.txt out2.txt one_solution
inverse_word_search.exe puzzle2.txt out2.txt all_solutions
```
The third argument indicates whether the program should find all solutions, or just one solution. Heres an
example of the input file format:
![alt text](example1.png "example1")
The first line specifies the width and height of the grid. Then each line that follows contains a character
and a word. If the character is +, then the word must appear in the grid. If the character is -, then the
word must not appear in the grid. For this first example we show an incorrect solution on the left. Though
it contains the 4 required words, it also contains two of the forbidden words. The solution on the right is a
fully correct solution. This particular problem has 8 solutions including rotations and reflections.
Below is a second example that specifies only positive (required) words. This puzzle has 4 solutions including
rotations and reflections.
![alt text](example2.png "example2")
When asked to find all solutions, your program should first output the number of solutions and then an
ASCII representation for each solution. See the example output files provided in this folder. You should follow
this output closely, however your solutions may be listed in a different order. When asked to find just one
solution, your program should just output the first legal solution it finds (it does not need to count the
number of solutions, nor does it need to be the first solution shown in our output). If the puzzle is impossible
your program should output “No solutions found”.
**To implement this assignment, you must use recursion in your search.** First you should tackle the problem
of finding and outputting one legal solution to the puzzle (if one exists).
## Algorithm Analysis
For larger, more complex examples, this is a really hard problem. Your program should be able to handle
the small puzzles we have created in a reasonable amount of time. <!--You should make up your own test cases
as well to understand this complexity. Include these test cases with your submission (they will be graded).
Summarize the results of your testing, which test cases completed successfully and the approximate “wall
clock time” for completion of each test.--> The UNIX/WSL time command can be prepended to your command
line to estimate the running time:
```console
time inverse_word_search.exe puzzle1.txt out1.txt one_solution
```
Once you have finished your implementation and testing, analyze the performance of your algorithm using
order notation. What important variables control the complexity of a particular problem? The width &
height of the grid (w and h), the number of required words (r), the number of forbidden words (f), the
number of letters in each word (l), the number of solutions (s)? In your plain text README.txt file, write
a concise paragraph (< 200 words) justifying your answer. <!--Also include a simple table summarizing the
running time and number of solutions found by your program on each of the provided examples. Note: Its
ok if your program cant solve the biggest puzzles in a reasonable amount of time.-->
## Program Requirements & Submission Details
Use good coding style when you design and implement your program. Organize your program into functions:
dont put all the code in main! Be sure to read the [Homework Policies](https://www.cs.rpi.edu/academics/courses/spring24/csci1200/homework_policies.php) as you put the finishing touches on your solution. Be sure to make up new test cases to fully debug your program and dont forget
to comment your code! Use the provided template [README.txt](./README.txt) file for notes you want the grader to read.
You must do this assignment on your own, as described in the [Collaboration Policy & Academic Integrity](https://www.cs.rpi.edu/academics/courses/spring24/csci1200/academic_integrity.php) page. If you did discuss the problem or error messages, etc. with anyone, please list their names in your README.txt file.
**Due Date**: 03/14/2024, Thursday, 10pm.
## Rubric
20 pts
- README.txt Completed (3 pts)
- One of name, collaborators, or hours not filled in. (-1)
- Two or more of name, collaborators, or hours not filled in. (-2)
- No reflection. (-1)
- LETTER GRID REPRESENTATION (2 pts)
- Grid is not represented via nested structure vector&lt;vector&lt;char&gt;&gt;, vector&lt;vector&lt;string&gt;&gt;, vector&lt;string&gt;, char\*\*, etc. (-1)
- Lookup of a position is not O(1), uses something like&lt;list&lt;char&gt;&gt; which has lookup of O(n). (-1)
- Incomplete to the point that no grid representation is evident within their code. (-1)
- USES RECURSION (4 pts)
- Use some non-trivial recursion but doesnt use recursion in the search process of board creation. (-2)
- Uses recursion but only trivially. (-3)
- Does not use any recursion. (-4)
- ALGORITHM ANALYSIS (In terms of the grid dimensions, the # of words, # of letters per word, the number of solutions etc. Looking for both an answer in order notation and a well-written justification in the plaintext README.txt file.) (5 pts)
- No order notation provided (-5)
- Order notation not written in terms of the provided variables w,h,r,f,l,s. Introduces new vars or provides it just in terms of n. (-2)
- Incorrect order notation. (-2)
- Order notation not simplified. (-1)
- No justification provided. (-4)
- Insufficient justification (tables alone are not enough). (-1)
- Did not finish but provides a reasonable analysis with respect to a theoretical implementation and properly justifies it. (-2)
- Did not finish but provides a runtime and some small analysis for a theoretical solution. (-4)
- Correct order notation for a largely incomplete implementation. (-4)
<!-- - TESTING SUMMARY & NEW TEST CASES (Included with submission and discussed in README.txt) (3 pts)
- Does not provide an adequate description of what the new testcases were in the README. (-2)
- Did not provide running times of the new test cases. (-1)
- Provides new test case description but implementation/test was missing from the submission. (-1)
- Did not provide new test cases or implementation too incomplete for new test cases. (-3)-->
- PROGRAM STRUCTURE (6 pts)
- Putting almost everything in the main function. It's better to create separate functions for different tasks. (-2)
- Function bodies containing more than one statement are placed in the .h file. (okay for templated classes) (-2)
- Missing include guards in the .h file. (Or does not declare them correctly) (-1)
- Functions are not well documented or are poorly commented, in either the .h or the .cpp file. (-1)
- Improper uses or omissions of const and reference. (-1)
- At least one function is excessively long (i.e., more than 200 lines). (-1)
- Overly cramped, excessive whitespace, or poor indentation. (-1)
- Poor file organization: Puts more than one class in a file (okay for very small helper classes) (-1)
- Poor variable names. (-1)
- Contains useless comments like commented-out code, terminal commands, or silly notes. (-1)

View File

@@ -1,43 +0,0 @@
HOMEWORK 6: INVERSE WORD SEARCH
NAME: < insert name >
COLLABORATORS AND OTHER RESOURCES:
List the names of everyone you talked to about this assignment
(classmates, TAs, ALAC tutors, upperclassmen, students/instructor via
LMS, etc.), and all of the resources (books, online reference
material, etc.) you consulted in completing this assignment.
< insert collaborators / resources >
Remember: Your implementation for this assignment must be done on your
own, as described in "Academic Integrity for Homework" handout.
ESTIMATE OF # OF HOURS SPENT ON THIS ASSIGNMENT: < insert # hours >
ALGORITHM ANALYSIS:
What's the order notation of your algorithm?
MISC. COMMENTS TO GRADER:
Optional, please be concise!
## Reflection and Self Assessment
Discuss the issues you encountered during development and testing. What
problems did you have? What did you have to research and learn on your
own? What kinds of errors did you get? How did you fix them?
What parts of the assignment did you find challenging? Is there anything that
finally "clicked" for you in the process of working on this assignment? How well
did the development and testing process go for you?
< insert reflection >

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -1,25 +0,0 @@
8 solution(s)
Board:
one
cat
Board:
one
tac
Board:
cat
one
Board:
tac
one
Board:
eno
cat
Board:
eno
tac
Board:
cat
eno
Board:
tac
eno

View File

@@ -1,3 +0,0 @@
Board:
one
cat

View File

@@ -1,13 +0,0 @@
4 solution(s)
Board:
one
cat
Board:
cat
one
Board:
eno
tac
Board:
tac
eno

View File

@@ -1,41 +0,0 @@
8 solution(s)
Board:
east
rest
arts
arid
Board:
arid
arts
rest
east
Board:
eraa
aerr
ssti
ttsd
Board:
ttsd
ssti
aerr
eraa
Board:
aare
rrea
itss
dstt
Board:
dstt
itss
rrea
aare
Board:
tsae
tser
stra
dira
Board:
dira
stra
tser
tsae

View File

@@ -1,17 +0,0 @@
4 solution(s)
Board:
echoo
baker
aptoe
Board:
aptoe
baker
echoo
Board:
oohce
rekab
eotpa
Board:
eotpa
rekab
oohce

View File

@@ -1,401 +0,0 @@
100 solution(s)
Board:
amrak
squid
ayeti
Board:
amrak
squid
byeti
Board:
amrak
squid
cyeti
Board:
amrak
squid
dyeti
Board:
amrak
squid
eyeti
Board:
amrak
squid
fyeti
Board:
amrak
squid
gyeti
Board:
amrak
squid
hyeti
Board:
amrak
squid
jyeti
Board:
amrak
squid
kyeti
Board:
amrak
squid
lyeti
Board:
amrak
squid
myeti
Board:
amrak
squid
nyeti
Board:
amrak
squid
oyeti
Board:
amrak
squid
pyeti
Board:
amrak
squid
qyeti
Board:
amrak
squid
ryeti
Board:
amrak
squid
syeti
Board:
amrak
squid
tyeti
Board:
amrak
squid
uyeti
Board:
amrak
squid
vyeti
Board:
amrak
squid
wyeti
Board:
amrak
squid
xyeti
Board:
amrak
squid
yyeti
Board:
amrak
squid
zyeti
Board:
ayeti
squid
amrak
Board:
byeti
squid
amrak
Board:
cyeti
squid
amrak
Board:
dyeti
squid
amrak
Board:
eyeti
squid
amrak
Board:
fyeti
squid
amrak
Board:
gyeti
squid
amrak
Board:
hyeti
squid
amrak
Board:
jyeti
squid
amrak
Board:
kyeti
squid
amrak
Board:
lyeti
squid
amrak
Board:
myeti
squid
amrak
Board:
nyeti
squid
amrak
Board:
oyeti
squid
amrak
Board:
pyeti
squid
amrak
Board:
qyeti
squid
amrak
Board:
ryeti
squid
amrak
Board:
syeti
squid
amrak
Board:
tyeti
squid
amrak
Board:
uyeti
squid
amrak
Board:
vyeti
squid
amrak
Board:
wyeti
squid
amrak
Board:
xyeti
squid
amrak
Board:
yyeti
squid
amrak
Board:
zyeti
squid
amrak
Board:
karma
diuqs
iteya
Board:
karma
diuqs
iteyb
Board:
karma
diuqs
iteyc
Board:
karma
diuqs
iteyd
Board:
karma
diuqs
iteye
Board:
karma
diuqs
iteyf
Board:
karma
diuqs
iteyg
Board:
karma
diuqs
iteyh
Board:
karma
diuqs
iteyj
Board:
karma
diuqs
iteyk
Board:
karma
diuqs
iteyl
Board:
karma
diuqs
iteym
Board:
karma
diuqs
iteyn
Board:
karma
diuqs
iteyo
Board:
karma
diuqs
iteyp
Board:
karma
diuqs
iteyq
Board:
karma
diuqs
iteyr
Board:
karma
diuqs
iteys
Board:
karma
diuqs
iteyt
Board:
karma
diuqs
iteyu
Board:
karma
diuqs
iteyv
Board:
karma
diuqs
iteyw
Board:
karma
diuqs
iteyx
Board:
karma
diuqs
iteyy
Board:
karma
diuqs
iteyz
Board:
iteya
diuqs
karma
Board:
iteyb
diuqs
karma
Board:
iteyc
diuqs
karma
Board:
iteyd
diuqs
karma
Board:
iteye
diuqs
karma
Board:
iteyf
diuqs
karma
Board:
iteyg
diuqs
karma
Board:
iteyh
diuqs
karma
Board:
iteyj
diuqs
karma
Board:
iteyk
diuqs
karma
Board:
iteyl
diuqs
karma
Board:
iteym
diuqs
karma
Board:
iteyn
diuqs
karma
Board:
iteyo
diuqs
karma
Board:
iteyp
diuqs
karma
Board:
iteyq
diuqs
karma
Board:
iteyr
diuqs
karma
Board:
iteys
diuqs
karma
Board:
iteyt
diuqs
karma
Board:
iteyu
diuqs
karma
Board:
iteyv
diuqs
karma
Board:
iteyw
diuqs
karma
Board:
iteyx
diuqs
karma
Board:
iteyy
diuqs
karma
Board:
iteyz
diuqs
karma

View File

@@ -1,833 +0,0 @@
208 solution(s)
Board:
zed
old
oat
Board:
zed
ola
oat
Board:
zed
olb
oat
Board:
zed
olc
oat
Board:
zed
ole
oat
Board:
zed
olf
oat
Board:
zed
olg
oat
Board:
zed
olh
oat
Board:
zed
oli
oat
Board:
zed
olj
oat
Board:
zed
olk
oat
Board:
zed
oll
oat
Board:
zed
olm
oat
Board:
zed
oln
oat
Board:
zed
olo
oat
Board:
zed
olp
oat
Board:
zed
olq
oat
Board:
zed
olr
oat
Board:
zed
ols
oat
Board:
zed
olt
oat
Board:
zed
olu
oat
Board:
zed
olv
oat
Board:
zed
olw
oat
Board:
zed
olx
oat
Board:
zed
oly
oat
Board:
zed
olz
oat
Board:
zoo
ela
ddt
Board:
zoo
ela
dat
Board:
zoo
ela
dbt
Board:
zoo
ela
dct
Board:
zoo
ela
det
Board:
zoo
ela
dft
Board:
zoo
ela
dgt
Board:
zoo
ela
dht
Board:
zoo
ela
dit
Board:
zoo
ela
djt
Board:
zoo
ela
dkt
Board:
zoo
ela
dlt
Board:
zoo
ela
dmt
Board:
zoo
ela
dnt
Board:
zoo
ela
dot
Board:
zoo
ela
dpt
Board:
zoo
ela
dqt
Board:
zoo
ela
drt
Board:
zoo
ela
dst
Board:
zoo
ela
dtt
Board:
zoo
ela
dut
Board:
zoo
ela
dvt
Board:
zoo
ela
dwt
Board:
zoo
ela
dxt
Board:
zoo
ela
dyt
Board:
zoo
ela
dzt
Board:
oat
ola
zed
Board:
oat
olb
zed
Board:
oat
olc
zed
Board:
oat
old
zed
Board:
oat
ole
zed
Board:
oat
olf
zed
Board:
oat
olg
zed
Board:
oat
olh
zed
Board:
oat
oli
zed
Board:
oat
olj
zed
Board:
oat
olk
zed
Board:
oat
oll
zed
Board:
oat
olm
zed
Board:
oat
oln
zed
Board:
oat
olo
zed
Board:
oat
olp
zed
Board:
oat
olq
zed
Board:
oat
olr
zed
Board:
oat
ols
zed
Board:
oat
olt
zed
Board:
oat
olu
zed
Board:
oat
olv
zed
Board:
oat
olw
zed
Board:
oat
olx
zed
Board:
oat
oly
zed
Board:
oat
olz
zed
Board:
ddt
ela
zoo
Board:
dat
ela
zoo
Board:
dbt
ela
zoo
Board:
dct
ela
zoo
Board:
det
ela
zoo
Board:
dft
ela
zoo
Board:
dgt
ela
zoo
Board:
dht
ela
zoo
Board:
dit
ela
zoo
Board:
djt
ela
zoo
Board:
dkt
ela
zoo
Board:
dlt
ela
zoo
Board:
dmt
ela
zoo
Board:
dnt
ela
zoo
Board:
dot
ela
zoo
Board:
dpt
ela
zoo
Board:
dqt
ela
zoo
Board:
drt
ela
zoo
Board:
dst
ela
zoo
Board:
dtt
ela
zoo
Board:
dut
ela
zoo
Board:
dvt
ela
zoo
Board:
dwt
ela
zoo
Board:
dxt
ela
zoo
Board:
dyt
ela
zoo
Board:
dzt
ela
zoo
Board:
ooz
ale
tad
Board:
ooz
ale
tbd
Board:
ooz
ale
tcd
Board:
ooz
ale
tdd
Board:
ooz
ale
ted
Board:
ooz
ale
tfd
Board:
ooz
ale
tgd
Board:
ooz
ale
thd
Board:
ooz
ale
tid
Board:
ooz
ale
tjd
Board:
ooz
ale
tkd
Board:
ooz
ale
tld
Board:
ooz
ale
tmd
Board:
ooz
ale
tnd
Board:
ooz
ale
tod
Board:
ooz
ale
tpd
Board:
ooz
ale
tqd
Board:
ooz
ale
trd
Board:
ooz
ale
tsd
Board:
ooz
ale
ttd
Board:
ooz
ale
tud
Board:
ooz
ale
tvd
Board:
ooz
ale
twd
Board:
ooz
ale
txd
Board:
ooz
ale
tyd
Board:
ooz
ale
tzd
Board:
dez
dlo
tao
Board:
dez
alo
tao
Board:
dez
blo
tao
Board:
dez
clo
tao
Board:
dez
elo
tao
Board:
dez
flo
tao
Board:
dez
glo
tao
Board:
dez
hlo
tao
Board:
dez
ilo
tao
Board:
dez
jlo
tao
Board:
dez
klo
tao
Board:
dez
llo
tao
Board:
dez
mlo
tao
Board:
dez
nlo
tao
Board:
dez
olo
tao
Board:
dez
plo
tao
Board:
dez
qlo
tao
Board:
dez
rlo
tao
Board:
dez
slo
tao
Board:
dez
tlo
tao
Board:
dez
ulo
tao
Board:
dez
vlo
tao
Board:
dez
wlo
tao
Board:
dez
xlo
tao
Board:
dez
ylo
tao
Board:
dez
zlo
tao
Board:
tad
ale
ooz
Board:
tbd
ale
ooz
Board:
tcd
ale
ooz
Board:
tdd
ale
ooz
Board:
ted
ale
ooz
Board:
tfd
ale
ooz
Board:
tgd
ale
ooz
Board:
thd
ale
ooz
Board:
tid
ale
ooz
Board:
tjd
ale
ooz
Board:
tkd
ale
ooz
Board:
tld
ale
ooz
Board:
tmd
ale
ooz
Board:
tnd
ale
ooz
Board:
tod
ale
ooz
Board:
tpd
ale
ooz
Board:
tqd
ale
ooz
Board:
trd
ale
ooz
Board:
tsd
ale
ooz
Board:
ttd
ale
ooz
Board:
tud
ale
ooz
Board:
tvd
ale
ooz
Board:
twd
ale
ooz
Board:
txd
ale
ooz
Board:
tyd
ale
ooz
Board:
tzd
ale
ooz
Board:
tao
alo
dez
Board:
tao
blo
dez
Board:
tao
clo
dez
Board:
tao
dlo
dez
Board:
tao
elo
dez
Board:
tao
flo
dez
Board:
tao
glo
dez
Board:
tao
hlo
dez
Board:
tao
ilo
dez
Board:
tao
jlo
dez
Board:
tao
klo
dez
Board:
tao
llo
dez
Board:
tao
mlo
dez
Board:
tao
nlo
dez
Board:
tao
olo
dez
Board:
tao
plo
dez
Board:
tao
qlo
dez
Board:
tao
rlo
dez
Board:
tao
slo
dez
Board:
tao
tlo
dez
Board:
tao
ulo
dez
Board:
tao
vlo
dez
Board:
tao
wlo
dez
Board:
tao
xlo
dez
Board:
tao
ylo
dez
Board:
tao
zlo
dez

View File

@@ -1,5 +0,0 @@
1 solution(s)
Board:
tenet
alula
tenet

View File

@@ -1,25 +0,0 @@
4 solution(s)
Board:
rmagnet
odacova
buffalo
iuchaos
ncedart
Board:
ncedart
iuchaos
buffalo
odacova
rmagnet
Board:
tengamr
avocado
olaffub
soahcui
tradecn
Board:
tradecn
soahcui
olaffub
avocado
tengamr

View File

@@ -1,4 +0,0 @@
3 2
+ cat
+ one

View File

@@ -1,4 +0,0 @@
3 2
+ cat
+ one
- to

View File

@@ -1,11 +0,0 @@
4 4
+ arts
+ arid
+ east
+ rest
- ear
- at
- sit

View File

@@ -1,8 +0,0 @@
5 3
+ echo
+ baker
+ apt
+ toe
+ ore
+ eat
+ cap

View File

@@ -1,12 +0,0 @@
5 3
+ yeti
+ karma
+ squid
- sky
- red
- ski
- me
- at
- rut
- is
- yum

View File

@@ -1,6 +0,0 @@
3 3
+ ale
+ oat
+ zed
+ old
+ zoo

View File

@@ -1,35 +0,0 @@
5 3
+ tenet
+ alula
+ tat
+ nun
- ale
- an
- tent
- tnt
- aa
- ee
- ll
- au
- b
- c
- d
- f
- g
- h
- i
- j
- k
- m
- o
- p
- q
- r
- s
- v
- w
- x
- y
- z

View File

@@ -1,12 +0,0 @@
7 5
+ avocado
+ magnet
+ cedar
+ robin
+ chaos
+ buffalo
+ trade
+ lad
+ fun
- ace
- coat