A code that generates a two-dimensional array of size n x n (where n is an integer inputted by the user) filled with randomly shuffled 1s and 0s. It then checks the array for any occurrences of four consecutive 1s in a row, column, or diagonal, and counts the total number of occurrences across 99 iterations of the array. Finally, it outputs the total number of occurrences and the average number of occurrences per iteration.
A code that determines whether the nth Fibonacci number is prime.
A code that reads a text file and preprocesses the text by removing all non-alphabetic characters and converting the remaining text to lowercase. It then generates triads of adjacent words and uses them to create a new text by randomly selecting the next word based on the previous two words. The generated text is limited to 200 words and starts with a randomly selected triad.
A code that generates a grid of rows and columns specified by the user, randomly fills it with either "S" or "O", and then counts the number of occurrences of the "SOS" sequence. The program repeats this process 99 times and then calculates the total number of "SOS" sequences found and their average. The input validation is also implemented to ensure that the user inputs integers for the number of rows and columns.