Created
May 2, 2018 01:19
-
-
Save Unitoi01/02d9d04eacb4fb7b93caa6c35a96f7ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import time | |
def prepareMessage(messageRaw): | |
words_list = messageRaw.split() | |
lineLength = 0 | |
message = '' | |
for word in words_list: | |
if(lineLength == 0): | |
message = message + word | |
lineLength = lineLength + len(word) | |
elif(lineLength + len(word) + 1 < 29): | |
message = message + ' ' + word | |
lineLength = lineLength + len(word) | |
else: | |
message = message + '\n' + word | |
lineLength = len(word) | |
print(message) | |
def readShuffle(): | |
with open('test.txt','r+') as source: | |
content = source.readlines() | |
content= [x.strip() for x in content] | |
return content | |
def randomize (arr, n): | |
# Start from the last element and swap one by one. We don't | |
# need to run for the first element that's why i > 0 | |
for i in range(n-1,0,-1): | |
# Pick a random index from 0 to i | |
j = random.randint(0,i) | |
# Swap arr[i] with the element at random index | |
arr[i],arr[j] = arr[j],arr[i] | |
return arr | |
def shuffleRead(): | |
ran= readShuffle() | |
i=0 | |
list=[] | |
first=True | |
count=0 | |
if(first==True): | |
first=False; | |
ran= randomize(ran,len(ran)) | |
if count == 3: | |
count=0 | |
ran= readShuffle() | |
else: | |
count= count +1 | |
time.sleep(1) | |
return ran[count] | |
while True: | |
array= shuffleRead() | |
prepareMessage(shuffleRead()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment