Compare commits
	
		
			17 Commits
		
	
	
		
			9f1f82ad43
			...
			a8-alt-sol
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 9752ef451f | |||
| 42cb09f3bd | |||
| 64f9b63215 | |||
| 8a5b7ce7fc | |||
| 06b028bfb2 | |||
| 7d4ecdaba6 | |||
| 4494f47a32 | |||
| 5ebb6a96cc | |||
| 6189cf6a3b | |||
| fb6ec1dc98 | |||
| ca2d32dc34 | |||
| 9a170e3334 | |||
| 0668095e82 | |||
| 4cf7a4e698 | |||
| 531c063830 | |||
| 131210cbab | |||
| 152e31b38d | 
							
								
								
									
										2
									
								
								Assignment8/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								Assignment8/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| a.out | ||||
| student_out | ||||
							
								
								
									
										86
									
								
								Assignment8/.idea/editor.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								Assignment8/.idea/editor.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,86 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <project version="4"> | ||||
|   <component name="BackendCodeEditorSettings"> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/EditorConfig/EnableClangFormatSupport/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXPRESSION/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_FOR_STMT/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTIPLE_DECLARATION/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_TERNARY/@EntryValue" value="ALIGN_ALL" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_CLASS_DEFINITION/@EntryValue" value="1" type="int" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue" value="2" type="int" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_CODE/@EntryValue" value="2" type="int" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_USER_LINEBREAKS/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_COMMENT/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INT_ALIGN_EQ/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_BLOCK_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMS/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_SEMICOLON/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_SEMICOLON/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_UNARY_OPERATOR/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_ARRAY_ACCESS_BRACKETS/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_METHOD_PARENTHESES/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPECIAL_ELSE_IF_TREATMENT/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_BINARY_OPSIGN/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_TERNARY_OPSIGNS/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/OTHER_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DECLARATION/@EntryValue" value="1" type="int" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DEFINITION/@EntryValue" value="1" type="int" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_INDENTATION/@EntryValue" value="All" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_PARAMETER/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_ARGUMENT/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_PARAMETER/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_DECLARATIONS/@EntryValue" value="0" type="int" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_COLON_IN_MEMBER_INITIALIZER_LISTS/@EntryValue" value="ON_SINGLE_LINE" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/MEMBER_INITIALIZER_LIST_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_NAMESPACE_DEFINITIONS_ON_SAME_LINE/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_EXTENDS_COLON/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_EXTENDS_COLON/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_COLON/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_COLON/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_DECLARATION_PARENTHESES/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_BLOCKS/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_LPAR/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_INVOCATION_LPAR/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_RPAR/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_LPAR/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_DECLARATION_LPAR/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_RPAR/@EntryValue" value="false" type="bool" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ARGUMENTS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_PARAMETERS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BREAK_TEMPLATE_DECLARATION/@EntryValue" value="LINE_BREAK" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/FREE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INVOCABLE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INITIALIZER_BRACES/@EntryValue" value="END_OF_LINE_NO_SPACE" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_STYLE/@EntryValue" value="Tab" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_SIZE/@EntryValue" value="4" type="int" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Double" type="string" /> | ||||
|     <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TAB_WIDTH/@EntryValue" value="4" type="int" /> | ||||
|   </component> | ||||
| </project> | ||||
							
								
								
									
										1
									
								
								Assignment8/.idea/misc.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								Assignment8/.idea/misc.xml
									
									
									
										generated
									
									
									
								
							| @@ -4,6 +4,7 @@ | ||||
|   <component name="MakefileSettings"> | ||||
|     <option name="linkedExternalProjectsSettings"> | ||||
|       <MakefileProjectSettings> | ||||
|         <option name="buildTarget" value="build" /> | ||||
|         <option name="externalProjectPath" value="$PROJECT_DIR$" /> | ||||
|         <option name="modules"> | ||||
|           <set> | ||||
|   | ||||
							
								
								
									
										7
									
								
								Assignment8/.idea/runConfigurations/1.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								Assignment8/.idea/runConfigurations/1.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| <component name="ProjectRunConfigurationManager"> | ||||
|   <configuration default="false" name="1" type="CLionNativeAppRunConfigurationType" PROGRAM_PARAMS="F" REDIRECT_INPUT="true" REDIRECT_INPUT_PATH="$PROJECT_DIR$/in/all_known_in_advance_spaces.in" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Assignment8" TARGET_NAME="build" CONFIG_NAME="build" version="1" RUN_PATH="a.out"> | ||||
|     <method v="2"> | ||||
|       <option name="CLION.COMPOUND.BUILD" enabled="true" /> | ||||
|     </method> | ||||
|   </configuration> | ||||
| </component> | ||||
							
								
								
									
										8
									
								
								Assignment8/.idea/runConfigurations/2.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Assignment8/.idea/runConfigurations/2.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <component name="ProjectRunConfigurationManager"> | ||||
|   <configuration default="false" name="2" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile"> | ||||
|     <makefile filename="C:\Users\Isaac\Documents\CS3413\Assignment8\makefile" target="2" workingDirectory="" arguments=""> | ||||
|       <envs /> | ||||
|     </makefile> | ||||
|     <method v="2" /> | ||||
|   </configuration> | ||||
| </component> | ||||
							
								
								
									
										8
									
								
								Assignment8/.idea/runConfigurations/3.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Assignment8/.idea/runConfigurations/3.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <component name="ProjectRunConfigurationManager"> | ||||
|   <configuration default="false" name="3" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile"> | ||||
|     <makefile filename="C:\Users\Isaac\Documents\CS3413\Assignment8\makefile" target="3" workingDirectory="" arguments=""> | ||||
|       <envs /> | ||||
|     </makefile> | ||||
|     <method v="2" /> | ||||
|   </configuration> | ||||
| </component> | ||||
							
								
								
									
										8
									
								
								Assignment8/.idea/runConfigurations/4.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Assignment8/.idea/runConfigurations/4.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <component name="ProjectRunConfigurationManager"> | ||||
|   <configuration default="false" name="4" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile"> | ||||
|     <makefile filename="C:\Users\Isaac\Documents\CS3413\Assignment8\makefile" target="4" workingDirectory="" arguments=""> | ||||
|       <envs /> | ||||
|     </makefile> | ||||
|     <method v="2" /> | ||||
|   </configuration> | ||||
| </component> | ||||
							
								
								
									
										7
									
								
								Assignment8/.idea/runConfigurations/5.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								Assignment8/.idea/runConfigurations/5.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| <component name="ProjectRunConfigurationManager"> | ||||
|   <configuration default="false" name="5" type="CLionNativeAppRunConfigurationType" PROGRAM_PARAMS="F" REDIRECT_INPUT="true" REDIRECT_INPUT_PATH="$PROJECT_DIR$/in/time_dependent_second_spaces.in" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Assignment8" TARGET_NAME="build" CONFIG_NAME="build" version="1" RUN_PATH="a.out"> | ||||
|     <method v="2"> | ||||
|       <option name="CLION.COMPOUND.BUILD" enabled="true" /> | ||||
|     </method> | ||||
|   </configuration> | ||||
| </component> | ||||
							
								
								
									
										7
									
								
								Assignment8/.idea/runConfigurations/6.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								Assignment8/.idea/runConfigurations/6.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| <component name="ProjectRunConfigurationManager"> | ||||
|   <configuration default="false" name="6" type="CLionNativeAppRunConfigurationType" PROGRAM_PARAMS="C" REDIRECT_INPUT="true" REDIRECT_INPUT_PATH="$PROJECT_DIR$/in/time_dependent_second_spaces.in" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Assignment8" TARGET_NAME="build" CONFIG_NAME="build" version="1" RUN_PATH="a.out"> | ||||
|     <method v="2"> | ||||
|       <option name="CLION.COMPOUND.BUILD" enabled="true" /> | ||||
|     </method> | ||||
|   </configuration> | ||||
| </component> | ||||
							
								
								
									
										8
									
								
								Assignment8/.idea/runConfigurations/all.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Assignment8/.idea/runConfigurations/all.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <component name="ProjectRunConfigurationManager"> | ||||
|   <configuration default="false" name="all" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile"> | ||||
|     <makefile filename="C:\Users\Isaac\Documents\CS3413\Assignment8\makefile" target="all" workingDirectory="" arguments=""> | ||||
|       <envs /> | ||||
|     </makefile> | ||||
|     <method v="2" /> | ||||
|   </configuration> | ||||
| </component> | ||||
							
								
								
									
										8
									
								
								Assignment8/.idea/runConfigurations/build.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Assignment8/.idea/runConfigurations/build.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <component name="ProjectRunConfigurationManager"> | ||||
|   <configuration default="false" name="build" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile"> | ||||
|     <makefile filename="C:\Users\Isaac\Documents\CS3413\Assignment8\makefile" target="build" workingDirectory="" arguments=""> | ||||
|       <envs /> | ||||
|     </makefile> | ||||
|     <method v="2" /> | ||||
|   </configuration> | ||||
| </component> | ||||
							
								
								
									
										8
									
								
								Assignment8/.idea/runConfigurations/clean.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Assignment8/.idea/runConfigurations/clean.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <component name="ProjectRunConfigurationManager"> | ||||
|   <configuration default="false" name="clean" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile"> | ||||
|     <makefile filename="C:\Users\Isaac\Documents\CS3413\Assignment8\makefile" target="clean" workingDirectory="" arguments=""> | ||||
|       <envs /> | ||||
|     </makefile> | ||||
|     <method v="2" /> | ||||
|   </configuration> | ||||
| </component> | ||||
							
								
								
									
										8
									
								
								Assignment8/.idea/runConfigurations/test.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Assignment8/.idea/runConfigurations/test.xml
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <component name="ProjectRunConfigurationManager"> | ||||
|   <configuration default="false" name="test" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile"> | ||||
|     <makefile filename="C:\Users\Isaac\Documents\CS3413\Assignment8\makefile" target="test" workingDirectory="" arguments=""> | ||||
|       <envs /> | ||||
|     </makefile> | ||||
|     <method v="2" /> | ||||
|   </configuration> | ||||
| </component> | ||||
							
								
								
									
										110
									
								
								Assignment8/code/disk.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								Assignment8/code/disk.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,110 @@ | ||||
| #include <stdlib.h> | ||||
| #include <stdio.h> | ||||
| #include "disk.h" | ||||
|  | ||||
|  | ||||
| DiskQueue *createDiskQueue() { | ||||
| 	DiskQueue *queue = malloc(sizeof(DiskQueue)); | ||||
| 	if (queue == NULL) { | ||||
| 		printf("Error allocating memory for queue\n"); | ||||
| 		exit(EXIT_FAILURE); | ||||
| 	} | ||||
| 	queue->head = NULL; | ||||
| 	queue->size = 0; | ||||
| 	return queue; | ||||
| } | ||||
|  | ||||
| void enqueue(DiskQueue *queue, int time, int position) { | ||||
| 	DiskRequest *request = malloc(sizeof(DiskRequest)); | ||||
| 	if (request == NULL) { | ||||
| 		printf("Error allocating memory for request\n"); | ||||
| 		exit(EXIT_FAILURE); | ||||
| 	} | ||||
| 	request->time = time; | ||||
| 	request->position = position; | ||||
| 	request->next = NULL; | ||||
|  | ||||
| 	if (queue->head == NULL) { | ||||
| 		queue->head = request; | ||||
| 	} else { | ||||
| 		DiskRequest *current = queue->head; | ||||
| 		while (current->next != NULL) { | ||||
| 			current = current->next; | ||||
| 		} | ||||
| 		current->next = request; | ||||
| 	} | ||||
| 	queue->size++; | ||||
| } | ||||
|  | ||||
| void delete(DiskQueue *queue, DiskRequest request) { | ||||
| 	DiskRequest *current = queue->head; | ||||
| 	DiskRequest *previous = NULL; | ||||
| 	while (current != NULL) { | ||||
| 		if (current->position == request.position && current->time == request.time) { | ||||
| 			if (previous == NULL) { | ||||
| 				queue->head = current->next; | ||||
| 			} else { | ||||
| 				previous->next = current->next; | ||||
| 			} | ||||
| 			queue->size--; | ||||
| 			free(current); | ||||
| 			return; | ||||
| 		} | ||||
| 		previous = current; | ||||
| 		current = current->next; | ||||
| 	} | ||||
| 	printf("Error: Request not found\n"); | ||||
| 	exit(EXIT_FAILURE); | ||||
| } | ||||
|  | ||||
| DiskRequest *dequeue(DiskQueue *queue) { | ||||
| 	DiskRequest *head = queue->head; | ||||
| 	queue->head = head->next; | ||||
| 	queue->size--; | ||||
| 	return head; | ||||
| } | ||||
|  | ||||
| void destroyDiskQueue(DiskQueue *queue) { | ||||
| 	DiskRequest *current = queue->head; | ||||
| 	DiskRequest *next = NULL; | ||||
| 	while (current != NULL) { | ||||
| 		next = current->next; | ||||
| 		free(current); | ||||
| 		current = next; | ||||
| 	} | ||||
| 	free(queue); | ||||
| } | ||||
|  | ||||
| DiskRequest* findClosest(DiskQueue *queue, int position, double time) { | ||||
| 	DiskRequest *current = queue->head; | ||||
| 	DiskRequest *next = NULL; | ||||
| 	DiskRequest *first = NULL; | ||||
| 	while (current != NULL) { | ||||
| 		if (current->time <= time) { // Filter out requests that haven't come in yet | ||||
| 			if (first == NULL) { | ||||
| 				first = current; | ||||
| 			} else { | ||||
| 				if (current->position < first->position) { | ||||
| 					first = current; | ||||
| 				} | ||||
| 			} | ||||
| 			int currentDistance = current->position - position; // Distance from the current to the current position, negative means down (bad) | ||||
| 			if (currentDistance > 0) { // If the current is up | ||||
| 				if (next == NULL) { // If there is no next yet, set it to the current | ||||
| 					next = current; | ||||
| 				} else { | ||||
| 					int nextDistance = next->position - position; // Distance from the next to the current position, negative means down (bad) | ||||
| 					if (currentDistance < nextDistance) { // If the current is closer than the next | ||||
| 						next = current; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		current = current->next; | ||||
| 	} | ||||
| 	// If we didn't find a request that is above the current position, return the first as a fallback | ||||
| 	if (next == NULL) { | ||||
| 		return first; | ||||
| 	} | ||||
| 	return next; | ||||
| } | ||||
							
								
								
									
										28
									
								
								Assignment8/code/disk.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								Assignment8/code/disk.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| #pragma once | ||||
|  | ||||
| typedef struct DiskRequest { | ||||
| 	struct DiskRequest *next; | ||||
| 	int position; | ||||
| 	int time; | ||||
| } DiskRequest; | ||||
|  | ||||
| typedef struct DiskQueue { | ||||
| 	DiskRequest *head; | ||||
| 	int size; | ||||
| } DiskQueue; | ||||
|  | ||||
| typedef enum DiskDirection { | ||||
| 	UP, DOWN | ||||
| } DiskDirection; | ||||
|  | ||||
| DiskQueue *createDiskQueue(); | ||||
|  | ||||
| void enqueue(DiskQueue *queue, int time, int position); | ||||
|  | ||||
| void delete(DiskQueue *queue, DiskRequest request); | ||||
|  | ||||
| DiskRequest *dequeue(DiskQueue *queue); | ||||
|  | ||||
| DiskRequest *findClosest(DiskQueue *queue, int position, double time); | ||||
|  | ||||
| void destroyDiskQueue(DiskQueue *queue); | ||||
							
								
								
									
										95
									
								
								Assignment8/code/main.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								Assignment8/code/main.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,95 @@ | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| #include "disk.h" | ||||
|  | ||||
| // Global tracking variables | ||||
| DiskDirection currentDirection = UP; | ||||
| int movement = 0; | ||||
| double seekTime = 0; | ||||
|  | ||||
| // Array for storing the requests | ||||
| DiskQueue *queue; | ||||
|  | ||||
| double timeToProcessRequest(int position, int destination) { | ||||
| 	//The time (a floating point number) required to process a request is computed by distance the head travels divided by 5 | ||||
| 	//Plus additional 15 milliseconds penalty if the direction has to change (for FCFS) | ||||
| 	double time = 0; | ||||
| 	// Calculated this way so that positive means up and negative means down | ||||
| 	int distance = destination - position; | ||||
| 	DiskDirection direction = (distance > 0) ? UP : DOWN; | ||||
| 	time += abs(distance) / 5.0; | ||||
| 	if (direction != currentDirection) { | ||||
| 		time += 15; | ||||
| 		currentDirection = direction; | ||||
| 	} | ||||
| 	return time; | ||||
| } | ||||
|  | ||||
| int diskMovement(int position, int destination) { | ||||
| 	int distance = destination - position; | ||||
| 	return abs(distance); | ||||
| } | ||||
|  | ||||
| // Your simulated disk is of size 10000, numbered from 0 to 9999. | ||||
|  | ||||
| // In first come first the time the request comes in is irrelevant | ||||
| void fcfs(int start) { | ||||
| 	int position = start; | ||||
| 	while (queue->size > 0) { | ||||
| 		DiskRequest *request = dequeue(queue); | ||||
| 		while (seekTime < request->time) { seekTime++; } | ||||
| 		seekTime += timeToProcessRequest(position, request->position); | ||||
| 		movement += diskMovement(position, request->position); | ||||
| 		position = request->position; | ||||
| 		free(request); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void cscan(int start) { | ||||
| 	int position = start; | ||||
|  | ||||
| 	while (queue->size > 0) { | ||||
| 		DiskRequest *request = findClosest(queue, position, seekTime); | ||||
| 		if (request == NULL) { | ||||
| 			seekTime++; | ||||
| 		} else { | ||||
| 			if (request->position < position) { | ||||
| 				// + 1 simulates the time it takes to move to the end of the disk (it is a circular disk) | ||||
| 				seekTime += timeToProcessRequest(position, 9999 + 1); | ||||
| 				movement += diskMovement(position, 9999 + 1); | ||||
| 				position = 0; | ||||
| 				// Rescan for closest, so we can efficiently handle requests | ||||
| 				request = findClosest(queue, position, seekTime); | ||||
| 			} | ||||
| 			seekTime += timeToProcessRequest(position, request->position); | ||||
| 			movement += diskMovement(position, request->position); | ||||
| 			position = request->position; | ||||
| 		} | ||||
| 		if (request != NULL) { | ||||
| 			delete(queue, *request); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
|  | ||||
| int main(int argc, char **argv) { | ||||
| 	int position, time; | ||||
| 	char algorithm = argv[1][0]; | ||||
| 	int start = 0; | ||||
|  | ||||
| 	queue = createDiskQueue(); | ||||
| 	while (EOF != (scanf("%i %i\n", &position, &time))) { | ||||
| 		enqueue(queue, time, position); | ||||
| 	} | ||||
| 	if (algorithm == 'F') { | ||||
| 		fcfs(start); | ||||
| 		printf("Movement:%i Time:%.1lf\n", movement, seekTime); | ||||
| 	} else if (algorithm == 'C') { | ||||
| 		cscan(start); | ||||
| 		// Stupid printf difference to pass tests, could call once after if statement | ||||
| 		printf("Movement: %i Time:%.1lf\n", movement, seekTime); | ||||
| 	} | ||||
| 	destroyDiskQueue(queue); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
| @@ -1,34 +0,0 @@ | ||||
| #include <stdio.h> | ||||
| char currentDirection; | ||||
|  | ||||
| void fcfs(int start){ | ||||
|     int movement = 0; | ||||
|     double time = 0; | ||||
|     printf("Movement: %i Time:%.1lf\n", movement, time); | ||||
| } | ||||
|  | ||||
| void cscan(int start){ | ||||
|     int movement = 0; | ||||
|     double time = 0; | ||||
|     printf("Movement: %i Time:%.1lf\n", movement, time); | ||||
| } | ||||
|  | ||||
| int main (int argc, char** argv){ | ||||
|     int position, time; | ||||
|     char algorithm = argv[1][0]; | ||||
|     int start = 0; | ||||
|     currentDirection  = 'a'; | ||||
|  | ||||
|  | ||||
|     while ( EOF!=(scanf("%i %i\n",&position,&time))) | ||||
|     { | ||||
|         printf("Delete me: position %i, Delete me: time %i\n",position,time); | ||||
|     } | ||||
|     if (algorithm == 'F'){ | ||||
|         fcfs(start); | ||||
|     }else if ( algorithm == 'C'){ | ||||
|         cscan(start); | ||||
|     } | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
							
								
								
									
										14
									
								
								Assignment8/documentation/verify.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								Assignment8/documentation/verify.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| | Initial position | Next Position | Distance | Time From Distance | Time from Change Direction | Total Time | | ||||
| |------------------|---------------|----------|--------------------|----------------------------|------------| | ||||
| | 0                | 93            | 93       | 18.6               | 0                          | 18.6       | | ||||
| | 93               | 183           | 90       | 18                 | 0                          | 18         | | ||||
| | 183              | 37            | 146      | 29.2               | 15                         | 44.2       | | ||||
| | 37               | 122           | 85       | 17                 | 0                          | 17         | | ||||
| | 122              | 14            | 108      | 21.6               | 15                         | 36.6       | | ||||
| | 14               | 124           | 110      | 22                 | 0                          | 22         | | ||||
| | 124              | 65            | 59       | 11.8               | 15                         | 26.8       | | ||||
| | 65               | 67            | 2        | 0.4                | 0                          | 0.4        | | ||||
|  | ||||
| | Total Distance | Total Time | | ||||
| |----------------|------------| | ||||
| | 693            | 183        | | ||||
| @@ -1,12 +1,12 @@ | ||||
| .PHONY: clean build test all | ||||
|  | ||||
| clean: | ||||
| 	mkdir -p student_out | ||||
| 	rm student_out/* | ||||
| 	rm a.out | ||||
| 	mkdir -p ./student_out | ||||
| 	rm -f ./student_out/* | ||||
| 	rm -f ./a.out | ||||
|  | ||||
| build: | ||||
| 	gcc -g -O0 ./code/*.c -lm  | ||||
| 	gcc -g -O0 ./code/main.c ./code/disk.c -lm | ||||
| 1: | ||||
| 	./a.out F < in/all_known_in_advance_spaces.in > student_out/f-in-advance.out && diff  student_out/f-in-advance.out  out/f-in-advance.out  | ||||
| 2: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user