Juliette Published & Destroyed that

Justin Bieber's Purpose Generator

Justin Bieber as a fortune teller

Justin.png

With only answering 3 simple questions you can generate your own Justin Bieber life purpose.

Juliette collected the lyrics of the songs from Justin's last album Purpose. The algorythm picks randomly lines from those songs and generates a new combination. Three recurrent words have been selected and are replaced by the answers of the questions. The text is automatically printed.

The Bieber algorythm

      import sys
      
      import random
      from subprocess import call

set the variable

      var1 = raw_input("Enter your name: ")
      var2 = raw_input("A verb that defines you: ")
      var3 = raw_input("One word that inspires you: ")
      txt = 
      lines = []

lyrics file

      f = open("justinbieber.txt", "r")

image turned into text

      f2 = open("justin.txt", "r")
      justin = f2.read()
      txt += justin
      txt += "\n"
      txt += "JUSTIN BIEBER'S PURPOSE GENERATOR\n"
      txt += "\n"
      txt += "\n"
      for line in f.readlines():
              lines.append(line.strip())

selection of a random number of lines between 25 and 42

      for i in range(random.randint(25,42)):
              l = random.choice(lines)

replace function

              l = l.replace("your",var1+"'s")
              l = l.replace("you",var1)
              l = l.replace("make",var2)
              l = l.replace("I ",var3+" ")
              l = l.replace("I'",var3+"'")
              txt += l +  "\n"

print

      output = open("output.txt", "w")
      output.write(txt)
      output.close()

basic layout for the page

      call(["lp", "-d", "HP_LaserJet_8150_Series__0030C1CCDDF2_", "-o", "page-left=72", "-o", "cpi=15","-o", "lpi=9", "-o", "page-bottom=36", "-o", "page-top=28", "-o", "page-right=42", "output.txt"])

save the file in a folder

      output = open("biebs/" + str(int(round(time.time()))) + ".txt", "w")
      output.write(txt)
      output.close()