Thread: srand slows down my program to a crawl

  1. #16
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    I will try it later.

    I meant what I said about keeping a backup. You can look at this in a few years time to judge your progress.

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Hodor
    I meant what I said about keeping a backup. You can look at this in a few years time to judge your progress.
    Backup? Use a version control system
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #18
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    I wouldn't preserve things just to look back upon them with horror. We all have code we are ashamed of...

    I haven't gotten to the classes or refactoring part of the book yet, this is the best I can do for now, sry.
    No need to apologize, I am not the one that suffers. But I would be very surprised if a book deliberately taught refactoring. Refactoring just means moving code around to achieve "cleaner" code without affecting what it does. In your case we simply want to remove the redundant code. I do want to encourage you to try it eventually, perhaps with our suggestions, once this is working.

    You may never be shown refactoring in a beginner's book. There are some for other audiences, but even if you never read it in a book, being able to refactor is a valued skill. It comes down to producing something professional.
    Last edited by whiteflags; 12-17-2015 at 08:38 PM.

  4. #19
    Registered User
    Join Date
    Apr 2011
    Posts
    308
    I took the time to put the functions into classes in their own files.

    I will post the header and cpp files, then the main program at the bottom.

    headers then their cpp file, there's about 10 of them.

    Code:
    #ifndef ARRAYZERORANDOM_H
    #define ARRAYZERORANDOM_H
    
    
    class ArrayZeroRandom
    {
        public:
            void set_array_value_to_zero ( int array[] );
            void randomizing_array_elements ( int array[], int size);
    };
    
    #endif // ARRAYZERORANDOM_H
    Code:
    #ifndef COUNTINGTHEFOURDIRECTIONS_H
    #define COUNTINGTHEFOURDIRECTIONS_H
    #include <string>
    #include "insertionsort.h"
    #include "arrayzerorandom.h"
    
    using namespace std;
    
    class CountingTheFourDirections
    {
        public:
            void set_one_int_array_equal_to_another_int_array ( int array[], int array2[] );
            void direction_value_array_transfer_value_to_new_array (int lowest_value_array[],
                                                           string *lowest_value_array_direction,
                                                                      int north[],
                                                                      int south[],
                                                                      int east[],
                                                                      int west[],
                                                                      int *direction_value);
            void newSwitch (int array[], int size, int subtracting_this_many_array_elements, int *high, int *medium, int *low);
            int which_value_is_largest (int high, int medium, int low);
            int side (int array[], int size, int subtracting_this_many_array_elements);
            int  do_this_if_left_or_right_is_greater(int array[], string left_or_right[], int *I_took_a_step, int left_side, int right_side, int subtracting_this_many_array_elements, int which_string_element);
            int testing_four_directions(int counter[], string left_or_right[], int which_string_element);
            int which_direction_is_lowest(string lowest_value_feeler[], int north, int south, int east, int west, int feeler, int element);
            void displaying_which_direction_is_lowest( int lowest_value_array[], int direction_value, int feeler );
            void used_in_setting_feeler_to_new_value ( string left_or_right[],
                                               string lowest_value_feeler[],
                                               int lowest_value_array[],
                                               int north_array[],
                                               int south_array[],
                                               int east_array[],
                                               int west_array[],
                                               string *lowest_value_array_direction,
                                               int *north_count,
                                               int *south_count,
                                               int *east_count,
                                               int *west_count,
                                               int *left_or_right_1,
                                               int *left_or_right_2,
                                               int *left_or_right_3,
                                               int *left_or_right_4,
                                               int *feeler,
                                               int *element );
            void direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest( string lowest_value_feeler[],
                                                                                                                                             int lowest_value_array[],
                                          int north_array[],
                                          int south_array[],
                                          int east_array[],
                                          int west_array[],
                                          string *lowest_value_array_direction,
                                          int *north_count,
                                          int *south_count,
                                          int *east_count,
                                          int *west_count,
                                          int *feeler,
                                          int *element,
                                          int *direction_value );
    
    };
    
    #endif // COUNTINGTHEFOURDIRECTIONS_H
    Code:
    #ifndef HOWMANYSTEPS_H
    #define HOWMANYSTEPS_H
    
    
    class HowManySteps
    {
        public:
            void display_number_of_steps_message(int north, int south, int east, int west, int which_feeler);
    };
    
    #endif // HOWMANYSTEPS_H
    Code:
    #ifndef INSERTIONSORT_H
    #define INSERTIONSORT_H
    
    
    class InsertionSort
    {
        public:
            int findSmallestRemainingElement (int array[], int size, int index);
            void swap (int array[], int first_index, int second_index);
            void sort (int array[], int size);
            void displayArray (int array[], int size);
    };
    
    #endif // INSERTIONSORT_H
    Code:
    #ifndef MAKINGSTRINGARRAYSEQUAL_H
    #define MAKINGSTRINGARRAYSEQUAL_H
    #include <string>
    using namespace std;
    
    class MakingStringArraysEqual
    {
        public:
            void set_one_string_array_equal_to_another_string_array ( string array[], string array2[] );
    };
    
    #endif // MAKINGSTRINGARRAYSEQUAL_H
    Code:
    #ifndef MUSIC_H
    #define MUSIC_H
    #include "stacklayerinfo.h"
    
    class music
    {
        public:
            void listening_to_the_sound_made_by_the_array();
    };
    
    #endif // MUSIC_H
    Code:
    #ifndef SETTINGARRAYELEMENTZERO_H
    #define SETTINGARRAYELEMENTZERO_H
    #include "countingthefourdirections.h"
    #include <iostream>
    
    using namespace std;
    
    class SettingArrayElementZero
    {
        public:
            void fourth_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_6[],
                                                              int lowest_value_array_feeler_2_try_6[],
                                                              int north_array_2_try_6_one_and_odd[],
                                                              int south_array_2_try_6_one_and_odd[],
                                                              int east_array_2_try_6_one_and_odd[],
                                                              int west_array_2_try_6_one_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_6_one_and_odd,
                                                              int *south_count_array_2_try_6_one_and_odd,
                                                              int *east_count_array_2_try_6_one_and_odd,
                                                              int *west_count_array_2_try_6_one_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops);
                void third_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_5[],
                                                              int lowest_value_array_feeler_2_try_5[],
                                                              int north_array_2_try_5_one_and_odd[],
                                                              int south_array_2_try_5_one_and_odd[],
                                                              int east_array_2_try_5_one_and_odd[],
                                                              int west_array_2_try_5_one_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_5_one_and_odd,
                                                              int *south_count_array_2_try_5_one_and_odd,
                                                              int *east_count_array_2_try_5_one_and_odd,
                                                              int *west_count_array_2_try_5_one_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops);
         int setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( string left_or_right[],
                                                               string lowest_value_feeler_2_try_4[],
                                                               int lowest_value_array_feeler_2_try_4[],
                                                               int north_array_2_try_4_zero_and_even[],
                                                               int south_array_2_try_4_zero_and_even[],
                                                               int east_array_2_try_4_zero_and_even[],
                                                               int west_array_2_try_4_zero_and_even[],
                                                               string *feeler_1_lowest_value_array_direction,
                                                               string *feeler_2_lowest_value_array_direction,
                                                               string *did_second_feeler_work,
                                                               int *north_count_array_2_try_4_zero_and_even,
                                                               int *south_count_array_2_try_4_zero_and_even,
                                                               int *east_count_array_2_try_4_zero_and_even,
                                                               int *west_count_array_2_try_4_zero_and_even,
                                                               int *left_or_right_1,
                                                               int *left_or_right_2,
                                                               int *left_or_right_3,
                                                               int *left_or_right_4,
                                                               int *feeler,
                                                               int *element,
                                                               int *the_number_of_loops);
                   void second_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                               string lowest_value_feeler_2_try_3[],
                                                               int lowest_value_array_feeler_2_try_3[],
                                                               int north_array_2_try_3_zero_and_odd[],
                                                               int south_array_2_try_3_zero_and_odd[],
                                                               int east_array_2_try_3_zero_and_odd[],
                                                               int west_array_2_try_3_zero_and_odd[],
                                                               string *feeler_1_lowest_value_array_direction,
                                                               string *feeler_2_lowest_value_array_direction,
                                                               string *did_second_feeler_work,
                                                               int *north_count_array_2_try_3_zero_and_odd,
                                                               int *south_count_array_2_try_3_zero_and_odd,
                                                               int *east_count_array_2_try_3_zero_and_odd,
                                                               int *west_count_array_2_try_3_zero_and_odd,
                                                               int *left_or_right_1,
                                                               int *left_or_right_2,
                                                               int *left_or_right_3,
                                                               int *left_or_right_4,
                                                               int *feeler,
                                                               int *element,
                                                               int *the_number_of_loops);
                    void first_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_2[],
                                                              int lowest_value_array_feeler_2_try_2[],
                                                              int north_array_2_try_2_zero_and_odd[],
                                                              int south_array_2_try_2_zero_and_odd[],
                                                              int east_array_2_try_2_zero_and_odd[],
                                                              int west_array_2_try_2_zero_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_2_zero_and_odd,
                                                              int *south_count_array_2_try_2_zero_and_odd,
                                                              int *east_count_array_2_try_2_zero_and_odd,
                                                              int *west_count_array_2_try_2_zero_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops);
                    void setting_feeler_one_element_zero_to_zero ( string left_or_right[],
                                                      string lowest_value_feeler[],
                                                      int lowest_value_array[],
                                                      int north_array_1_try_2_zero[],
                                                      int south_array_1_try_2_zero[],
                                                      int east_array_1_try_2_zero[],
                                                      int west_array_1_try_2_zero[],
                                                      string *feeler_1_lowest_value_array_direction,
                                                      string *feeler_2_lowest_value_array_direction,
                                                      string *did_second_feeler_work,
                                                      int *north_count_array_1_try_2_zero,
                                                      int *south_count_array_1_try_2_zero,
                                                      int *east_count_array_1_try_2_zero,
                                                      int *west_count_array_1_try_2_zero,
                                                      int *left_or_right_1,
                                                      int *left_or_right_2,
                                                      int *left_or_right_3,
                                                      int *left_or_right_4,
                                                      int *feeler,
                                                      int *element,
                                                      int *the_number_of_loops);
    };
    
    #endif // SETTINGARRAYELEMENTZERO_H
    Code:
    #ifndef STACKLAYERINFO_H
    #define STACKLAYERINFO_H
    
    
    class StackLayerInfo
    {
        public:
            void display_message_about_stack_layer_part_two( int *stack_layer_one,
                                                     int *stack_layer_two,
                                                     int *stack_layer_three,
                                                     int *stack_layer_four);
            void display_message_about_stack_layer_part_one( int array[],
                                                     int *first_array_one_counter,
                                                     int *second_array_one_counter,
                                                     int *third_array_one_counter,
                                                     int *stack_layer_one,
                                                     int *stack_layer_two,
                                                     int *stack_layer_three,
                                                     int *stack_layer_four);
            void reading_the_results_of_listening_to_the_sound_made_by_the_array_function ( int *zero_counter, int *one_counter );
    };
    
    #endif // STACKLAYERINFO_H
    Code:
    #ifndef STARTPROGRAM_H
    #define STARTPROGRAM_H
    #include "thefunctionpartone.h"
    #include "thefunctionparttwo.h"
    #include "testresultsofthetwomainfunctions.h"
    #include <string>
    #include <iostream>
    
    using namespace std;
    
    class StartProgram
    {
        public:
            void running_the_two_main_functions( int compare_to_output_array_1[],
                                        int compare_to_output_array_2[],
                                        int the_random_list_generated_by_the_left_node_results_array[],
                                        int *try_again,
                                        int *good_job );
    };
    
    #endif // STARTPROGRAM_H
    Code:
    #ifndef TESTRESULTSOFTHETWOMAINFUNCTIONS_H
    #define TESTRESULTSOFTHETWOMAINFUNCTIONS_H
    #include "insertionsort.h"
    
    
    class TestResultsOfTheTwoMainFunctions
    {
        public:
            void writing_array_to_file_to_listen_to_after_program_ends( int array[]);
            int displaying_the_test_results_from_running_the_two_main_function(
                                                                       int compare_to_output_array_1[],
                                                                       int compare_to_output_array_2[],
                                                                       int the_random_list_generated_by_the_left_node_results_array[],
                                                                       int *counting_matching_array_elements_1,
                                                                       int *counting_matching_array_elements_2,
                                                                       int *counting_left_nodes_1,
                                                                       int *counting_left_nodes_2,
                                                                       int *try_again,
                                                                       int *good_job);
    };
    
    #endif // TESTRESULTSOFTHETWOMAINFUNCTIONS_H
    Code:
    #ifndef THEFUNCTIONPARTONE_H
    #define THEFUNCTIONPARTONE_H
    #include "makingstringarraysequal.h"
    #include "countingthefourdirections.h"
    #include "howmanysteps.h"
    #include "settingarrayelementzero.h"
    #include <string>
    
    using namespace std;
    
    class TheFunctionPartOne
    {
        public:
            void the_master_function_part_one ( string lowest_value_feeler_1_try_1[],
                                       string lowest_value_feeler_1_try_2[],
                                       string main_left_or_right[],
                                       int main_north_array[],
                                       int main_south_array[],
                                       int main_east_array[],
                                       int main_west_array[],
                                       string *feeler_one_element_zero_equal,
                                       string *feeler_1_lowest_value_array_direction,
                                       int *main_north_count,
                                       int *main_south_count,
                                       int *main_east_count,
                                       int *main_west_count,
                                       int *less_than_node);
    };
    
    #endif // THEFUNCTIONPARTONE_H
    Code:
    #ifndef THEFUNCTIONPARTTWO_H
    #define THEFUNCTIONPARTTWO_H
    #include "makingstringarraysequal.h"
    #include "arrayzerorandom.h"
    #include "countingthefourdirections.h"
    #include "howmanysteps.h"
    #include "settingarrayelementzero.h"
    #include <string>
    
    using namespace std;
    
    class TheFunctionPartTwo
    {
        public:
            void the_master_function_part_two ( string lowest_value_feeler_1_try_1[],
                                       string lowest_value_feeler_1_try_2[],
                                       string main_left_or_right[],
                                       int main_north_array[],
                                       int main_south_array[],
                                       int main_east_array[],
                                       int main_west_array[],
                                       string *feeler_one_element_zero_equal,
                                       string *feeler_1_lowest_value_array_direction,
                                       int *main_north_count,
                                       int *main_south_count,
                                       int *main_east_count,
                                       int *main_west_count,
                                       int *less_than_node,
                                       int *result_of_left_node_test);
    };
    
    #endif // THEFUNCTIONPARTTWO_H
    Code:
    #ifndef WHOSCORED_H
    #define WHOSCORED_H
    
    class WhoScored
    {
        public:
            void which_team_scored( int *try_again, int *good_job );
    };
    
    #endif // WHOSCORED_H
    Last edited by jeremy duncan; 12-18-2015 at 12:37 AM.

  5. #20
    Registered User
    Join Date
    Apr 2011
    Posts
    308
    Code:
    #include "arrayzerorandom.h"
    #include <cstdlib>
    #include <ctime>
    
    void ArrayZeroRandom::set_array_value_to_zero ( int array[] )
    {
        for ( int i = 0; i < 9; i++ )
        {
            array[ i ] = 0;
        }
    }
    
    void ArrayZeroRandom::randomizing_array_elements ( int array[], int size)
    {
    
        for ( int i = 0; i < size; i++ )
        {
            // keep the numbers small so they're easy to read
            array[ i ] = rand() % 9;
        }
    }
    Code:
    #include "countingthefourdirections.h"
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    
    void CountingTheFourDirections::set_one_int_array_equal_to_another_int_array ( int array[], int array2[] )
    {
        for ( int i = 0; i < 9; i++ )
        {
            array[ i ] = array2[ i ];
        }
    }
    
    void CountingTheFourDirections::direction_value_array_transfer_value_to_new_array (int lowest_value_array[],
                                                           string *lowest_value_array_direction,
                                                                      int north[],
                                                                      int south[],
                                                                      int east[],
                                                                      int west[],
                                                                      int *direction_value)
    {
    
        switch( *direction_value )
        {
            case 1:
            case 5:
            case 6:
            case 10:
            case 17:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, north );
                *lowest_value_array_direction = "north";
                break;
    
            case 2:
            case 8:
            case 12:
            case 15:
            case 18:
            case 20:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, south );
                *lowest_value_array_direction = "south";
                break;
    
            case 3:
            case 7:
            case 11:
            case 16:
            case 19:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, east );
                *lowest_value_array_direction = "east";
                break;
    
            case 4:
            case 9:
            case 13:
            case 14:
            case 21:
                set_one_int_array_equal_to_another_int_array ( lowest_value_array, west );
                *lowest_value_array_direction = "west";
                break;
        }
    }
    
    void CountingTheFourDirections::newSwitch (int array[], int size, int subtracting_this_many_array_elements, int *high, int *medium, int *low)
    {
        for ( int i = size; i-- > subtracting_this_many_array_elements; )
        {
    
            switch(array[i])
            {
                case 8:
                case 7:
                case 6:
                    //cout << "Input: " << i << " too high\n";
                    *high += 1;
                    break;
                case 5:
                case 4:
                case 3:
                    //cout << "Input: " << i << " might be good\n";
                    *medium += 1;
                    break;
                case 2:
                case 1:
                case 0:
                    //cout << "Input: " << i << " is good\n";
                    *low += 1;
                    break;
            }
        }
    }
    
    int CountingTheFourDirections::which_value_is_largest (int high, int medium, int low)
    {
        int value = 0;
    
        if ( high > medium && high > low && medium > low )
        {
            value = 13;
        }
    
        else if ( high > medium && high > low && medium == low )
        {
            value = 12;
        }
    
        else if ( high > medium && high > low && low > medium )
        {
            value = 11;
        }
    
        else if ( medium > high && medium > low && high > low )
        {
            value = 10;
        }
    
        else if ( medium > high && medium > low && high == low )
        {
            value = 9;
        }
    
        else if ( medium > high && medium > low && low > high )
        {
            value = 8;
        }
    
        else if ( low > medium && low > high && high > medium )
        {
            value = 7;
        }
    
        else if ( low > medium && low > high && high == medium )
        {
            value = 6;
        }
    
        else if ( low > medium && low > high && medium > high )
        {
            value = 5;
        }
    
        else if ( medium == low && high < medium )
        {
            value = 4;
        }
        else if ( high == low && medium < high )
        {
            value = 3;
        }
        else if ( high == medium && low < medium )
        {
            value = 2;
        }
        else
        {
            value = 1;
        }
    
        return value;
    }
    
    int CountingTheFourDirections::side (int array[], int size, int subtracting_this_many_array_elements)
    {
        InsertionSort function_in_InsertionSort;
        int too_high = 0;
        int might_be_good = 0;
        int good_stuff = 0;
    
        int value = 0;
    
        //cout << "____________________________________\n";
    
        //cout << "Original array: ";
        //displayArray( array, size );
        //cout << '\n';
    
        function_in_InsertionSort.sort( array, size );
    
        //cout << "Sorted array: ";
        //displayArray( array, size );
       // cout << '\n';
        //cout << '\n';
    
        newSwitch( array, size, subtracting_this_many_array_elements, &too_high, &might_be_good, &good_stuff );
    
        //cout << '\n';
    
        //cout << "high counter = " << too_high << '\n';
        //cout << "medium counter = " << might_be_good << '\n';
        //cout << "low counter = " << good_stuff << '\n';
    
        //cout << '\n';
    
        value = which_value_is_largest (too_high, might_be_good, good_stuff);
        //interpreting_whichValueIsLargest(value);
    
        //cout << '\n';
    
        return value;
    }
    
    int  CountingTheFourDirections::do_this_if_left_or_right_is_greater(int array[], string left_or_right[], int *I_took_a_step, int left_side, int right_side, int subtracting_this_many_array_elements, int which_string_element)
    {
        int value = 0;
        ArrayZeroRandom randomizing_or_zeroing;
        //cout << "____________________________________\n";
    
        //cout << "Left side value is: " << left_side << '\n';
        //cout << "Right side value is: " << right_side << '\n';
        //cout << '\n';
    
        if ( left_side > right_side )
        {
            for ( int i = 0; i < 8; i++ )
            {
                randomizing_or_zeroing.set_array_value_to_zero( array );
    
                randomizing_or_zeroing.randomizing_array_elements(array, 9);
    
                subtracting_this_many_array_elements++;
                left_side = side( array, 9, subtracting_this_many_array_elements );
                //cout << "Left side value is: " << left_side << '\n';
    
                if (left_side <= 3)
                {
                    //cout << "____________________________________\n";
    
                    //cout << "Took a step\n";
                    value = 1;
                    *I_took_a_step += 1;
                    //Beep(1568, 500);
    
                    break;
                }
                else
                {
                    value = 0;
                }
                //cout << '\n';
            }
            left_or_right [ which_string_element ] = "left";
        }
        else if ( right_side > left_side )
        {
            for ( int i = 0; i < 8; i++ )
            {
                randomizing_or_zeroing.set_array_value_to_zero( array );
    
                randomizing_or_zeroing.randomizing_array_elements(array, 9);
    
                subtracting_this_many_array_elements++;
                right_side = side( array, 9, subtracting_this_many_array_elements );
                //cout << "Right side value is: " << right_side << '\n';
    
                if (right_side <= 3)
                {
                    //cout << "____________________________________\n";
                    //cout << "Took a step\n";
                    value = 1;
                    *I_took_a_step += 1;
                    //Beep(523,500); // 523 hertz (C5) for 500 milliseconds
                    break;
                }
                else
                {
                    value = 0;
                }
    
                //cout << '\n';
            }
            left_or_right [ which_string_element ] = "right";
        }
    
        return value;
    }
    
    int CountingTheFourDirections::testing_four_directions(int counter[], string left_or_right[], int which_string_element)
    {
        int array[ 9 ];
    
        int I_took_a_step = 0;
    
        int subtracting_this_many_array_elements = 0;
    
        ArrayZeroRandom randomizing_or_zeroing;
    
        for ( int i = 0; i < 9; i++ )
        {
            randomizing_or_zeroing.set_array_value_to_zero( array );
    
            randomizing_or_zeroing.randomizing_array_elements(array, 9);
            int left_side = side( array, 9 , subtracting_this_many_array_elements);
    
            randomizing_or_zeroing.set_array_value_to_zero( array );
    
            randomizing_or_zeroing.randomizing_array_elements(array, 9);
            int right_side = side( array, 9, subtracting_this_many_array_elements );
    
            while ( left_side == right_side )
            {
                randomizing_or_zeroing.set_array_value_to_zero( array );
    
                randomizing_or_zeroing.randomizing_array_elements(array, 9);
                left_side = side( array, 9 , subtracting_this_many_array_elements);
    
                randomizing_or_zeroing.set_array_value_to_zero( array );
    
                randomizing_or_zeroing.randomizing_array_elements(array, 9);
                right_side = side( array, 9, subtracting_this_many_array_elements );
            }
    
            int step_counter = do_this_if_left_or_right_is_greater(array, left_or_right, &I_took_a_step, left_side, right_side, subtracting_this_many_array_elements, which_string_element);
            counter[ i ] = step_counter;
        }
        return I_took_a_step;
    }
    
    int CountingTheFourDirections::which_direction_is_lowest(string lowest_value_feeler[], int north, int south, int east, int west, int feeler, int element)
    {
        int direction_value = 0;
        if ( north < south && north < east && north < west )
        {
            lowest_value_feeler[ element ] = "north";
            direction_value = 1;
        }
        else if ( south < north && south < east && south < west )
        {
            lowest_value_feeler[ element ] = "south";
            direction_value = 2;
        }
        else if ( east < north && east < south && east < west )
        {
            lowest_value_feeler[ element ] = "east";
            direction_value = 3;
        }
        else if ( west < north && west < south && west < east )
        {
            lowest_value_feeler[ element ] = "west";
            direction_value = 4;
        }
        else if ( north == south && north == east && north == west )
        {
            lowest_value_feeler[ element ] = "no_lowest_direction.";
            direction_value = 5;
        }
        else if ( north == east && north == south )
        {
            lowest_value_feeler[ element ] = "north_east_south.";
            direction_value = 6;
        }
        else if ( east == south && east == west )
        {
            lowest_value_feeler[ element ] = "east_south_west.";
            direction_value = 7;
        }
        else if ( south == west && south == north )
        {
            lowest_value_feeler[ element ] = "south_west_north.";
            direction_value = 8;
        }
        else if ( west == north && west == east )
        {
            lowest_value_feeler[ element ] = "west_north_east.";
            direction_value = 9;
        }
        else if ( north == east )
        {
            lowest_value_feeler[ element ] = "north_east.";
            direction_value = 10;
        }
        else if ( east == south )
        {
            lowest_value_feeler[ element ] = "east_south.";
            direction_value = 11;
        }
        else if ( south == west )
        {
            lowest_value_feeler[ element ] = "south_west.";
            direction_value = 12;
        }
        else if ( west == north )
        {
            lowest_value_feeler[ element ] = "west_north.";
            direction_value = 13;
        }
        else if ( west == east )
        {
            lowest_value_feeler[ element ] = "west_east.";
            direction_value = 14;
        }
        else if ( north == south )
        {
            lowest_value_feeler[ element ] = "north_south.";
            direction_value = 15;
        }
        else if ( north == east && north > south && north > west )
        {
            lowest_value_feeler[ element ] = "north_east";
            direction_value = 16;
        }
    
        else if ( north == west && north > east && north > south )
        {
            lowest_value_feeler[ element ] = "north_west";
            direction_value = 17;
        }
        else if ( north == south && north > east && north > west )
        {
            lowest_value_feeler[ element ] = "north_south";
            direction_value = 18;
        }
        else if ( east == west && east > north && east > south )
        {
            lowest_value_feeler[ element ] = "east_west";
            direction_value = 19;
        }
        else if ( east == south && east > north && east > west )
        {
            lowest_value_feeler[ element ] = "east_south";
            direction_value = 20;
        }
        else if ( west == south && west > north && west > east )
        {
            lowest_value_feeler[ element ] = "west_south";
            direction_value = 21;
        }
    
        return direction_value;
    }
    
    void CountingTheFourDirections::displaying_which_direction_is_lowest( int lowest_value_array[], int direction_value, int feeler )
    {
    
        if ( direction_value == 1 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 2 )
        {
            cout << "Feeler " << feeler << " the lowest value is the south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 3 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 4 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 5 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, south, east, west direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, south, east, west direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 6 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, east, south direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, east, south direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 7 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, south, west direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, south, west direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 8 )
        {
            cout << "Feeler " << feeler << " the lowest value is the south, west, north direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the south, west, north direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 9 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, north, east direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, north, east direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 10 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, east direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, east direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 11 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, south direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, south direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 12 )
        {
            cout << "Feeler " << feeler << " the lowest value is the south, west direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the south, west direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 13 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, north direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, north direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 14 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, east direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, east direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 15 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 16 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, east direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, east direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 17 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, west direction, so north is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, west direction, so north is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 18 )
        {
            cout << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the north, south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 19 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, west direction, so east is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, west direction, so east is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 20 )
        {
            cout << "Feeler " << feeler << " the lowest value is the east, south direction, so south is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the east, south direction, so south is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
        else if ( direction_value == 21 )
        {
            cout << "Feeler " << feeler << " the lowest value is the west, south direction, so west is blocked." << "\n";
            cout << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the displaying_which_direction_is_lowest function" << endl;
            }
            else
            {
                file << "Feeler " << feeler << " the lowest value is the west, south direction, so west is blocked." << "\n";
                file << "Array element zero is: " << lowest_value_array[ 0 ] << " value\n\n";
            }
    
            file.close();
        }
    }
    
    void CountingTheFourDirections::used_in_setting_feeler_to_new_value ( string left_or_right[],
                                               string lowest_value_feeler[],
                                               int lowest_value_array[],
                                               int north_array[],
                                               int south_array[],
                                               int east_array[],
                                               int west_array[],
                                               string *lowest_value_array_direction,
                                               int *north_count,
                                               int *south_count,
                                               int *east_count,
                                               int *west_count,
                                               int *left_or_right_1,
                                               int *left_or_right_2,
                                               int *left_or_right_3,
                                               int *left_or_right_4,
                                               int *feeler,
                                               int *element )
    {
        int direction_value = 0;
        ArrayZeroRandom randomizing_or_zeroing;
    
        randomizing_or_zeroing.set_array_value_to_zero( north_array );
    
        randomizing_or_zeroing.set_array_value_to_zero( south_array );
    
        randomizing_or_zeroing.set_array_value_to_zero( east_array );
    
        randomizing_or_zeroing.set_array_value_to_zero( west_array );
        randomizing_or_zeroing.set_array_value_to_zero( lowest_value_array );
    
        left_or_right[ *left_or_right_1 ] = "";
        left_or_right[ *left_or_right_2 ] = "";
        left_or_right[ *left_or_right_3 ] = "";
        left_or_right[ *left_or_right_4 ] = "";
    
        *north_count = testing_four_directions(north_array, left_or_right, *left_or_right_1);
        *south_count = testing_four_directions(south_array, left_or_right, *left_or_right_2);
        *east_count = testing_four_directions(east_array, left_or_right, *left_or_right_3);
        *west_count = testing_four_directions(west_array, left_or_right, *left_or_right_4);
        direction_value = which_direction_is_lowest(lowest_value_feeler,
                                                    *north_count,
                                                    *south_count,
                                                    *east_count,
                                                    *west_count,
                                                    *feeler, *element);
    
        direction_value_array_transfer_value_to_new_array ( lowest_value_array,
                                                           lowest_value_array_direction,
                                                            north_array,
                                                            south_array,
                                                            east_array,
                                                            west_array,
                                                            &direction_value);
    
        displaying_which_direction_is_lowest( lowest_value_array, direction_value, *feeler );
    
    
    }
    
    void CountingTheFourDirections::direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest( string lowest_value_feeler[],
                                                                                                                                             int lowest_value_array[],
                                          int north_array[],
                                          int south_array[],
                                          int east_array[],
                                          int west_array[],
                                          string *lowest_value_array_direction,
                                          int *north_count,
                                          int *south_count,
                                          int *east_count,
                                          int *west_count,
                                          int *feeler,
                                          int *element,
                                          int *direction_value )
    {
    
        *direction_value = which_direction_is_lowest(lowest_value_feeler,
                                                    *north_count,
                                                    *south_count,
                                                    *east_count,
                                                    *west_count,
                                                    *feeler,
                                                    *element);
    
        direction_value_array_transfer_value_to_new_array ( lowest_value_array,
                                                           lowest_value_array_direction,
                                                            north_array,
                                                            south_array,
                                                            east_array,
                                                            west_array,
                                                            direction_value);
    
        displaying_which_direction_is_lowest( lowest_value_array, *direction_value, *feeler );
    
    }
    Code:
    #include "howmanysteps.h"
    #include <iostream>
    #include <fstream>
    using namespace std;
    
    
    void HowManySteps::display_number_of_steps_message(int north, int south, int east, int west, int which_feeler)
    {
        cout << "Values with feeler "<< which_feeler << "\n";
        cout << "I tried to take 9 steps in the north direction, but I actual took " << north << " steps.\n";
        cout << "I tried to take 9 steps in the south direction, but I actual took " << south << " steps.\n";
        cout << "I tried to take 9 steps in the east direction, but I actual took " << east << " steps.\n";
        cout << "I tried to take 9 steps in the west direction, but I actual took " << west << " steps.\n";
    
        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
        if( file.fail() )
        {
            cout << "error while opening the file in the display_number_of_steps_message function" << endl;
        }
        else
        {
            file << endl;
            file << "Values with feeler "<< which_feeler << "\n";
            file << "I tried to take 9 steps in the north direction, but I actual took " << north << " steps.\n";
            file << "I tried to take 9 steps in the south direction, but I actual took " << south << " steps.\n";
            file << "I tried to take 9 steps in the east direction, but I actual took " << east << " steps.\n";
            file << "I tried to take 9 steps in the west direction, but I actual took " << west << " steps.\n";
            file << endl;
        }
    
        file.close();
    }
    Code:
    #include "insertionsort.h"
    #include <cstdlib>
    #include <ctime>
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    
    void InsertionSort::sort (int array[], int size)
    {
        for ( int i = 0; i < size; i++ )
        {
            int index = findSmallestRemainingElement( array, size, i );
            swap( array, i, index );
        }
    }
    
    int InsertionSort::findSmallestRemainingElement (int array[], int size, int index)
    {
        int index_of_smallest_value = index;
        for (int i = index + 1; i < size; i++)
        {
            if ( array[ i ] < array[ index_of_smallest_value ]  )
            {
                index_of_smallest_value = i;
            }
        }
        return index_of_smallest_value;
    }
    
    
    void InsertionSort::swap (int array[], int first_index, int second_index)
    {
        int temp = array[ first_index ];
        array[ first_index ] = array[ second_index ];
        array[ second_index ] = temp;
    }
    
    // small helper method to display the before and after arrays
    void InsertionSort::displayArray (int array[], int size)
    {
        cout << "{";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "{";
            }
    
            file.close();
        }
    
        for ( int i = 0; i < size; i++ )
        {
            // you'll see this pattern a lot for nicely formatting
            // lists--check if we're past the first element, and
            // if so, append a comma
            if ( i != 0 )
            {
                cout << ", ";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << ", ";
                    }
    
                    file.close();
                }
    
            }
            cout << array[ i ];
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the main function" << endl;
                }
                else
                {
                    file << array[ i ];
                }
    
                file.close();
            }
        }
        cout << "}";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "}";
            }
    
            file.close();
        }
    }
    Code:
    #include "makingstringarraysequal.h"
    #include <string>
    
    using namespace std;
    
    void MakingStringArraysEqual::set_one_string_array_equal_to_another_string_array ( string array[], string array2[] )
    {
        for ( int i = 0; i < 4; i++ )
        {
            array[ i ] = array2[ i ];
        }
    }
    Code:
    #include "music.h"
    #include <iostream>
    #include <fstream>
    #include <windows.h> // WinApi header
    
    using namespace std;
    
    void music::listening_to_the_sound_made_by_the_array()
    {
        StackLayerInfo stack_data;
        int zero_counter = 0;
        int one_counter = 0;
    
    
        int i;
        int counter = 0;
        int counter_to_add_new_sound = 0;
    
        ifstream input("array_used_for_sound.txt");
    
        if( input.fail() )
        {
            cout << "error while opening the file in the main function" << endl;
        }
    
        cout << "\nListen...";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\nListen...";
            }
    
            file.close();
        }
    
        while ( input >> i)
        {
            counter_to_add_new_sound += 1;
            counter += 1;
    
            if( counter == 2)
            {
                Sleep( 400 );
            }
            else if ( counter == 4 )
            {
                Sleep( 250 );
            }
            if ( counter_to_add_new_sound  == 4 )
            {
                Beep(400,210);
                Beep(500,210);
                Beep(600,210);
            }
            else if ( counter_to_add_new_sound  == 8 )
            {
                Beep(400,210);
                Beep(500,210);
                Beep(600,210);
            }
            else if ( counter_to_add_new_sound  == 12 )
            {
                Beep(400,210);
                Beep(500,210);
                Beep(600,210);
    
            }
            else if ( counter_to_add_new_sound  == 16 )
            {
                Beep(1000,210);
                Beep(1100,210);
                Beep(1200,210);
                counter_to_add_new_sound = 0;
            }
    
    
            if ( i == 0 )
            {
                zero_counter += 1;
                Beep(400,150);
            }
            else if ( i == 1 )
            {
                one_counter += 1;
                Beep(900, 150);
            }
                counter = 0;
        }
    
        input.close();
    
        cout << "I can hear it!\n\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "I can hear it!\n\n";
            }
    
            file.close();
        }
    
        for ( int i = 0; i < zero_counter; i+= 1 )
        {
            Beep(400,150);
        }
    
        for ( int i = 0; i < one_counter; i+= 1 )
        {
            Beep(900, 150);
        }
    
        stack_data.reading_the_results_of_listening_to_the_sound_made_by_the_array_function( &zero_counter, &one_counter );
    }
    Code:
    #include "settingarrayelementzero.h"
    
    
    
    void SettingArrayElementZero::fourth_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_6[],
                                                              int lowest_value_array_feeler_2_try_6[],
                                                              int north_array_2_try_6_one_and_odd[],
                                                              int south_array_2_try_6_one_and_odd[],
                                                              int east_array_2_try_6_one_and_odd[],
                                                              int west_array_2_try_6_one_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_6_one_and_odd,
                                                              int *south_count_array_2_try_6_one_and_odd,
                                                              int *east_count_array_2_try_6_one_and_odd,
                                                              int *west_count_array_2_try_6_one_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops)
    {
        CountingTheFourDirections directions_value;
        while ( 1 )
        {
            directions_value.used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_6,
                                                  lowest_value_array_feeler_2_try_6,
                                                  north_array_2_try_6_one_and_odd,
                                                  south_array_2_try_6_one_and_odd,
                                                  east_array_2_try_6_one_and_odd,
                                                  west_array_2_try_6_one_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_6_one_and_odd,
                                                  south_count_array_2_try_6_one_and_odd,
                                                  east_count_array_2_try_6_one_and_odd,
                                                  west_count_array_2_try_6_one_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_6[ 0 ] == 1)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                    *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
            }
        }
    
    
    }
    
    void SettingArrayElementZero::third_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_5[],
                                                              int lowest_value_array_feeler_2_try_5[],
                                                              int north_array_2_try_5_one_and_odd[],
                                                              int south_array_2_try_5_one_and_odd[],
                                                              int east_array_2_try_5_one_and_odd[],
                                                              int west_array_2_try_5_one_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_5_one_and_odd,
                                                              int *south_count_array_2_try_5_one_and_odd,
                                                              int *east_count_array_2_try_5_one_and_odd,
                                                              int *west_count_array_2_try_5_one_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops)
    {
        CountingTheFourDirections directions_value;
        while ( 1 )
        {
            directions_value.used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_5,
                                                  lowest_value_array_feeler_2_try_5,
                                                  north_array_2_try_5_one_and_odd,
                                                  south_array_2_try_5_one_and_odd,
                                                  east_array_2_try_5_one_and_odd,
                                                  west_array_2_try_5_one_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_5_one_and_odd,
                                                  south_count_array_2_try_5_one_and_odd,
                                                  east_count_array_2_try_5_one_and_odd,
                                                  west_count_array_2_try_5_one_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_5[ 0 ] == 0)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                    *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
            }
        }
    
    
    }
    
    int SettingArrayElementZero::setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( string left_or_right[],
                                                               string lowest_value_feeler_2_try_4[],
                                                               int lowest_value_array_feeler_2_try_4[],
                                                               int north_array_2_try_4_zero_and_even[],
                                                               int south_array_2_try_4_zero_and_even[],
                                                               int east_array_2_try_4_zero_and_even[],
                                                               int west_array_2_try_4_zero_and_even[],
                                                               string *feeler_1_lowest_value_array_direction,
                                                               string *feeler_2_lowest_value_array_direction,
                                                               string *did_second_feeler_work,
                                                               int *north_count_array_2_try_4_zero_and_even,
                                                               int *south_count_array_2_try_4_zero_and_even,
                                                               int *east_count_array_2_try_4_zero_and_even,
                                                               int *west_count_array_2_try_4_zero_and_even,
                                                               int *left_or_right_1,
                                                               int *left_or_right_2,
                                                               int *left_or_right_3,
                                                               int *left_or_right_4,
                                                               int *feeler,
                                                               int *element,
                                                               int *the_number_of_loops)
    {
        CountingTheFourDirections directions_value;
        int counter = 0;
        while ( 1 )
        {
            counter = counter + 1;
            directions_value.used_in_setting_feeler_to_new_value ( left_or_right,
                                                      lowest_value_feeler_2_try_4,
                                                      lowest_value_array_feeler_2_try_4,
                                                      north_array_2_try_4_zero_and_even,
                                                      south_array_2_try_4_zero_and_even,
                                                      east_array_2_try_4_zero_and_even,
                                                      west_array_2_try_4_zero_and_even,
                                                      feeler_2_lowest_value_array_direction,
                                                      north_count_array_2_try_4_zero_and_even,
                                                      south_count_array_2_try_4_zero_and_even,
                                                      east_count_array_2_try_4_zero_and_even,
                                                      west_count_array_2_try_4_zero_and_even,
                                                      left_or_right_1,
                                                      left_or_right_2,
                                                      left_or_right_3,
                                                      left_or_right_4,
                                                      feeler,
                                                      element );
    
                if ( lowest_value_array_feeler_2_try_4[ 0 ] == 0)
                {
                    if ( *feeler_2_lowest_value_array_direction ==  *feeler_1_lowest_value_array_direction )
                    {
                        *the_number_of_loops += 1;
                        *did_second_feeler_work = "elements_are_equal";
    
                        return counter;
                    }
                }
                else
                {
                   *the_number_of_loops += 1;
                   *did_second_feeler_work = "elements_are_unequal";
                }
        }
    }
    
    void SettingArrayElementZero::second_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                               string lowest_value_feeler_2_try_3[],
                                                               int lowest_value_array_feeler_2_try_3[],
                                                               int north_array_2_try_3_zero_and_odd[],
                                                               int south_array_2_try_3_zero_and_odd[],
                                                               int east_array_2_try_3_zero_and_odd[],
                                                               int west_array_2_try_3_zero_and_odd[],
                                                               string *feeler_1_lowest_value_array_direction,
                                                               string *feeler_2_lowest_value_array_direction,
                                                               string *did_second_feeler_work,
                                                               int *north_count_array_2_try_3_zero_and_odd,
                                                               int *south_count_array_2_try_3_zero_and_odd,
                                                               int *east_count_array_2_try_3_zero_and_odd,
                                                               int *west_count_array_2_try_3_zero_and_odd,
                                                               int *left_or_right_1,
                                                               int *left_or_right_2,
                                                               int *left_or_right_3,
                                                               int *left_or_right_4,
                                                               int *feeler,
                                                               int *element,
                                                               int *the_number_of_loops)
    {
        CountingTheFourDirections directions_value;
        while ( 1 )
        {
            directions_value.used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_3,
                                                  lowest_value_array_feeler_2_try_3,
                                                  north_array_2_try_3_zero_and_odd,
                                                  south_array_2_try_3_zero_and_odd,
                                                  east_array_2_try_3_zero_and_odd,
                                                  west_array_2_try_3_zero_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_3_zero_and_odd,
                                                  south_count_array_2_try_3_zero_and_odd,
                                                  east_count_array_2_try_3_zero_and_odd,
                                                  west_count_array_2_try_3_zero_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_3[ 0 ] == 0)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                    *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
    
            }
        }
    }
    
    void SettingArrayElementZero::first_time_setting_feeler_two_element_zero_to_zero ( string left_or_right[],
                                                              string lowest_value_feeler_2_try_2[],
                                                              int lowest_value_array_feeler_2_try_2[],
                                                              int north_array_2_try_2_zero_and_odd[],
                                                              int south_array_2_try_2_zero_and_odd[],
                                                              int east_array_2_try_2_zero_and_odd[],
                                                              int west_array_2_try_2_zero_and_odd[],
                                                              string *feeler_1_lowest_value_array_direction,
                                                              string *feeler_2_lowest_value_array_direction,
                                                              string *did_second_feeler_work,
                                                              int *north_count_array_2_try_2_zero_and_odd,
                                                              int *south_count_array_2_try_2_zero_and_odd,
                                                              int *east_count_array_2_try_2_zero_and_odd,
                                                              int *west_count_array_2_try_2_zero_and_odd,
                                                              int *left_or_right_1,
                                                              int *left_or_right_2,
                                                              int *left_or_right_3,
                                                              int *left_or_right_4,
                                                              int *feeler,
                                                              int *element,
                                                              int *the_number_of_loops)
    
    
    
    {
        CountingTheFourDirections directions_value;
        while ( 1 )
        {
            directions_value.used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler_2_try_2,
                                                  lowest_value_array_feeler_2_try_2,
                                                  north_array_2_try_2_zero_and_odd,
                                                  south_array_2_try_2_zero_and_odd,
                                                  east_array_2_try_2_zero_and_odd,
                                                  west_array_2_try_2_zero_and_odd,
                                                  feeler_2_lowest_value_array_direction,
                                                  north_count_array_2_try_2_zero_and_odd,
                                                  south_count_array_2_try_2_zero_and_odd,
                                                  east_count_array_2_try_2_zero_and_odd,
                                                  west_count_array_2_try_2_zero_and_odd,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
            if ( lowest_value_array_feeler_2_try_2[ 0 ] == 0)
            {
                if ( *feeler_2_lowest_value_array_direction !=  *feeler_1_lowest_value_array_direction )
                {
                   *the_number_of_loops += 1;
                    *did_second_feeler_work = "elements_are_unequal";
                    break;
                }
            }
            else
            {
               *the_number_of_loops += 1;
               *did_second_feeler_work = "elements_are_equal";
            }
        }
    }
    
    void SettingArrayElementZero::setting_feeler_one_element_zero_to_zero ( string left_or_right[],
                                                      string lowest_value_feeler[],
                                                      int lowest_value_array[],
                                                      int north_array_1_try_2_zero[],
                                                      int south_array_1_try_2_zero[],
                                                      int east_array_1_try_2_zero[],
                                                      int west_array_1_try_2_zero[],
                                                      string *feeler_1_lowest_value_array_direction,
                                                      string *feeler_2_lowest_value_array_direction,
                                                      string *did_second_feeler_work,
                                                      int *north_count_array_1_try_2_zero,
                                                      int *south_count_array_1_try_2_zero,
                                                      int *east_count_array_1_try_2_zero,
                                                      int *west_count_array_1_try_2_zero,
                                                      int *left_or_right_1,
                                                      int *left_or_right_2,
                                                      int *left_or_right_3,
                                                      int *left_or_right_4,
                                                      int *feeler,
                                                      int *element,
                                                      int *the_number_of_loops)
    {
        CountingTheFourDirections directions_value;
        while ( 1 )
        {
            directions_value.used_in_setting_feeler_to_new_value ( left_or_right,
                                                  lowest_value_feeler,
                                                  lowest_value_array,
                                                  north_array_1_try_2_zero,
                                                  south_array_1_try_2_zero,
                                                  east_array_1_try_2_zero,
                                                  west_array_1_try_2_zero,
                                                  feeler_1_lowest_value_array_direction,
                                                  north_count_array_1_try_2_zero,
                                                  south_count_array_1_try_2_zero,
                                                  east_count_array_1_try_2_zero,
                                                  west_count_array_1_try_2_zero,
                                                  left_or_right_1,
                                                  left_or_right_2,
                                                  left_or_right_3,
                                                  left_or_right_4,
                                                  feeler,
                                                  element );
    
    
    
            if ( lowest_value_array[ 0 ] == 0 )
            {
                break;
            }
        }
    }
    Code:
    #include "stacklayerinfo.h"
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    
    void StackLayerInfo::display_message_about_stack_layer_part_two( int *stack_layer_one,
                                                     int *stack_layer_two,
                                                     int *stack_layer_three,
                                                     int *stack_layer_four)
    {
        if ( *stack_layer_one == 0 )
             {
                 cout << "- stack layer 1 value is too low\n";
                 cout << "meaning it went bad at catching the ball.\n";
    
                 {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "- stack layer 1 value is too low\n";
                        file << "meaning it went bad at catching the ball.\n";
                    }
    
                    file.close();
                }
             }
             if ( *stack_layer_two == 0 )
             {
                 cout << "- stack layer 2 value is too low\n";
    
                 {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "- stack layer 2 value is too low\n";
                    }
    
                    file.close();
                }
                 if ( *stack_layer_one > 0 )
                 {
                     cout << "meaning it went bad at controlling the ball once cought.\n";
    
                     {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "meaning it went bad at controlling the ball once cought.\n";
                        }
    
                        file.close();
                    }
                 }
             }
             if ( *stack_layer_three == 0 )
             {
                 cout << "- stack layer 3 value is too low\n";
    
                 {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "- stack layer 3 value is too low\n";
                    }
    
                    file.close();
                }
                 if ( (*stack_layer_one > 0) && (*stack_layer_two> 0) )
                 {
                     cout << "meaning it went bad at tossing the ball to the other hand to throw.\n";
    
                     {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "meaning it went bad at tossing the ball to the other hand to throw.\n";
                        }
    
                        file.close();
                    }
                 }
             }
             if ( *stack_layer_four == 0 )
             {
                 cout << "- stack layer 4 value is too low\n";
    
                 {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "- stack layer 4 value is too low\n";
                    }
    
                    file.close();
                }
                 if (  (*stack_layer_one > 0) && (*stack_layer_two> 0)  && (*stack_layer_three > 0 ) )
                 {
                     cout << "meaning it went bad at throwing the ball.\n\n";
    
                     {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "meaning it went bad at throwing the ball.\n\n";
                        }
    
                        file.close();
                    }
                 }
             }
    }
    
    void StackLayerInfo::display_message_about_stack_layer_part_one( int array[],
                                                     int *first_array_one_counter,
                                                     int *second_array_one_counter,
                                                     int *third_array_one_counter,
                                                     int *stack_layer_one,
                                                     int *stack_layer_two,
                                                     int *stack_layer_three,
                                                     int *stack_layer_four)
    {
        if ( (*first_array_one_counter == *second_array_one_counter) && (*first_array_one_counter == *third_array_one_counter) )
        {
            cout << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the main function" << endl;
                }
                else
                {
                    file << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
                }
    
                file.close();
            }
    
            int counter = 0;
    
            for ( int i = 0; i < 8; i++ )
            {
    
                counter += 1;
    
                if ( counter == 1 || counter == 2 )
                {
                    if ( array[ i ] == 1 )
                    {
                        *stack_layer_one += 1;
                    }
                }
                else if ( counter == 3 || counter == 4 )
                {
                    if ( array[ i ] == 1 )
                    {
                        *stack_layer_two += 1;
                    }
                }
                else if ( counter == 5 || counter == 6 )
                {
                    if ( array[ i ] == 1 )
                    {
                        *stack_layer_three += 1;
                    }
                }
                else if ( counter == 7 || counter == 8 )
                {
                    if ( array[ i ] == 1 )
                    {
                        *stack_layer_four += 1;
                    }
                }
            }
    
        }
    
        if ( (*first_array_one_counter == *second_array_one_counter) && (*first_array_one_counter < *third_array_one_counter) )
            {
                cout << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 0; i < 8; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
    
            }
    
            if ( (*first_array_one_counter == *second_array_one_counter) && (*first_array_one_counter > *third_array_one_counter) )
            {
                cout << "\nThird array needs to change one or more stack layers to a higher one value.\n\n";
                cout << "\nThis is the right most array on the binary search tree\n";
                cout << "That means did you score phase\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nThird array needs to change one or more stack layers to a higher one value.\n\n";
                        file << "\nThis is the second right most array on the binary search tree\n";
                        cout << "That means did you score phase\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 18; i < 26; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
            }
    
            if ( (*first_array_one_counter == *third_array_one_counter) && (*first_array_one_counter < *second_array_one_counter) )
            {
                cout << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 0; i < 8; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
            }
    
            if ( (*first_array_one_counter == *third_array_one_counter) && (*first_array_one_counter > *second_array_one_counter) )
            {
                cout << "\nSecond array needs to change one or more stack layers to a higher one value.\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nSecond array needs to change one or more stack layers to a higher one value.\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 9; i < 17; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
            }
    
            if ( (*third_array_one_counter == *second_array_one_counter ) && (*first_array_one_counter < *second_array_one_counter )  )
            {
                cout << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 0; i < 8; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
            }
    
            if ( (*third_array_one_counter == *second_array_one_counter ) && (*first_array_one_counter > *second_array_one_counter )  )
            {
                cout << "\nSecond array needs to change one or more stack layers to a higher one value.\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nSecond array needs to change one or more stack layers to a higher one value.\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 9; i < 17; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
            }
    
        if ( (*first_array_one_counter < *second_array_one_counter) && (*first_array_one_counter < *third_array_one_counter) )
            {
                cout << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
                cout << "\nThis is the left most array on the binary search tree\n";
                cout << "That means this is the catch and control phase\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nFirst array needs to change one or more stack layers to a higher one value.\n\n";
                        file << "\nThis is the left most array on the binary search tree\n";
                        file << "That means this is the catch and control phase\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 0; i < 8; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
    
            }
    
            if ( (*second_array_one_counter < *first_array_one_counter  ) && (*second_array_one_counter < *third_array_one_counter  ) )
            {
                cout << "\nSecond array needs to change one or more stack layers to a higher one value.\n\n";
                cout << "\nThis is the second right most array on the binary search tree\n";
                cout << "That means this is the catch and shoot the puck phase\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nSecond array needs to change one or more stack layers to a higher one value.\n\n";
                        file << "\nThis is the second right most array on the binary search tree\n";
                        file << "That means this is the catch and shoot the puck phase\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 9; i < 17; i++ )
                {
    
                    counter += 1;
    
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
            }
            if ( (*third_array_one_counter < *first_array_one_counter  ) && (*third_array_one_counter < *second_array_one_counter) )
            {
                cout << "\nThird array needs to change one or more stack layers to a higher one value.\n\n";
                cout << "\nThis is the right most array on the binary search tree\n";
                cout << "That means did you score phase\n\n";
    
                {
                    fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                    if( file.fail() )
                    {
                        cout << "error while opening the file in the main function" << endl;
                    }
                    else
                    {
                        file << "\nThird array needs to change one or more stack layers to a higher one value.\n\n";
                        file << "\nThis is the second right most array on the binary search tree\n";
                        cout << "That means did you score phase\n\n";
                    }
    
                    file.close();
                }
    
                int counter = 0;
    
                for ( int i = 18; i < 26; i++ )
                {
    
                    counter += 1;
    
                    if ( counter == 1 || counter == 2 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_one += 1;
                        }
                    }
                    else if ( counter == 3 || counter == 4 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_two += 1;
                        }
                    }
                    else if ( counter == 5 || counter == 6 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_three += 1;
                        }
                    }
                    else if ( counter == 7 || counter == 8 )
                    {
                        if ( array[ i ] == 1 )
                        {
                            *stack_layer_four += 1;
                        }
                    }
                }
            }
    }
    
    void StackLayerInfo::reading_the_results_of_listening_to_the_sound_made_by_the_array_function ( int *zero_counter, int *one_counter )
    {
    
        ifstream input("array_used_for_sound.txt");
        if( input.fail() )
        {
            cout << "error while opening the file in the main function" << endl;
        }
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
        cout << "counting 27 array elements to find 1, 0, value...\n\nresults\n";
        cout << "zero = " << *zero_counter << '\n';
        cout << "one = " << *one_counter << '\n';
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                file << "counting 27 array elements to find 1, 0, value...\n\nresults\n";
                file << "zero = " << *zero_counter << '\n';
                file << "one = " << *one_counter << '\n';
            }
    
            file.close();
        }
    
        if ( *one_counter > *zero_counter )
        {
            cout << "\none is greater, \nmeaning the winning team actually won in real life.\n\n";
    
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the main function" << endl;
                }
                else
                {
                    file << "\none is greater, \nmeaning the winning team actually won in real life.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
        }
        else
        {
            cout << "\none is less than or equal to zero value,\nmeaning the winning team actually lost in real life.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the main function" << endl;
                }
                else
                {
                    file << "\none is less than or equal to zero value,\nmeaning the winning team actually lost in real life.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
            int first_array_one_counter = 0;
            int first_array_zero_counter = 0;
    
            int second_array_one_counter = 0;
            int second_array_zero_counter = 0;
    
            int third_array_one_counter = 0;
            int third_array_zero_counter = 0;
    
            int array[ 27 ];
    
            // reading 27 numbers from array file into array so I can count the three arrays zero one values
            for ( int i = 0; i < 27; i++ )
            {
                input >> array[ i ];
            }
    
            // input array that does not match the generated array
            for ( int i = 0; i < 8; i++ )
            {
                if ( array [ i ] == 0 )
                {
                    first_array_zero_counter++;
                }
                else if ( array [ i ] == 1 )
                {
                    first_array_one_counter++;
                }
            }
    
            // input array that matches the generated array
            for ( int i = 9; i < 17; i++ )
            {
                if ( array [ i ] == 0 )
                {
                    second_array_zero_counter++;
                }
                else if ( array [ i ] == 1 )
                {
                    second_array_one_counter++;
                }
            }
    
            // the generated output array
            for ( int i = 18; i < 26; i++ )
            {
                if ( array [ i ] == 0 )
                {
                    third_array_zero_counter++;
                }
                else if ( array [ i ] == 1 )
                {
                    third_array_one_counter++;
                }
            }
    
            cout << "\ncounting 24 array elements, not 27\n";
    
            cout << "\n# of 0 in first array = " << first_array_zero_counter << '\n';
            cout << "# of 1 in first array = " << first_array_one_counter << '\n';
    
            cout << "\n# of 0 in second array = " << second_array_zero_counter << '\n';
            cout << "# of 1 in second array = " << second_array_one_counter << '\n';
    
            cout << "\n# of 0 in third array = " << third_array_zero_counter << '\n';
            cout << "# of 1 in third array = " << third_array_one_counter << '\n';
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the main function" << endl;
                }
                else
                {
                    file << "\ncounting 24 array elements, not 27\n";
    
                    file << "\n# of 0 in first array = " << first_array_zero_counter << '\n';
                    file << "# of 1 in first array = " << first_array_one_counter << '\n';
    
                    file << "\n# of 0 in second array = " << second_array_zero_counter << '\n';
                    file << "# of 1 in second array = " << second_array_one_counter << '\n';
    
                    file << "\n# of 0 in third array = " << third_array_zero_counter << '\n';
                    file << "# of 1 in third array = " << third_array_one_counter << '\n';
                }
    
                file.close();
            }
    
            int stack_layer_one = 0;
            int stack_layer_two = 0;
            int stack_layer_three = 0;
            int stack_layer_four = 0;
    
            display_message_about_stack_layer_part_one( array,
                                                       &first_array_one_counter,
                                                        &second_array_one_counter,
                                                        &third_array_one_counter,
                                                        &stack_layer_one,
                                                        &stack_layer_two,
                                                        &stack_layer_three,
                                                        &stack_layer_four);
    
            cout << "\nWhich stack layer needs to be changed?\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the main function" << endl;
                }
                else
                {
                    file << "\nWhich stack layer needs to be changed?\n\n";
                }
    
                file.close();
            }
    
             display_message_about_stack_layer_part_two( &stack_layer_one,
                                                         &stack_layer_two,
                                                         &stack_layer_three,
                                                         &stack_layer_four);
    
             cout << "\nstack layer 1 value: " << stack_layer_one << '\n';
             cout << "\nstack layer 2 value: " << stack_layer_two << '\n';
             cout << "\nstack layer 3 value: " << stack_layer_three << '\n';
             cout << "\nstack layer 4 value: " << stack_layer_four << '\n' << '\n';
    
             {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the main function" << endl;
                }
                else
                {
                    file << "\nstack layer 1 value: " << stack_layer_one << '\n';
                    file << "\nstack layer 2 value: " << stack_layer_two << '\n';
                    file << "\nstack layer 3 value: " << stack_layer_three << '\n';
                    file << "\nstack layer 4 value: " << stack_layer_four << '\n' << '\n';
                }
    
                file.close();
            }
        }
    
        input.close();
    
    }
    Code:
    #include "startprogram.h"
    #include <string>
    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    
    using namespace std;
    
    void StartProgram::running_the_two_main_functions( int compare_to_output_array_1[],
                                        int compare_to_output_array_2[],
                                        int the_random_list_generated_by_the_left_node_results_array[],
                                        int *try_again,
                                        int *good_job )
    {
        string lowest_value_feeler_1_try_1[ 9 ];
        string lowest_value_feeler_1_try_2[ 9 ];
        string left_or_right[ 4 ];
        int north_array[ 9 ];
        int south_array[ 9 ];
        int east_array[ 9 ];
        int west_array[ 9 ];
        string feeler_1_lowest_value_array_direction = "";
        string feeler_one_element_zero_equal = "";
        int north_count_1 = 0;
        int south_count_1 = 0;
        int east_count_1 = 0;
        int west_count_1 = 0;
        int less_than_node = 0;
        int result_of_left_node_test = 0;
        TheFunctionPartOne first_half;
        TheFunctionPartTwo second_half;
        TestResultsOfTheTwoMainFunctions test_results;
    
            while ( 1 )
        {
            north_count_1 = 0;
            south_count_1 = 0;
            east_count_1 = 0;
            west_count_1 = 0;
            less_than_node = 0;
            result_of_left_node_test = 0;
            int counting_matching_array_elements_1 = 0;
            int counting_matching_array_elements_2 = 0;
            int counting_left_nodes_1 = 0;
            int counting_left_nodes_2 = 0;
    
            for ( int i = 0; i < 9; i++ )
            {
                first_half.the_master_function_part_one(lowest_value_feeler_1_try_1,
                                         lowest_value_feeler_1_try_2,
                                         left_or_right,
                                         north_array,
                                         south_array,
                                         east_array,
                                         west_array,
                                         &feeler_one_element_zero_equal,
                                         &feeler_1_lowest_value_array_direction,
                                         &north_count_1,
                                         &south_count_1,
                                         &east_count_1,
                                         &west_count_1,
                                         &less_than_node);
    
            second_half.the_master_function_part_two(lowest_value_feeler_1_try_1,
                                         lowest_value_feeler_1_try_2,
                                         left_or_right,
                                         north_array,
                                         south_array,
                                         east_array,
                                         west_array,
                                         &feeler_one_element_zero_equal,
                                         &feeler_1_lowest_value_array_direction,
                                         &north_count_1,
                                         &south_count_1,
                                         &east_count_1,
                                         &west_count_1,
                                         &less_than_node,
                                         &result_of_left_node_test);
    
            the_random_list_generated_by_the_left_node_results_array[ i ] = result_of_left_node_test;
            }
    
            for ( int i = 0; i < 9; i++ )
            {
                // keep the numbers small so they're easy to read
                compare_to_output_array_2[ i ] = rand() % 2;
            }
    
            for ( int i = 0; i < 9; i++ )
            {
                // counting left nodes in the 2 arrays
                if ( compare_to_output_array_1[ i ] == 0 )
                {
                    counting_left_nodes_1 += 1;
                }
                if ( compare_to_output_array_2[ i ] == 0 )
                {
                    counting_left_nodes_2 += 1;
                }
    
                // comparing the elements of the two arrays to the results array to find matching elements
                if (compare_to_output_array_1[ i ] == the_random_list_generated_by_the_left_node_results_array [ i ] )
                {
                    counting_matching_array_elements_1 += 1;
                }
                if (compare_to_output_array_2[ i ] == the_random_list_generated_by_the_left_node_results_array[ i ] )
                {
                    counting_matching_array_elements_2 += 1;
                }
            }
    
            int break_or_not = test_results.displaying_the_test_results_from_running_the_two_main_function(
                                                                        compare_to_output_array_1,
                                                                        compare_to_output_array_2,
                                                                        the_random_list_generated_by_the_left_node_results_array,
                                                                        &counting_matching_array_elements_1,
                                                                        &counting_matching_array_elements_2,
                                                                        &counting_left_nodes_1,
                                                                        &counting_left_nodes_2,
                                                                        try_again,
                                                                        good_job);
    
            if ( break_or_not == 1 )
            {
                break;
            }
        }
    }
    Code:
    #include "testresultsofthetwomainfunctions.h"
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    
    void TestResultsOfTheTwoMainFunctions::writing_array_to_file_to_listen_to_after_program_ends( int array[])
    {
        for ( int i = 0; i < 9; i++ )
        {
            fstream file("array_used_for_sound.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << array[ i ] << endl;
            }
    
            file.close();
        }
    }
    
    int TestResultsOfTheTwoMainFunctions::displaying_the_test_results_from_running_the_two_main_function(
                                                                       int compare_to_output_array_1[],
                                                                       int compare_to_output_array_2[],
                                                                       int the_random_list_generated_by_the_left_node_results_array[],
                                                                       int *counting_matching_array_elements_1,
                                                                       int *counting_matching_array_elements_2,
                                                                       int *counting_left_nodes_1,
                                                                       int *counting_left_nodes_2,
                                                                       int *try_again,
                                                                       int *good_job)
    {
        InsertionSort function_in_InsertionSort;
        int break_or_not = 0;
    
        if ( *counting_matching_array_elements_1 > *counting_matching_array_elements_2 )
            {
                if ( *counting_left_nodes_1 < *counting_left_nodes_2 )
                {
    
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was met: Good job!.\n\n";
                    cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was met: Good job!.\n\n";
                            file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    function_in_InsertionSort.displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
    
                    writing_array_to_file_to_listen_to_after_program_ends( compare_to_output_array_2);
                    writing_array_to_file_to_listen_to_after_program_ends( compare_to_output_array_1);
                    writing_array_to_file_to_listen_to_after_program_ends( the_random_list_generated_by_the_left_node_results_array);
                    function_in_InsertionSort.displayArray( compare_to_output_array_1, 9 );
                    *good_job += 1;
                    break_or_not = 1;
                }
                else
                {
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was not met: Try again.\n\n";
                    cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was not met: Try again.\n\n";
                            file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    function_in_InsertionSort.displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    function_in_InsertionSort.displayArray( compare_to_output_array_1, 9 );
    
                    *try_again += 1;
                }
            }
            else if ( *counting_matching_array_elements_2 > *counting_matching_array_elements_1 )
            {
                if ( *counting_left_nodes_2 < *counting_left_nodes_1 )
                {
                    cout << "The goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was met: Good job!.\n\n";
                    cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "The goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was met: Good job!.\n\n";
                            file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    function_in_InsertionSort.displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    writing_array_to_file_to_listen_to_after_program_ends( compare_to_output_array_1);
                    writing_array_to_file_to_listen_to_after_program_ends( compare_to_output_array_2);
                    writing_array_to_file_to_listen_to_after_program_ends( the_random_list_generated_by_the_left_node_results_array);
                    function_in_InsertionSort.displayArray( compare_to_output_array_2, 9 );
                    *good_job += 1;
                    break_or_not = 1;
                }
                else
                {
                    cout << "\nThe goal is to match the results array to the input array\n";
                    cout << "with the least left nodes.\n";
                    cout << "That goal was not met: Try again.\n\n";
                    cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                    cout << "This is the results generated array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << "\nThe goal is to match the results array to the input array\n";
                            file << "with the least left nodes.\n";
                            file << "That goal was not met: Try again.\n\n";
                            file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                            file << "This is the results generated array:\n";
                        }
    
                        file.close();
                    }
    
                    function_in_InsertionSort.displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
                    cout << '\n';
                    cout << "\nThis is the best matching input array:\n";
    
                    {
                        fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                        if( file.fail() )
                        {
                            cout << "error while opening the file in the main function" << endl;
                        }
                        else
                        {
                            file << '\n';
                            file << "\nThis is the best matching input array:\n";
                        }
    
                        file.close();
                    }
    
                    function_in_InsertionSort.displayArray( compare_to_output_array_2, 9 );
                    *try_again += 1;
                }
            }
    
            return break_or_not;
    }
    Code:
    #include "thefunctionpartone.h"
    #include <iostream>
    #include <string>
    #include <fstream>
    
    using namespace std;
    
    void TheFunctionPartOne::the_master_function_part_one ( string lowest_value_feeler_1_try_1[],
                                       string lowest_value_feeler_1_try_2[],
                                       string main_left_or_right[],
                                       int main_north_array[],
                                       int main_south_array[],
                                       int main_east_array[],
                                       int main_west_array[],
                                       string *feeler_one_element_zero_equal,
                                       string *feeler_1_lowest_value_array_direction,
                                       int *main_north_count,
                                       int *main_south_count,
                                       int *main_east_count,
                                       int *main_west_count,
                                       int *less_than_node)
    {
        string left_or_right[ 20 ];
        string lowest_value_feeler_2_try_1[ 9 ];
        string lowest_value_feeler_2_try_2[ 9 ];
        string lowest_value_feeler_2_try_3[ 9 ];
        string lowest_value_feeler_2_try_4[ 9 ];
        string lowest_value_feeler_2_try_5[ 9 ];
        string feeler_2_lowest_value_array_direction = "";
        string did_second_feeler_work = "";
        int lowest_value_array_feeler_1_try_1[ 9 ];
        int lowest_value_array_feeler_1_try_2[ 9 ];
        int lowest_value_array_feeler_2_try_1[ 9 ];
        int lowest_value_array_feeler_2_try_2[ 9 ];
        int lowest_value_array_feeler_2_try_4[ 9 ];
        int lowest_value_array_feeler_2_try_5[ 9 ];
        int direction_value = 0;
        int feeler = 0;
        int element = 0;
        int left_or_right_1 = 0;
        int left_or_right_2 = 0;
        int left_or_right_3 = 0;
        int left_or_right_4 = 0;
        int north_array_1[ 9 ];
        int south_array_1[ 9 ];
        int east_array_1[ 9 ];
        int west_array_1[ 9 ];
        int north_array_2[ 9 ];
        int south_array_2[ 9 ];
        int east_array_2[ 9 ];
        int west_array_2[ 9 ];
    
        int north_array_1_try_2_zero[ 9 ];
        int south_array_1_try_2_zero[ 9 ];
        int east_array_1_try_2_zero[ 9 ];
        int west_array_1_try_2_zero[ 9 ];
    
        int north_array_2_try_2_zero_and_odd[ 9 ];
        int south_array_2_try_2_zero_and_odd[ 9 ];
        int east_array_2_try_2_zero_and_odd[ 9 ];
        int west_array_2_try_2_zero_and_odd[ 9 ];
    
        int north_array_2_try_4_zero_and_even[ 9 ];
        int south_array_2_try_4_zero_and_even[ 9 ];
        int east_array_2_try_4_zero_and_even[ 9 ];
        int west_array_2_try_4_zero_and_even[ 9 ];
    
        int north_array_2_try_5_one_and_odd[ 9 ];
        int south_array_2_try_5_one_and_odd[ 9 ];
        int east_array_2_try_5_one_and_odd[ 9 ];
        int west_array_2_try_5_one_and_odd[ 9 ];
    
        int north_count_1 = 0;
        int south_count_1 = 0;
        int east_count_1 = 0;
        int west_count_1 = 0;
        int north_count_2 = 0;
        int south_count_2 = 0;
        int east_count_2 = 0;
        int west_count_2 = 0;
    
        int north_count_array_2_try_2_zero_and_odd = 0;
        int south_count_array_2_try_2_zero_and_odd = 0;
        int east_count_array_2_try_2_zero_and_odd = 0;
        int west_count_array_2_try_2_zero_and_odd = 0;
    
        int north_count_array_2_try_3_zero_and_odd = 0;
        int south_count_array_2_try_3_zero_and_odd = 0;
        int east_count_array_2_try_3_zero_and_odd = 0;
        int west_count_array_2_try_3_zero_and_odd = 0;
    
        int north_count_array_2_try_4_zero_and_even = 0;
        int south_count_array_2_try_4_zero_and_even = 0;
        int east_count_array_2_try_4_zero_and_even = 0;
        int west_count_array_2_try_4_zero_and_even = 0;
    
        int north_count_array_2_try_5_one_and_odd = 0;
        int south_count_array_2_try_5_one_and_odd = 0;
        int east_count_array_2_try_5_one_and_odd = 0;
        int west_count_array_2_try_5_one_and_odd = 0;
    
        int north_count_array_1_try_2_zero = 0;
        int south_count_array_1_try_2_zero = 0;
        int east_count_array_1_try_2_zero = 0;
        int west_count_array_1_try_2_zero = 0;
    
        int the_number_of_loops = 0;
    
        MakingStringArraysEqual string_arrays;
    
        CountingTheFourDirections directions_value;
    
        HowManySteps displaying_the_number_of_steps;
    
        SettingArrayElementZero setting_first_element_to;
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting step 1
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>directions_value
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // feeler 1 begin
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        north_count_1 = directions_value.testing_four_directions(north_array_1, left_or_right, 0);
        south_count_1 = directions_value.testing_four_directions(south_array_1, left_or_right, 1);
        east_count_1 = directions_value.testing_four_directions(east_array_1, left_or_right, 2);
        west_count_1 = directions_value.testing_four_directions(west_array_1, left_or_right, 3);
    
        cout << '\n';
        feeler = 1;
        element = 0;
    
       directions_value.direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest(
        lowest_value_feeler_1_try_1,
        lowest_value_array_feeler_1_try_1,
        north_array_1,
        south_array_1,
        east_array_1,
        west_array_1,
        feeler_1_lowest_value_array_direction,
        &north_count_1,
        &south_count_1,
        &east_count_1,
        &west_count_1,
        &feeler,
        &element,
        &direction_value );
    
        if ( lowest_value_array_feeler_1_try_1[ 0 ] == 0 )
        {
            *feeler_one_element_zero_equal = "feeler_one_element_zero_equal_zero";
    
            cout << '\n';
    
            displaying_the_number_of_steps.display_number_of_steps_message(north_count_1,
                                            south_count_1,
                                            east_count_1,
                                            west_count_1,
                                            feeler);
    
            cout << "\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in  the the_master_function_part_one function" << endl;
            }
            else
            {
                file << "\n\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n\n";
            }
    
            file.close();
    
            cout << '\n';
        }
        else if ( lowest_value_array_feeler_1_try_1[ 0 ] == 1 )
        {
            *feeler_one_element_zero_equal = "feeler_one_element_zero_equal_one";
    
            element = 2;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            setting_first_element_to.setting_feeler_one_element_zero_to_zero ( left_or_right,
                                                         lowest_value_feeler_1_try_2,
                                                         lowest_value_array_feeler_1_try_2,
                                                         north_array_1_try_2_zero,
                                                         south_array_1_try_2_zero,
                                                         east_array_1_try_2_zero,
                                                         west_array_1_try_2_zero,
                                                         feeler_1_lowest_value_array_direction,
                                                         &feeler_2_lowest_value_array_direction,
                                                         &did_second_feeler_work,
                                                         &north_count_array_1_try_2_zero,
                                                         &south_count_array_1_try_2_zero,
                                                         &east_count_array_1_try_2_zero,
                                                         &west_count_array_1_try_2_zero,
                                                         &left_or_right_1,
                                                         &left_or_right_2,
                                                         &left_or_right_3,
                                                         &left_or_right_4,
                                                         &feeler,
                                                         &element,
                                                         &the_number_of_loops);
    
                cout << '\n';
    
                displaying_the_number_of_steps.display_number_of_steps_message(north_count_array_1_try_2_zero,
                                                south_count_array_1_try_2_zero,
                                                east_count_array_1_try_2_zero,
                                                west_count_array_1_try_2_zero,
                                                feeler);
    
                cout << '\n';
    
                cout << "\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n";
    
                cout << '\n';
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "\n\nstep 1.) change feeler in that direction.\nstep 2.) feel again in that direction\n\n";
                }
    
                file.close();
    
        }
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // feeler 1 end
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // feeler 2 begin
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        north_count_2 = directions_value.testing_four_directions(north_array_2, left_or_right, 4);
        south_count_2 = directions_value.testing_four_directions(south_array_2, left_or_right, 5);
        east_count_2 = directions_value.testing_four_directions(east_array_2, left_or_right, 6);
        west_count_2 = directions_value.testing_four_directions(west_array_2, left_or_right, 7);
    
        cout << '\n';
    
        feeler = 2;
        element = 1;
    
        directions_value.direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest(
        lowest_value_feeler_2_try_1,
        lowest_value_array_feeler_2_try_1,
        north_array_2,
        south_array_2,
        east_array_2,
        west_array_2,
        &feeler_2_lowest_value_array_direction,
        &north_count_2,
        &south_count_2,
        &east_count_2,
        &west_count_2,
        &feeler,
        &element,
        &direction_value );
    
        if ( lowest_value_array_feeler_2_try_1[ 0 ] == 0 )
        {
    
            cout << '\n';
    
            displaying_the_number_of_steps.display_number_of_steps_message(north_count_2,
                                            south_count_2,
                                            east_count_2,
                                            west_count_2,
                                            feeler);
    
            cout << '\n';
        }
        else if ( lowest_value_array_feeler_2_try_1[ 0 ] == 1 )
        {
            while ( 1 )
            {
                element = 3;
                left_or_right_1 = 12;
                left_or_right_2 = 13;
                left_or_right_3 = 14;
                left_or_right_4 = 15;
                setting_first_element_to.first_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                   lowest_value_feeler_2_try_2,
                                                                   lowest_value_array_feeler_2_try_2,
                                                                   north_array_2_try_2_zero_and_odd,
                                                                   south_array_2_try_2_zero_and_odd,
                                                                   east_array_2_try_2_zero_and_odd,
                                                                   west_array_2_try_2_zero_and_odd,
                                                                   feeler_1_lowest_value_array_direction,
                                                                   &feeler_2_lowest_value_array_direction,
                                                                   &did_second_feeler_work,
                                                                   &north_count_array_2_try_2_zero_and_odd,
                                                                   &south_count_array_2_try_2_zero_and_odd,
                                                                   &east_count_array_2_try_2_zero_and_odd,
                                                                   &west_count_array_2_try_2_zero_and_odd,
                                                                   &left_or_right_1,
                                                                   &left_or_right_2,
                                                                   &left_or_right_3,
                                                                   &left_or_right_4,
                                                                   &feeler,
                                                                   &element,
                                                                   &the_number_of_loops);
                if ( lowest_value_array_feeler_2_try_2[ 0 ] == 0)
                {
                        break;
    
                }
            }
    
    
                displaying_the_number_of_steps.display_number_of_steps_message(north_count_array_2_try_2_zero_and_odd,
                                                south_count_array_2_try_2_zero_and_odd,
                                                east_count_array_2_try_2_zero_and_odd,
                                                west_count_array_2_try_2_zero_and_odd,
                                                feeler);
        }
    
        //////////
    
        cout << '\n';
    
        //results = testing_if_feeler_one_lowest_value_is_same_direction_as_feeler_two_lowest_value ( lowest_value_feeler,
                                                                                          //&did_second_feeler_work,
                                                                                          //&version);
    
    
    
            if ( lowest_value_feeler_1_try_1[ 0 ] == lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_1[ 0 ] != lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_unequal";
    
            }
    
            else if ( lowest_value_feeler_1_try_2[ 0 ] == lowest_value_feeler_2_try_2 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_2[ 0 ] != lowest_value_feeler_2_try_2 [ 0 ] )
            {
               did_second_feeler_work = "elements_are_unequal";
            }
    
        // running the second feeler again if it didn't fix the block problem the first time.
    ////
        if ( did_second_feeler_work == "elements_are_equal" )
        {
            int north_array_2_try_3_zero_and_odd[ 9 ];
            int lowest_value_array_feeler_2_try_3[ 9 ];
            int south_array_2_try_3_zero_and_odd[ 9 ];
            int east_array_2_try_3_zero_and_odd[ 9 ];
            int west_array_2_try_3_zero_and_odd[ 9 ];
    
            feeler = 2;
            element = 4;
            left_or_right_1 = 16;
            left_or_right_2 = 17;
            left_or_right_3 = 18;
            left_or_right_4 = 19;
            setting_first_element_to.second_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                  lowest_value_feeler_2_try_3,
                                                                  lowest_value_array_feeler_2_try_3,
                                                                  north_array_2_try_3_zero_and_odd,
                                                                  south_array_2_try_3_zero_and_odd,
                                                                  east_array_2_try_3_zero_and_odd,
                                                                  west_array_2_try_3_zero_and_odd,
                                                                  feeler_1_lowest_value_array_direction,
                                                                  &feeler_2_lowest_value_array_direction,
                                                                  &did_second_feeler_work,
                                                                  &north_count_array_2_try_3_zero_and_odd,
                                                                  &south_count_array_2_try_3_zero_and_odd,
                                                                  &east_count_array_2_try_3_zero_and_odd,
                                                                  &west_count_array_2_try_3_zero_and_odd,
                                                                  &left_or_right_1,
                                                                  &left_or_right_2,
                                                                  &left_or_right_3,
                                                                  &left_or_right_4,
                                                                  &feeler,
                                                                  &element,
                                                                  &the_number_of_loops);
    
            displaying_the_number_of_steps.display_number_of_steps_message(north_count_array_2_try_3_zero_and_odd,
                                        south_count_array_2_try_3_zero_and_odd,
                                        east_count_array_2_try_3_zero_and_odd,
                                        west_count_array_2_try_3_zero_and_odd,
                                        feeler);
        }
    
    
        cout << '\n';
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting feeler 2 end
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << "The second feeler did something to unblock feeler 1\n\n";
        cout << "Step 1 ended = make feeler 1 and 2 unequal - gain control.\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in  the the_master_function_part_one function" << endl;
            }
            else
            {
                file << "The second feeler did something to unblock feeler 1\n\n";
                file << "Step 1 ended = make feeler 1 and 2 unequal - gain control.\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
            }
    
            file.close();
        }
    
    ////
    
    // begin test here
    
    
    
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making the unequal equal again
    
    ////
            feeler = 2;
            element = 5;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            *less_than_node = setting_first_element_to.setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( left_or_right,
                                                                lowest_value_feeler_2_try_4,
                                                                lowest_value_array_feeler_2_try_4,
                                                                north_array_2_try_4_zero_and_even,
                                                                south_array_2_try_4_zero_and_even,
                                                                east_array_2_try_4_zero_and_even,
                                                                west_array_2_try_4_zero_and_even,
                                                                feeler_1_lowest_value_array_direction,
                                                                &feeler_2_lowest_value_array_direction,
                                                                &did_second_feeler_work,
                                                                &north_count_array_2_try_4_zero_and_even,
                                                                &south_count_array_2_try_4_zero_and_even,
                                                                &east_count_array_2_try_4_zero_and_even,
                                                                &west_count_array_2_try_4_zero_and_even,
                                                                &left_or_right_1,
                                                                &left_or_right_2,
                                                                &left_or_right_3,
                                                                &left_or_right_4,
                                                                &feeler,
                                                                &element,
                                                                &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            displaying_the_number_of_steps.display_number_of_steps_message(north_count_array_2_try_4_zero_and_even,
                                        south_count_array_2_try_4_zero_and_even,
                                        east_count_array_2_try_4_zero_and_even,
                                        west_count_array_2_try_4_zero_and_even,
                                        feeler);
    
            cout << "Step 2 ended = make feeler 1 and 2 equal - lose control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "Step 2 ended = make feeler 1 and 2 equal - lose control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making equal unequal again.
    ////
            feeler = 3;
            element = 6;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            setting_first_element_to.third_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                lowest_value_feeler_2_try_5,
                                                                lowest_value_array_feeler_2_try_5,
                                                                north_array_2_try_5_one_and_odd,
                                                                south_array_2_try_5_one_and_odd,
                                                                east_array_2_try_5_one_and_odd,
                                                                west_array_2_try_5_one_and_odd,
                                                                feeler_1_lowest_value_array_direction,
                                                                &feeler_2_lowest_value_array_direction,
                                                                &did_second_feeler_work,
                                                                &north_count_array_2_try_5_one_and_odd,
                                                                &south_count_array_2_try_5_one_and_odd,
                                                                &east_count_array_2_try_5_one_and_odd,
                                                                &west_count_array_2_try_5_one_and_odd,
                                                                &left_or_right_1,
                                                                &left_or_right_2,
                                                                &left_or_right_3,
                                                                &left_or_right_4,
                                                                &feeler,
                                                                &element,
                                                                &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            displaying_the_number_of_steps.display_number_of_steps_message(north_count_array_2_try_5_one_and_odd,
                                        south_count_array_2_try_5_one_and_odd,
                                        east_count_array_2_try_5_one_and_odd,
                                        west_count_array_2_try_5_one_and_odd,
                                        feeler);
    
            cout << "Step 3 ended = make feeler 1 and 2 unequal - regain control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in  the the_master_function_part_one function" << endl;
                }
                else
                {
                    file << "Step 3 ended = make feeler 1 and 2 unequal - regain control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                    file << endl;
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << '\n';
    
        *main_north_count = north_count_1;
        *main_south_count = south_count_1;
        *main_east_count = east_count_1;
        *main_west_count = west_count_1;
    
        string_arrays.set_one_string_array_equal_to_another_string_array ( main_left_or_right, left_or_right );
    
        directions_value.set_one_int_array_equal_to_another_int_array ( main_north_array, north_array_1 );
    
        directions_value.set_one_int_array_equal_to_another_int_array ( main_south_array, south_array_1 );
    
        directions_value.set_one_int_array_equal_to_another_int_array ( main_east_array, east_array_1 );
    
        directions_value.set_one_int_array_equal_to_another_int_array ( main_west_array, west_array_1 );
    }
    Code:
    #include "thefunctionparttwo.h"
    #include <iostream>
    #include <string>
    #include <fstream>
    
    using namespace std;
    
    void TheFunctionPartTwo::the_master_function_part_two ( string lowest_value_feeler_1_try_1[],
                                       string lowest_value_feeler_1_try_2[],
                                       string main_left_or_right[],
                                       int main_north_array[],
                                       int main_south_array[],
                                       int main_east_array[],
                                       int main_west_array[],
                                       string *feeler_one_element_zero_equal,
                                       string *feeler_1_lowest_value_array_direction,
                                       int *main_north_count,
                                       int *main_south_count,
                                       int *main_east_count,
                                       int *main_west_count,
                                       int *less_than_node,
                                       int *result_of_left_node_test)
    {
    
        string left_or_right[ 20 ];
        string lowest_value_feeler_2_try_1[ 9 ];
        string lowest_value_feeler_2_try_2[ 9 ];
        string lowest_value_feeler_2_try_3[ 9 ];
        string lowest_value_feeler_2_try_4[ 9 ];
        string lowest_value_feeler_2_try_6[ 9 ];
        string feeler_2_lowest_value_array_direction = "";
        string did_second_feeler_work = "";
        int lowest_value_array_feeler_2_try_1[ 9 ];
        int lowest_value_array_feeler_2_try_2[ 9 ];
    
        int lowest_value_array_feeler_2_try_4[ 9 ];
        int lowest_value_array_feeler_2_try_6[ 9 ];
        int direction_value = 0;
        int feeler = 0;
        int element = 0;
        int left_or_right_1 = 0;
        int left_or_right_2 = 0;
        int left_or_right_3 = 0;
        int left_or_right_4 = 0;
        int north_array_1[ 9 ];
        int south_array_1[ 9 ];
        int east_array_1[ 9 ];
        int west_array_1[ 9 ];
        int north_array_2[ 9 ];
        int south_array_2[ 9 ];
        int east_array_2[ 9 ];
        int west_array_2[ 9 ];
    
        int north_array_2_try_2_zero_and_odd[ 9 ];
        int south_array_2_try_2_zero_and_odd[ 9 ];
        int east_array_2_try_2_zero_and_odd[ 9 ];
        int west_array_2_try_2_zero_and_odd[ 9 ];
    
        int north_array_2_try_4_zero_and_even[ 9 ];
        int south_array_2_try_4_zero_and_even[ 9 ];
        int east_array_2_try_4_zero_and_even[ 9 ];
        int west_array_2_try_4_zero_and_even[ 9 ];
    
        int north_array_2_try_6_one_and_odd[ 9 ];
        int south_array_2_try_6_one_and_odd[ 9 ];
        int east_array_2_try_6_one_and_odd[ 9 ];
        int west_array_2_try_6_one_and_odd[ 9 ];
    
        int north_element_0[ 9 ];
        int south_element_0[ 9 ];
        int east_element_0[ 9 ];
        int west_element_0[ 9 ];
    
        int north_count_2 = 0;
        int south_count_2 = 0;
        int east_count_2 = 0;
        int west_count_2 = 0;
    
        int north_count_array_2_try_2_zero_and_odd = 0;
        int south_count_array_2_try_2_zero_and_odd = 0;
        int east_count_array_2_try_2_zero_and_odd = 0;
        int west_count_array_2_try_2_zero_and_odd = 0;
    
        int north_count_array_2_try_3_zero_and_odd = 0;
        int south_count_array_2_try_3_zero_and_odd = 0;
        int east_count_array_2_try_3_zero_and_odd = 0;
        int west_count_array_2_try_3_zero_and_odd = 0;
    
        int north_count_array_2_try_4_zero_and_even = 0;
        int south_count_array_2_try_4_zero_and_even = 0;
        int east_count_array_2_try_4_zero_and_even = 0;
        int west_count_array_2_try_4_zero_and_even = 0;
    
        int north_count_array_2_try_6_one_and_odd = 0;
        int south_count_array_2_try_6_one_and_odd = 0;
        int east_count_array_2_try_6_one_and_odd = 0;
        int west_count_array_2_try_6_one_and_odd = 0;
    
        int the_number_of_loops = 0;
        int greater_than_node = 0;
    
        MakingStringArraysEqual string_arrays;
    
        ArrayZeroRandom randomizing_or_zeroing;
    
        CountingTheFourDirections directions_value;
    
        HowManySteps displaying_the_number_of_steps;
    
        SettingArrayElementZero setting_first_element_to;
    
        randomizing_or_zeroing.set_array_value_to_zero( north_element_0 );
    
        randomizing_or_zeroing.set_array_value_to_zero( south_element_0 );
    
        randomizing_or_zeroing.set_array_value_to_zero( east_element_0 );
    
        randomizing_or_zeroing.set_array_value_to_zero( west_element_0 );
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting step 1
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        string_arrays.set_one_string_array_equal_to_another_string_array ( left_or_right, main_left_or_right );
    
        directions_value.set_one_int_array_equal_to_another_int_array ( north_array_1, main_north_array );
    
        directions_value.set_one_int_array_equal_to_another_int_array ( south_array_1, main_south_array );
    
        directions_value.set_one_int_array_equal_to_another_int_array ( east_array_1, main_east_array );
    
        directions_value.set_one_int_array_equal_to_another_int_array ( west_array_1, main_west_array );
    
    
        north_count_2 = directions_value.testing_four_directions(north_array_2, left_or_right, 4);
        south_count_2 = directions_value.testing_four_directions(south_array_2, left_or_right, 5);
        east_count_2 = directions_value.testing_four_directions(east_array_2, left_or_right, 6);
        west_count_2 = directions_value.testing_four_directions(west_array_2, left_or_right, 7);
        displaying_the_number_of_steps.display_number_of_steps_message(north_count_2, south_count_2,east_count_2, west_count_2, 2);
    
        cout << '\n';
    
        feeler = 2;
        element = 1;
    
        directions_value.direction_value__which_direction_is_lowest__direction_value_array_transfer_value_to_new_array__displaying_which_direction_is_lowest(
        lowest_value_feeler_2_try_1,
        lowest_value_array_feeler_2_try_1,
        north_array_2,
        south_array_2,
        east_array_2,
        west_array_2,
        &feeler_2_lowest_value_array_direction,
        &north_count_2,
        &south_count_2,
        &east_count_2,
        &west_count_2,
        &feeler,
        &element,
        &direction_value );
    
        if ( lowest_value_array_feeler_2_try_1[ 0 ] == 0 )
        {
    
            cout << '\n';
    
            displaying_the_number_of_steps.display_number_of_steps_message(north_count_2,
                                            south_count_2,
                                            east_count_2,
                                            west_count_2,
                                            feeler);
    
            cout << '\n';
        }
        else if ( lowest_value_array_feeler_2_try_1[ 0 ] == 1 )
        {
            while ( 1 )
            {
                element = 3;
                left_or_right_1 = 12;
                left_or_right_2 = 13;
                left_or_right_3 = 14;
                left_or_right_4 = 15;
                setting_first_element_to.first_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                   lowest_value_feeler_2_try_2,
                                                                   lowest_value_array_feeler_2_try_2,
                                                                   north_array_2_try_2_zero_and_odd,
                                                                   south_array_2_try_2_zero_and_odd,
                                                                   east_array_2_try_2_zero_and_odd,
                                                                   west_array_2_try_2_zero_and_odd,
                                                                   feeler_1_lowest_value_array_direction,
                                                                   &feeler_2_lowest_value_array_direction,
                                                                   &did_second_feeler_work,
                                                                   &north_count_array_2_try_2_zero_and_odd,
                                                                   &south_count_array_2_try_2_zero_and_odd,
                                                                   &east_count_array_2_try_2_zero_and_odd,
                                                                   &west_count_array_2_try_2_zero_and_odd,
                                                                   &left_or_right_1,
                                                                   &left_or_right_2,
                                                                   &left_or_right_3,
                                                                   &left_or_right_4,
                                                                   &feeler,
                                                                   &element,
                                                                   &the_number_of_loops);
                if ( lowest_value_array_feeler_2_try_2[ 0 ] == 0)
                {
                        break;
    
                }
            }
        }
    
        //////////
    
        cout << '\n';
    
        //results = testing_if_feeler_one_lowest_value_is_same_direction_as_feeler_two_lowest_value ( lowest_value_feeler,
                                                                                          //&did_second_feeler_work,
                                                                                          //&version);
    
    
    
            if ( lowest_value_feeler_1_try_1[ 0 ] == lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_1[ 0 ] != lowest_value_feeler_2_try_1 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_unequal";
    
            }
    
            else if ( lowest_value_feeler_1_try_2[ 0 ] == lowest_value_feeler_2_try_2 [ 0 ] )
            {
                did_second_feeler_work = "elements_are_equal";
    
                cout << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                cout << "Redo the second feeler until it works.\n\n";
    
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "The second feeler didn't do anything to unblock feeler 1.\n\n";
                    file << "Redo the second feeler until it works.\n\n";
                }
    
                file.close();
    
                //cout << "Then testing bulk results to see if one of them solved the feeler 1 block problem.\n";
            }
            else if ( lowest_value_feeler_1_try_2[ 0 ] != lowest_value_feeler_2_try_2 [ 0 ] )
            {
               did_second_feeler_work = "elements_are_unequal";
    
            }
    
        // running the second feeler again if it didn't fix the block problem the first time.
    ////
        if ( did_second_feeler_work == "elements_are_equal" )
        {
            int lowest_value_array_feeler_2_try_3[ 9 ];
            int north_array_2_try_3_zero_and_odd[ 9 ];
            int south_array_2_try_3_zero_and_odd[ 9 ];
            int east_array_2_try_3_zero_and_odd[ 9 ];
            int west_array_2_try_3_zero_and_odd[ 9 ];
    
            feeler = 2;
            element = 4;
            left_or_right_1 = 16;
            left_or_right_2 = 17;
            left_or_right_3 = 18;
            left_or_right_4 = 19;
            setting_first_element_to.second_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                  lowest_value_feeler_2_try_3,
                                                                  lowest_value_array_feeler_2_try_3,
                                                                  north_array_2_try_3_zero_and_odd,
                                                                  south_array_2_try_3_zero_and_odd,
                                                                  east_array_2_try_3_zero_and_odd,
                                                                  west_array_2_try_3_zero_and_odd,
                                                                  feeler_1_lowest_value_array_direction,
                                                                  &feeler_2_lowest_value_array_direction,
                                                                  &did_second_feeler_work,
                                                                  &north_count_array_2_try_3_zero_and_odd,
                                                                  &south_count_array_2_try_3_zero_and_odd,
                                                                  &east_count_array_2_try_3_zero_and_odd,
                                                                  &west_count_array_2_try_3_zero_and_odd,
                                                                  &left_or_right_1,
                                                                  &left_or_right_2,
                                                                  &left_or_right_3,
                                                                  &left_or_right_4,
                                                                  &feeler,
                                                                  &element,
                                                                  &the_number_of_loops);
    
            displaying_the_number_of_steps.display_number_of_steps_message(north_count_array_2_try_3_zero_and_odd,
                                        south_count_array_2_try_3_zero_and_odd,
                                        east_count_array_2_try_3_zero_and_odd,
                                        west_count_array_2_try_3_zero_and_odd,
                                        feeler);
        }
    
    
        cout << '\n';
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        // starting feeler 2 end
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << "The second feeler did something to unblock feeler 1\n\n";
        cout << "Step 4 ended = make feeler 1 and 2 unequal - gain control.\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "The second feeler did something to unblock feeler 1\n\n";
                file << "Step 4 ended = make feeler 1 and 2 unequal - gain control.\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
            }
    
            file.close();
        }
    
    ////
    
    // begin test here
    
    
    
    
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making the unequal equal again
    
    ////
            feeler = 2;
            element = 5;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            greater_than_node = setting_first_element_to.setting_feeler_two_lowest_direction_equal_to_feeler_one_lowest_direction_and_element_zero_to_zero ( left_or_right,
                                                                lowest_value_feeler_2_try_4,
                                                                lowest_value_array_feeler_2_try_4,
                                                                north_array_2_try_4_zero_and_even,
                                                                south_array_2_try_4_zero_and_even,
                                                                east_array_2_try_4_zero_and_even,
                                                                west_array_2_try_4_zero_and_even,
                                                                feeler_1_lowest_value_array_direction,
                                                                &feeler_2_lowest_value_array_direction,
                                                                &did_second_feeler_work,
                                                                &north_count_array_2_try_4_zero_and_even,
                                                                &south_count_array_2_try_4_zero_and_even,
                                                                &east_count_array_2_try_4_zero_and_even,
                                                                &west_count_array_2_try_4_zero_and_even,
                                                                &left_or_right_1,
                                                                &left_or_right_2,
                                                                &left_or_right_3,
                                                                &left_or_right_4,
                                                                &feeler,
                                                                &element,
                                                                &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            displaying_the_number_of_steps.display_number_of_steps_message(north_count_array_2_try_4_zero_and_even,
                                        south_count_array_2_try_4_zero_and_even,
                                        east_count_array_2_try_4_zero_and_even,
                                        west_count_array_2_try_4_zero_and_even,
                                        feeler);
    
            cout << "Step 5 ended = make feeler 1 and 2 equal - lose control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "Step 5 ended = make feeler 1 and 2 equal - lose control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        // making equal unequal again.
    ////
            feeler = 3;
            element = 7;
            left_or_right_1 = 8;
            left_or_right_2 = 9;
            left_or_right_3 = 10;
            left_or_right_4 = 11;
            setting_first_element_to.fourth_time_setting_feeler_two_element_zero_to_zero ( left_or_right,
                                                                  lowest_value_feeler_2_try_6,
                                                                  lowest_value_array_feeler_2_try_6,
                                                                  north_array_2_try_6_one_and_odd,
                                                                  south_array_2_try_6_one_and_odd,
                                                                  east_array_2_try_6_one_and_odd,
                                                                  west_array_2_try_6_one_and_odd,
                                                                  feeler_1_lowest_value_array_direction,
                                                                  &feeler_2_lowest_value_array_direction,
                                                                  &did_second_feeler_work,
                                                                  &north_count_array_2_try_6_one_and_odd,
                                                                  &south_count_array_2_try_6_one_and_odd,
                                                                  &east_count_array_2_try_6_one_and_odd,
                                                                  &west_count_array_2_try_6_one_and_odd,
                                                                  &left_or_right_1,
                                                                  &left_or_right_2,
                                                                  &left_or_right_3,
                                                                  &left_or_right_4,
                                                                  &feeler,
                                                                  &element,
                                                                  &the_number_of_loops);
    
            the_number_of_loops = 0;
    
            displaying_the_number_of_steps.display_number_of_steps_message(north_count_array_2_try_6_one_and_odd,
                                        south_count_array_2_try_6_one_and_odd,
                                        east_count_array_2_try_6_one_and_odd,
                                        west_count_array_2_try_6_one_and_odd,
                                        feeler);
    
            cout << "Step 3 ended = make feeler 1 and 2 unequal - regain control.\n\n";
            cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
            {
                fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
                if( file.fail() )
                {
                    cout << "error while opening the file in the the_master_function_part_two function" << endl;
                }
                else
                {
                    file << "Step 6 ended = make feeler 1 and 2 unequal - regain control.\n\n";
                    file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                }
    
                file.close();
            }
    
    ////
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
        cout << '\n';
    
        if ( greater_than_node > *less_than_node )
        {
            cout << "greater than node: " << greater_than_node << ", is greater than less than node: " << *less_than_node << '\n';
            cout << "Added left node, start turning.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "greater than node: " << greater_than_node << ", is greater than less than node: " << *less_than_node << '\n';
                file << "Added left node, start turning.\n";
            }
    
            file.close();
    
            *result_of_left_node_test = 0;
        }
        else if( *less_than_node > greater_than_node )
        {
            cout << "greater than node: " << greater_than_node << ", is not greater than less than node: " << *less_than_node << '\n';
            cout << "Didn\'t add left node, no turning, go straight.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "greater than node: " << greater_than_node << ", is not greater than less than node: " << *less_than_node << '\n';
                file << "Didn\'t add left node, no turning, go straight.\n";
            }
    
            file.close();
    
            *result_of_left_node_test = 1;
        }
        else
        {
            cout << "greater than node: " << greater_than_node << ", is equal to less than node: " << *less_than_node << '\n';
            cout << "Didn\'t add left node, no turning, go straight.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the the_master_function_part_two function" << endl;
            }
            else
            {
                file << "greater than node: " << greater_than_node << ", is equal to less than node: " << *less_than_node << '\n';
                file << "Didn\'t add left node, no turning, go straight.\n";
            }
    
            file.close();
    
            *result_of_left_node_test = 1;
        }
    }
    Code:
    #include "whoscored.h"
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    
    void WhoScored::which_team_scored( int *try_again, int *good_job )
    {
        if ( *try_again == 0)
        {
            cout << "\nteam 2 won.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\nteam 2 won.\n";
            }
    
            file.close();
    
        }
        else if ( *try_again == 1 )
        {
            cout << "\nteam 1 won.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\nteam 1 won.\n";
            }
    
            file.close();
        }
        else if ( *try_again % 2 == 0 )
        {
            cout << "\nteam 2 won.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\nteam 2 won.\n";
            }
    
            file.close();
        }
        else if ( *try_again % 2 == 1 )
        {
            cout << "\nteam 1 won.\n";
    
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\nteam 1 won.\n";
            }
    
            file.close();
        }
    }
    Code:
    #include <cstdlib>
    #include <ctime>
    #include <iostream>
    #include <windows.h> // WinApi header
    #include <cstdio>
    #include <string>
    #include <time.h>
    #include <fstream>
    #include "insertionsort.h"
    #include "arrayzerorandom.h"
    #include "makingstringarraysequal.h"
    #include "countingthefourdirections.h"
    #include "howmanysteps.h"
    #include "settingarrayelementzero.h"
    #include "thefunctionpartone.h"
    #include "thefunctionparttwo.h"
    #include "whoscored.h"
    #include "stacklayerinfo.h"
    #include "music.h"
    #include "testresultsofthetwomainfunctions.h"
    #include "startprogram.h"
    
    using namespace std;
    
    
    int main ()
    {
        int compare_to_output_array_1[ 9 ];
        int compare_to_output_array_2[ 9 ];
        int the_random_list_generated_by_the_left_node_results_array[ 9 ];
        int try_again = 0;
        int good_job = 0;
    
        InsertionSort function_in_InsertionSort;
    
        ArrayZeroRandom randomizing_or_zeroing;
    
        WhoScored the_score;
    
        music sounds;
    
        StartProgram starting;
    
        srand( time( NULL ) );
    
    
        randomizing_or_zeroing.set_array_value_to_zero( compare_to_output_array_1 );
        randomizing_or_zeroing.set_array_value_to_zero( compare_to_output_array_2 );
        randomizing_or_zeroing.set_array_value_to_zero( the_random_list_generated_by_the_left_node_results_array );
    
        // clear text file
        {
            fstream file("text_from_program.txt", ios::out | ios::trunc);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
    
    
            file.close();
        }
    
        // clear text file
        {
            fstream file("array_used_for_sound.txt", ios::out | ios::trunc);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
    
    
            file.close();
        }
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            cout << "Starting program\n";
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "Starting program\n\n";
            }
            file.close();
        }
    
        for ( int i = 0; i < 9; i++ )
        {
            // keep the numbers small so they're easy to read
            compare_to_output_array_1[ i ] = rand() % 2;
        }
    
        starting.running_the_two_main_functions( compare_to_output_array_1,
                                        compare_to_output_array_2,
                                        the_random_list_generated_by_the_left_node_results_array,
                                        &try_again,
                                        &good_job );
    
    
    
        cout << '\n';
        cout << "\ngenerated input list 1\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "\ngenerated input list 1\n";
            }
    
            file.close();
        }
    
        function_in_InsertionSort.displayArray( compare_to_output_array_1, 9 );
        cout << '\n';
        cout << "generated input list 2\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated input list 2\n";
            }
    
            file.close();
        }
    
        function_in_InsertionSort.displayArray( compare_to_output_array_2, 9 );
        cout << '\n';
        cout << "generated results list\n";
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << '\n';
                file << "generated results list\n";
            }
    
            file.close();
        }
    
        function_in_InsertionSort.displayArray( the_random_list_generated_by_the_left_node_results_array, 9 );
        cout << "\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
        cout << "\n\nscore:\n";
        cout << "Number of times won = " << good_job << '\n';
        cout << "Number of retries until won = " << try_again << '\n';
    
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                file << "\n\nscore:\n";
                file << "Number of times won = " << good_job << '\n';
                file << "Number of retries until won = " << try_again << '\n';
            }
    
            file.close();
        }
    
        the_score.which_team_scored( &try_again, &good_job );
    
        cout << "\nEnding program\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
    
        cout << "Begin analysis of the sound the 27 array elements make.\n\n";
        cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
        {
            fstream file("text_from_program.txt", ios::in | ios::out | ios::app);
    
            if( file.fail() )
            {
                cout << "error while opening the file in the main function" << endl;
            }
            else
            {
                file << "\n\n";
    
                file << "\nEnding program\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
                file << "Begin analysis of the sound the 27 array elements make.\n\n";
                file << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
            }
    
            file.close();
        }
    
        cout << "listening to the sound the arrays make\n";
        sounds.listening_to_the_sound_made_by_the_array();
    
        getchar();
    
    }
    Last edited by jeremy duncan; 12-18-2015 at 12:54 AM.

  6. #21
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I was not entirely kidding about the version control thing. Since you are open to allowing the public to see your work, consider using say, Git, and then uploading your Git repository to a code hosting system like GitHub or Bitbucket. This way, you can then just provide us with a link to your hosted code.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #22
    Registered User
    Join Date
    Apr 2011
    Posts
    308
    Sounds pretty formal though laserlight.

    Here is the source you can download and look at.
    Mega File Upload - ai program 18.zip

    Bucky taught me about the classes today, that's why I was able to put my code into different files today. Thanks Bucky if your reaading this.
    Last edited by jeremy duncan; 12-18-2015 at 01:01 AM.

  8. #23
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by jeremy duncan
    Sounds pretty formal though laserlight.
    It is true that companies use such services for their commercial code, perhaps in a private repository, and that open source projects with substantial user bases use it too, but a lone hobbyist/student can utilise them too.

    The version control system gives you an incremental backup and record of your project's history, allowing you to more easily see what has changed, why it changed, and undo/redo changes. In a team, it can help in collaboration, facilitating integration and allowing team members to identify who made what changes, but even when coding alone it is useful.

    Quote Originally Posted by jeremy duncan
    Here is the source you can download and look at.
    The code hosting sites that I mentioned provide a web interface for code, similiar to what is provided by the code bbcode tags here or in pastebins, thus readers do not have to download the code separately. Nonetheless, they can still do so, or even clone the repository if they want to take advantage of the version control locally. You can link people to a specific version, or just ask for comment on the latest version.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #24
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    In some ways having version control can inspire creativity and make it less daunting to make huge changes as well. No need to worry about backups of the code before changing things: just make sure everything is up-to-date, make a new branch and go crazy. If things go wrong you just delete the branch, if they go right you merge into your master.

    Keeps backups of the repo of course. (Although that is somewhat redundant if you're pushing to a remote location I do it anyway. While you're learning how to use the source control and you're learning a new command you probably want to either make sure the remote location is up-to-date -- so you can recover in the event of disaster -- or you can make a local backup of the repo. Or do both!)

  10. #25
    Registered User
    Join Date
    Apr 2011
    Posts
    308
    Here is my github that has my AI program, the code was updated since the last post above.

    https://github.com/jeremyduncanartif.../ai-program-18

    No that I have my master on the github I just need to figure out how to make branches that don't affect the master. So I can play with the code and still have a nice master until I am ready to commit the changes.

  11. #26
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    I would like your post twice if I could. You've made the right decision.

    If you need help with git (and github) I think there is somewhere on this forum where the "topic" is appropriate (maybe "Tech Board"). Using git might take a bit of getting used to but there are only a handful of commands that you'll need to commonly use. Use some kind of GUI front-end (to git) to begin with if that makes your new adventure easier, but bear in mind that after a while git from the command line becomes pretty easy and intuitive (honestly).

  12. #27
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Often it is helpful to just get started using it on a project like you are now. Common things like git status, git commit, and git checkout get easier the more practice you have. (And there are GUI interfaces if/when you get tired of typing commands.)

    Still I have a bunch of useful links for you to check out at your own pace. I don't really think you need them all... just depends on the type of person you are and how much help you need.


    1. Pro Git - free online book
    2. try git - free online course by Code School
    3. Git How-To: Guided Git Tutorial
    4. Linus Torvalds on git - YouTube talk
    5. Git Reference
    6. Introduction to Git - YouTube
    7. GUI clients

  13. #28
    Registered User
    Join Date
    Apr 2011
    Posts
    308
    I watched this video and got my files on github;
    https://www.youtube.com/watch?v=om42hY4A5Qg

    Then once it was on there I watched this video for how to update the master;
    https://www.youtube.com/watch?v=XdhuWDdu-rk

    When I click fork like in the second video I don't see the fork symbol he shows, so I just cloned the master to my desktop gui and then figured out how to change the code then upload the changed files to github.

    Then I coded all day and night and cleaned up the code and fixed a ton of logical errors then I had about 11 commits to the project, so I deleted the repository and uploaded the new code to start over.

    Here it is;

    https://github.com/jeremyduncanartif...gence-software

    What's new in this version: I made the code cleaner so it's not so many lines of code, and I fixed some, actually a lot, of logical bugs.

  14. #29
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    You can "squash" commits (squashing means turning more than 1 commit into 1 commit that you can then push) Look it up! Very useful.

    Edit: creating a branch is pretty easy. Are you using the command line or a GUI?

    Edit 2: Also, what OS are you using. I think that git-gui (https://git-scm.com/docs/git-gui) is probably all you need if you want to start off with a GUI solution (although I don't think it can squash... it does every other common thing though)

    Edit 3: Of course, if you're using Linux or BSD ignore the link below and install it using your package manager.

    https://git-scm.com/downloads
    Last edited by Hodor; 12-20-2015 at 08:05 AM.

  15. #30
    Registered User
    Join Date
    Apr 2011
    Posts
    308
    I'm using the gui.

    Windows 7 64 bit.

    I'm using the desktop gui right now. I can update the master pretty good, but that's about it. I will watch some more youtube videos later.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Recursion slows down mysteriously
    By brane_sail in forum C++ Programming
    Replies: 9
    Last Post: 03-20-2008, 07:03 AM
  2. My script slows down how do I fix this??
    By JordanCason in forum C++ Programming
    Replies: 10
    Last Post: 11-25-2007, 11:43 PM
  3. What slows down if statements?
    By Hunter2 in forum C++ Programming
    Replies: 3
    Last Post: 05-30-2003, 03:37 PM
  4. directory and file crawl
    By atari400 in forum C++ Programming
    Replies: 4
    Last Post: 04-24-2003, 05:04 PM
  5. Program slows down system
    By Mox in forum Windows Programming
    Replies: 1
    Last Post: 10-23-2001, 08:11 AM

Tags for this Thread