Am running Python 3.8.10 in a 32-bit Windows 7 computer with only 2GB memory and no video card (not even an
NVIDIA) - it's a two decade old netbook...

Tried running the following code:
Code:
import numpy as np
from scipy import ndimage

def predict_next_string(database):
  # Split the database into a list of strings
  strings = np.array(database.split('\n'))

  #last_two_strings = ndimage.laplace(strings.astype(bool), mode='constant')

  # Check if there are at least two strings
  if len(last_two_strings) < 2:
      print ("Not enough strings in the database,")
      return

  # Get the second-to-the-last string in the list
  last_string = last_two_strings[-1]

  # Split the last string into a list of integers
  last_string_numbers = [int(x) for x in last_string.split()]

  # Increment each number by one and return the resulting string
  predicted_string = ' '.join([str(x + 1) for x in last_string_numbers])

  print("The predicted next string is", predicted_string)
 
database = """5 3 4 5 1 2
1 3 1 5 0 4
2 3 0 5 1 2
0 5 4 0 5 2
1 1 0 5 2 4
4 1 4 3 0 0
4 3 3 3 2 3
2 3 3 1 4 1
4 2 3 3 1 1
2 3 1 4 4 2
0 2 3 4 2 2
3 4 5 4 5 1
2 4 3 1 0 2
2 1 2 2 0 5
4 4 1 0 1 3
2 2 5 4 0 2
3 2 2 2 4 3
4 1 3 3 3 2
5 3 3 1 3 5
1 0 2 2 5 3
1 3 3 5 0 2
2 3 4 1 1 0
0 0 4 2 4 1
4 3 2 4 1 3
3 4 4 1 1 4
1 2 4 1 5 4
5 5 4 2 0 5
5 4 1 4 5 5
4 4 4 2 2 0
1 3 1 2 0 1
1 2 4 4 5 5
3 2 1 4 5 5
5 1 5 2 5 4
1 2 4 1 5 2
5 5 4 2 0 5
5 4 1 4 5 5 
4 4 4 2 2 0
1 3 1 2 0 1
1 2 4 4 5 5 
3 2 1 4 5 5
5 1 5 2 5 4
0 1 5 5 5 4
3 3 1 5 3 5 
"""
It is meant to predict the next string of 6 numbers from 0 to 5.

There are no errors when I compiled it - but for some reason, it's not giving out an output.
Name:  source code output_03202023.jpg
Views: 3411
Size:  13.7 KB

What could be wrong with the code?