NaPoWriMo x NaPoGenMo 2024 Day 29 : Rule Based Carousel 3

NaPoWriMo x NaPoGenMo 2024 Day 29 : Rule Based Carousel 3

String Comparison as a Rule Generator

Poetic Carousel 3

For the 29th day of NaPoWriMo/NaPoGenMo 2024, Poetic Carousel 3 contains rules and prompts coded in Ruby & Python. This is done by making a comparison between 6 random assortments of the alphabet and only outputting, letters that match.

Poetic Rule

The following rule set for this poem:

  • 4 lines of poetry

  • 3 stanzas

  • Words must start with the letter shown in these arrays

['x', 'j', 'p']
['m', 'h', 'p']
['p', 's']
['e', 'b', 'g', 'l']


Xylophones jumping profusely 

Managing hopes perfectly

Persistence, Simply
Excludes Bass, Grabs & Leave



#random seed mapped to time, so it becomes "more" random

timer = use_random_seed

#range of letters in an array

grid = ('a'..'z').to_a

#shuffling as a random generator
grid_shuffled = grid.shuffle(random:

#empty erray
grid_final= []

#iteration to fill an array of 9 letters in
(0..36).each {|i| grid_final.push(grid_shuffled[i]) }

#print the final grid
puts grid_final.inspect

for letters in grid_final do
  puts letters

#Output to a file"E:/Creatuve Code Challenges/Simplify/Simplification.txt", "w+") do |f|

Python - File Read

#reading the file and adjusting it to become am array

import numpy as np

def reading(x):

    f = open(x, "r")

    arr ="\n", " ") # replace newline with space

    arr1 =  arr.split(" ")  #puts its as an array

    #arr1 = arr1_space.pop() #takes away the space at the end

    arr1_fix = arr1.pop() #removes last element

    return arr1
text_1 = reading("E:\Creatuve Code Challenges\Simplify\Simplification5x5.txt")
text_2 = reading("E:\Creatuve Code Challenges\Simplify\Simplification5x5_1.txt")
text_3 = reading("E:\Creatuve Code Challenges\Simplify\Simplification5x5_2.txt")
text_4 = reading("E:\Creatuve Code Challenges\Simplify\Simplification5x5_3.txt")

Python - File Comparison

#comparison of the two list of letters and outputs the one that are in the identical spot

def charcheck(a,b):

    #empty array
    letters = []

    #this will run a loop to the length of the array and if the elements match, it will be append to the letters array

    i = 0
    while i < len(text_1):
        if (a[i] == b[i]):
        i += 1

    return letters
#All possible comparisons

tx1_a = charcheck(text_1,text_2)
tx1_b = charcheck(text_1,text_3)
tx1_c = charcheck(text_1,text_4)

tx2_a = charcheck(text_2,text_3)
tx2_b = charcheck(text_2,text_4)

tx3_a = charcheck(text_3,text_4)