"""Will generate a string of S and L using the line intercept method. First arameter is the number of digits to generate - default 100. Second parameter is offset on the y axis. Third parameter is the slope of the line - default ~.6898 
(c) Adly Templeton 2015""" 

import sys

max = 100
if len(sys.argv) > 1:
    if sys.argv[1] == '-h':
        print("python3 sl.py [numDigits] [offset] [slope]")
        exit()
    else:
        max = int(sys.argv[1])

ratio = 0.6898979073690380324097615046885475307859255514140942442576957976161025523228995263541856987704967228231368540739877319673055482769110828476927831007710961179622086834989219317484306218762387710564564600842115200746451833018586390617057662244292248880727306443236842935222583079528404349913065341798560984673416525215896202889126665452850766933194957297618278563426190761235663416619601062950181480970355373088285177294094784916978489423177385980553520440105425929179487820920666241761674033734047879106655030141261707803014670995726566325404909898834558051213128382539375578650408534848313554671336214752059539697902350509654139094861159584148821356734481952213239529020868121876923913091497780890722136525874509538333647530335376149170921681896314419287697619216933957383354212260356911204748163657652568990486841211405222915565255169202074048813750013552109453117325552779993405316072957475667509493684311390762581830487068788183582240684345735562514381816457552365049464
offset = 0
if len(sys.argv) > 2:
    offset = float(sys.argv[2])
if len(sys.argv) > 3:
    ratio = float(sys.argv[3])

x = 0
y = 0
t = 0
r=""
for i in range(max):
    #Values of t which will next give an intercept for X and Y
    nextX = x + 1
    #y = ratio * t
    nextY = (y + 1 - offset) / ratio 
    
    if nextX < nextY:
        r += "S"
        x += 1
        t = nextX
    elif nextY < nextX:
        r += "L"
        y += 1
        t = nextY
    else:
        print("Serious Error - grid point intercept")
print(r)    
    
