I studied class, iterator, Pointers, Vector, List, and Operator in this course. This is homework about the recursion star battle
I studied class, iterator, Pointers, Vector, List, and Operator in this course. This is homework about the recursion star battle puzzle. I can't use getline() in this homework. The output of the program should be exactly the same as the example output file I uploaded. For example, if the example output file name is "out_twonot2_3_one_slow.txt". There will take "twonot2.txt" as input file and 3 stars. "one" is the output mode mentioned in the hw.pdf. More detail in hw.pdf.
14 14 a 11 0 0 0 1 0 2 1 2 2 2 0 3 1 3 0 4 1 4 2 4 0 5 b 18 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 1 1 2 1 5 1 6 1 7 1 8 1 5 2 6 2 7 2 8 2 c 16 9 0 10 0 11 0 12 0 13 0 9 1 10 1 11 1 12 1 13 1 12 2 13 2 12 3 13 3 12 4 13 4 d 18 2 3 3 3 4 3 3 2 4 2 3 1 4 1 5 3 5 4 6 3 6 4 7 3 7 4 8 3 8 4 9 2 9 3 9 4 e 16 10 2 11 2 11 3 11 4 11 5 12 5 13 5 11 6 12 6 13 6 9 7 10 7 11 7 12 7 13 7 12 8 f 8 3 4 4 4 3 5 4 5 5 5 6 5 5 6 5 7 g 8 7 5 8 5 9 5 10 5 9 6 10 6 10 4 10 3 h 10 1 5 2 5 1 6 2 6 1 7 2 7 3 6 4 6 4 7 4 8 i 13 0 6 0 7 0 8 0 9 1 8 1 9 2 8 2 9 2 10 3 7 3 8 3 9 4 9 j 18 6 6 7 6 8 6 7 7 8 7 7 8 8 8 9 8 7 9 8 9 9 9 9 10 8 11 9 11 10 11 10 12 11 11 11 12 k 17 6 7 5 8 6 8 5 9 6 9 5 10 6 10 7 10 8 10 5 11 6 11 7 11 6 12 7 12 8 12 7 13 8 13 l 7 10 8 11 8 10 9 11 9 12 9 10 10 11 10 m 22 0 10 1 10 3 10 4 10 0 11 1 11 2 11 3 11 4 11 0 12 1 12 2 12 3 12 4 12 5 12 0 13 1 13 2 13 3 13 4 13 5 13 6 13 n 14 13 8 13 9 12 10 13 10 12 11 13 11 12 12 13 12 9 12 9 13 10 13 11 13 12 13 13 13
,
Number of solutions: 1 Solution 1: [email protected]@[email protected] @[email protected]@cccc [email protected]@[email protected] @[email protected]@dgecc [email protected]@[email protected] [email protected]@[email protected] [email protected]@[email protected] [email protected]@[email protected] [email protected]@[email protected] @[email protected]@n [email protected]@[email protected] [email protected]@[email protected] [email protected]@[email protected] [email protected]@[email protected]
,
Number of solutions: 1 Solution 1: @[email protected] [email protected]@ccccc @[email protected] [email protected]@ [email protected]@cc [email protected]@gggeee [email protected]@geee [email protected]@ [email protected]@len [email protected]@n [email protected]@kkkjllnn [email protected]@n [email protected]@kknjjnn [email protected]@nnnn
,
CSCI-1200 Data Structures — Spring 2022 Homework 6 — Star Battle
In this homework we will work with a variation on Star Battles, however we will modify one of the rules. As such, you should read the entire handout carefully. Star Battles in various forms have seen some popularity, so there is lots of material available online. You may not search for, study, or use any outside code related to Star Battles (or variants of Star Battles). You are welcome to find additional puzzles to experiment with and try to solve by hand. Some examples of puzzles are “Trees” (S=1, uses trees instead of stars as a symbol), “Two Not Touch” (S=2), and more generally “Star Battles“ (S=1, S=2, S=3 examples).
The basic goal is to consider a two dimensional grid in which each square belongs to exactly one contiguous group of squares. We will refer to these groups as zones. Some puzzles use background colors to make this more clear, we will use single letter labels for our zones (see Input File) below. The goal in our version is that for a positive integer S, we should place stars (we will use @ instead) such that:
1. Each zone should have exactly S stars.
2. No two stars can be adjacent (touching), not even diagonally!
3. Each row can have up to S stars in it.
4. Each column can have up to S stars in it.
Star Battle Arguments
Your program will accept five command line arguments.
Execution looks like: ./a.out [input file] [output file] [stars per zone] [output mode] [solution mode]
Input File
The input file describes the puzzle. The first two integers are the number of rows and then number of columns. Next that, we describe one zone at a time by first giving the label (letter) for zone and the number of squares in the zone. After each label and square count, the file contains a series of (x,y) coordinates for the zone. We define (0, 0) as the top left of the puzzle. You can assume zones always have at least 1 square, and that every input has at least 1 zone.
The input file custom1.txt and a visualization of the puzzle’s initial state is:
4 3
L 6
0 0
1 0
0 1
1 1
0 2
1 2
X 6
2 0
2 1
2 2
0 3
1 3
2 3
= Zone L
= Zone X
Output Mode
The output mode will either be count in which case you will only print the number of solutions you found (just the first line of output from the example in the section below), or print in which case you should print the count and print all solutions.
Solution Mode
The solution mode will either be one solution meaning you should only find up to one solution, or it will be all solutions meaning you should find all solutions that satisfy the inputs.
Output Formatting
Partial output for the custom1.txt puzzle with S = 1 is:
Number of solutions: 17
Solution 1:
LLX
@LX
XXX
Solution 2:
LLX
LLX
[see out_custom1_1_all.txt for full output]
To ensure full credit on the homework server, please format your solution exactly as shown above. Solutions may appear in any order, but the first line must start with Number of solution(s): then a space and the number of solutions. Each solution should start with a line that starts with Solution followed by one row of the grid per line, with (0, 0) being located in the top left. For any square that has a star, you should print @. For all other squares, you should print the letter of the zone the square belongs to.
Additional Requirements: Recursion, Order Notation, & Extra Puzzles
You must use recursion in a non-trivial way in your solution to this homework. As always, we recommend you work on this program in logical steps. Partial credit will be awarded for each component of the assignment. Your program should do some error checking when reading in the input to make sure you understand the file format. IMPORTANT NOTE: This problem is computationally expensive, even for medium-sized puzzles with too much freedom! Be sure to create your own simple test cases as you debug your program.
To help with runtime, your program should be written to do the three following things (also discussed in the HW6 Discussion lecture videos):
1. Start with the smallest zones first, and work up to the bigger zones in a puzzle
2. Stop considering a partial solution if we’ve seen it before (keep a history of states)
3. Stop considering a partial solution if it is no longer solveable
To get started, we recommend starting by solving sporcle1.txt first, since for S = 1, only one solution exists. After that, you may either want to move to twonot1.txt to handle S > 1, or you may want to move to custom1.txt (Still S = 1 but has many solutions).
2
Once you have finished your implementation, analyze the performance of your algorithm using order notation. What important variables control the complexity of a particular problem? In your 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.
You should include 1-3 new puzzles that either helped you test corner cases or experiment with the running time of your program. Make sure to describe these puzzles in your README.
You can use any technique we have covered in Lectures 1-14, Homework 1-5, and Lab 1-7. This means you cannot use STL pair, map, set, etc. on this homework assignment.
You must do this assignment on your own, as described in the “Collaboration Policy & Academic Integrity” handout. If you did discuss this assignment, problem solving techniques, or error messages, etc. with anyone, please list their names in your README.txt file.
NOTE: If you earn 7 points on the homework submission server for tests 3 through 10 by 11:59pm on Wednesday, March 16, you will earn a one day extension on HW6.
3
,
provided_files/out_twonot1_2_all.txt
Number of solutions: 1 Solution 1: [email protected]@d [email protected]@ccbccd [email protected]@ [email protected]@dd [email protected]@eedd [email protected]@ [email protected]@ggggd @[email protected] [email protected]@ggd @[email protected]
provided_files/out_twonot2_1_one.txt
Number of solutions: 1 Solution 1: @bbbbbbbbccccc [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
provided_files/out_twonot2_4_all_count.txt
Number of solutions: 0
provided_files/out_sporcle1_1_all_count.txt
Number of solutions: 1
provided_files/custom2.txt
3 6 T 12 0 0 1 0 0 1 1 1 2 1 3 1 4 1 5 1 2 0 3 0 4 0 5 0 o 6 0 2 1 2 2 2 3 2 4 2 5 2
provided_files/out_custom2_2_all.txt
Number of solutions: 142 Solution 1: [email protected] [email protected] [email protected]@ Solution 2: [email protected] [email protected] [email protected]@ Solution 3: [email protected] [email protected] [email protected]@ Solution 4: [email protected] @TTTTT [email protected]@ Solution 5: [email protected] @TTTTT [email protected]@ Solution 6: [email protected] @TTTTT [email protected]@o Solution 7: [email protected]@ TTTTTT [email protected]@ Solution 8: [email protected]@ TTTTTT [email protected]@o Solution 9: [email protected]@ TTTTTT [email protected]@oo Solution 10: [email protected]@ TTTTTT @[email protected] Solution 11: [email protected]@ TTTTTT @[email protected] Solution 12: [email protected]@ TTTTTT @[email protected] Solution 13: [email protected]@ TTTTTT @[email protected] Solution 14: [email protected]@ TTTTTT [email protected]@ Solution 15: [email protected]@ TTTTTT [email protected]@o Solution 16: [email protected]@ TTTTTT [email protected]@ Solution 17: [email protected] @TTTTT [email protected]@ Solution 18: [email protected] @TTTTT [email protected]@ Solution 19: [email protected] @TTTTT [email protected]@o Solution 20: [email protected] @TTTTT [email protected]@ Solution 21: [email protected] @TTTTT [email protected]@ Solution 22: [email protected] @TTTTT [email protected]@o Solution 23: [email protected]@ TTTTTT [email protected]@ Solution 24: [email protected]@ TTTTTT [email protected]@o Solution 25: [email protected]@ TTTTTT [email protected]@oo Solution 26: [email protected]@ TTTTTT @[email protected] Solution 27: [email protected]@ TTTTTT @[email protected] Solution 28: [email protected]@ TTTTTT @[email protected] Solution 29: [email protected]@ TTTTTT @[email protected] Solution 30: [email protected]@ TTTTTT [email protected]@ Solution 31: [email protected]@ TTTTTT [email protected]@ Solution 32: [email protected]@ TTTTTT [email protected]@o Solution 33: [email protected] @TTTTT [email protected]@ Solution 34: [email protected] @TTTTT [email protected]@ Solution 35: [email protected] @TTTTT [email protected]@o Solution 36: [email protected]@T TTTTTT [email protected]@ Solution 37: [email protected]@T TTTTTT [email protected]@o Solution 38: [email protected]@T TTTTTT [email protected]@oo Solution 39: [email protected]@T TTTTTT @[email protected] Solution 40: [email protected]@T TTTTTT @[email protected] Solution 41: [email protected]@T TTTTTT @[email protected] Solution 42: [email protected]@T TTTTTT @[email protected] Solution 43: [email protected]@T TTTTTT [email protected]@ Solution 44: [email protected]@T TTTTTT [email protected]@ Solution 45: [email protected]@T TTTTTT [email protected]@o Solution 46: [email protected] [email protected] @[email protected] Solution 47: [email protected] [email protected] [email protected]@ Solution 48: [email protected] [email protected] @[email protected] Solution 49: [email protected]@ TTTTTT [email protected]@ Solution 50: [email protected]@ TTTTTT [email protected]@ Solution 51: [email protected]@ TTTTTT [email protected]@o Solution 52: [email protected]@ TTTTTT [email protected]@o Solution 53: [email protected]@ TTTTTT [email protected]@oo Solution 54: [email protected]@ TTTTTT @[email protected] Solution 55: [email protected]@ TTTTTT @[email protected] Solution 56: [email protected]@ TTTTTT @[email protected] Solution 57: [email protected]@ TTTTTT [email protected]@ Solution 58: [email protected]@ TTTTTT @[email protected] Solution 59: [email protected]@T TTTTTT [email protected]@ Solution 60: [email protected]@T TTTTTT [email protected]@ Solution 61: <a href='/cdn-cgi/l/email-protect
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.
All Rights Reserved Terms and Conditions
College pals.com Privacy Policy 2010-2018