# NaPoWriMo x NaPoGenMo 2024 Day 27 : Rule Based Carousel

# **Poetic Carousel**

For the 27th day of **NaPoWriMo/NaPoGenMo** 2024, ***Poetic Carousel*** rules are coded in **Ruby & Python:** Where the starting letter of each word is derived from a ***3x3*** matrix that is generated with no repeat letters and then transposed.

## Poems

### First Poem

```python
Poetic Stanza 1 :
[['x' 's' 'n']
 ['d' 't' 'a']
 ['g' 'e' 'z']]

Poetic Stanza 2:
[['x' 'd' 'g']
 ['s' 't' 'e']
 ['n' 'a' 'z']]
```

```ocaml
X-Men Singing Nervously
Dancing to Ambition
Gracefully, Energetic & Zesty  

Xylophone driven Grooves
Simply Tossing Energy
Naturely, Anti- Zoo
```

### Second Poem

```python
Poetic Stanza 1 :
[['m' 'd' 't']
 ['e' 'y' 'z']
 ['j' 's' 'p']]

Poetic Stanza 2:
[['m' 'e' 'j']
 ['d' 'y' 's']
 ['t' 'z' 'p']]
```

```ocaml
Magically Driven Tones
Eyeing Your Zones
Juicing Supreme Positions

Magically erasing jurisdictions
Decreasing your stubbornness
Teasing zonal publicness
```

## Images

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1714238340013/049bc5ed-2174-4d0a-90e2-8b9ad7220fb1.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1714238368083/1ca78278-995e-4d47-bfcc-54bd92f68e53.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1714238375067/36b84af0-17c5-4413-9d19-9cbfd175fa28.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1714238383132/5fa52c61-cfb8-4786-be38-4f5cb59b5b39.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1714238405565/6c94dd27-d5a4-4e9c-b527-0d42a12d84fd.jpeg align="center")

## Code

### Pre Poetic Rules in Ruby(SonicPi)

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

timer = use_random_seed Time.now.to_i

#range of letters in an array

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

#shuffling as a random generator
grid_shuffled = grid.shuffle(random: Random.new(timer))

#empty erray
grid_final= []

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

#print the final grid
puts grid_final.inspect


for letters in grid_final do
  puts letters
end

#Output to a file

File.open("E:/Genuary/NaPoWRiMO2024/Day 27 - 3x3 Poems/grid array.txt", "w+") do |f|
  f.puts(grid_final)
end
```

### Python

**File Read**

```python
#reading the file and adjusting it

f = open("E:/Genuary/NaPoWRiMO2024/Day 27 - 3x3 Poems/grid array.txt", "r")
arr = f.read().replace("\n", " ") # replace newline with space

print(arr)

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

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

print(arr1)
arr1_fix = arr1.pop() #removes last element

print(arr1)
```

**Rule Basis**

```python
def transformation(box):
    
    import numpy as np
    
    
    arr1 = np.array([[box[0],box[1],box[2]],[box[3],box[4],box[5]],[box[6],box[7],box[8]]])
    
    print(f'Poetic Stanza 1 :\n{arr1}')

    arr1_transpose = arr1.transpose()


    print(f'Poetic Stanza 2:\n{arr1_transpose}')

transformation(arr1)
```
