<jupyter_start><jupyter_text>Palindrome GenerationWe start by generating a list of the first n iterations of the lychrel process on 196.<jupyter_code>pal = 196
n = 0
n_final = 100000

# generator, break condition removed as we can save computation time
def lychrel_generator(start) :
    a = start
    b = a + int(str(a)[::-1])
    while True :
        yield a
        a , b = b , b + int(str(b)[::-1])

lychrel_gen = lychrel_generator(pal)


title_text = "Frequency Of Digits for " + str(n_final) + " Steps of the Lychrel Process on 196" 
image_title = "images/196DigitDistributionForN" + str(n_final)
digits = list( map( str, list(range(0,10))))
distr_list = [0, 0, 0, 0, 0, 0, 0, 0 ,0 ,0]


lychrel_char_gen = lychrel_generator(pal)

i=0
for char in lychrel_char_gen:
    if i > n_final :
        break
    else:
        #print(char)
        digit_list = map(int, list(str(char)))
        for digit in digit_list:
                #print("increasing", digit, "by one")
                distr_list[digit] += 1
        print(i)
        i += 1
        
name = "datasets/DigitDistribution" + str(n_final) +".txt"
with open(name, "w") as output:
    output.write(str(distr_list))

print(distr_list)
print(digits)
distr_list = [215572511, 204208594, 206919317, 203447888, 208115723, 208146254, 203464390, 206912759, 204163875, 215587526]<jupyter_output><empty_output><jupyter_text>Then we want to analyse the distribution of integers above some arbitrary cut off point.<jupyter_code>plt.bar(digits, distr_list, color="#E59F71")
plt.title(title_text, y=1.04)
plt.xlabel("Digits")
plt.ylabel("Occurence")
#plt.tight_layout()
plt.autoscale()
plt.savefig(image_title, dpi = 400, transparent=True)
plt.show()
title_text = "Frequency Of Digits for " + str(n_final) + " Steps of the Lychrel Process on 196" 
bar_color = '#ffffff'
if n_final <= 100:
    bar_color = '#FCBA04'
    text_color = '#dfdfbf'
elif n_final <= 1000:
    bar_color = '#EB5160'
    text_color = '#dfbfbf'
elif n_final <= 10000:
    bar_color = '#67E0A3'
    text_color = '#bfdfbf'
elif n_final <= 100000:
    bar_color = '#822E81'
    text_color = '#dfbfdf'
elif n_final <= 1000000:
    bar_color = '#0D97FC'
    text_color = '#bfcfdf'

fig = go.Figure([go.Bar(x=digits, y=distr_list, marker=dict(color=bar_color))])

fig.update_layout(
    title={
        'text': title_text,
        'y':0.9,
        'x':0.5,
        'xanchor': 'center',
        'yanchor': 'top'}
    , xaxis={
        'spikemode' : 'across',
        'spikesnap' : 'data',
        'spikethickness' : 1,
        'spikedash' : 'solid',
        'spikecolor' : '#0f0f0f',
        'gridcolor' : '#3d4752',
        'gridwidth' : 0.5,
        'type' : 'category'        
    }     
    , yaxis = {
        'gridcolor' : '#3d4752',
        'gridwidth' : 0.5,
        'zeroline' : False,
    }
    , xaxis_title="Digits"
    , yaxis_title="Quantity"
    , hoverlabel_align = 'right'
    , hovermode = 'x'
    , spikedistance = -1
    , plot_bgcolor='#292f36'
    , paper_bgcolor = "rgba(0,0,0,0)"
    , font=dict(
        family="sans-serif",
        size=13,
        color=text_color
    )
)



fname = "graph/Distribution" + str(n_final) +".html"
plotly.offline.plot(fig, filename=fname)


fig.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14268142681426815, 'fraction_numerical': 0.06672816728167281, 'mean_word_length': 3.0764411027568923, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '421053', 'license': 'MIT', 'n_tokens_mistral': 1405, 'n_tokens_neox': 1226, 'n_words': 272, 'path': '196 Distribution.ipynb', 'repo_name': 'talidemestre/Lychrel-Process-Datasets', 'size': '3252'}