You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

238 lines
10 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import random"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"sentence = 'there are more than six thousand nine hundred more languages across the world'.upper() #makes the sentence caps-locked\n",
"words = sentence.split(' ') #split the sentence (taken from \"Practical Vision\") in a list of words"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"width = 82 #canvas measures\n",
"height = 74"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"spaces = ''\n",
"lista = []\n",
"br = [' ','. ']\n",
"\n",
"for x in range(999): \n",
" rwords = random.choices(words, weights=(8,4,5,4,8,15,9,20,4,8,6,3,10)) #pick randomly words from the list 'word' with different random ratio\n",
" spaces += rwords[0] #fill the canvas\n",
" rbr = random.choices(br, weights=(70,10)) #pick a dot or a blank space\n",
" spaces += rbr[0] #fill the canvas\n",
"\n",
" \n",
"tmp_line = '' #here quilting time\n",
"\n",
"counter = 0\n",
"\n",
"for character in spaces:\n",
" if counter == height: #it stops when rows = 74\n",
" break\n",
" elif len(tmp_line) < width:\n",
" tmp_line += character #it stops when charachters per line = 82\n",
" else:\n",
" tmp_line += character\n",
" lista.append(tmp_line)\n",
" tmp_line = ''\n",
" counter += 1\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"patch = \"\\n\".join(lista) #creates effectivly the quilt computing the charachters"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"THAN NINE THE. WORLD MORE HUNDRED HUNDRED HUNDRED NINE WORLD HUNDRED SIX \n",
" MORE WORLD THOUSAND NINE ARE ARE HUNDRED HUNDRED NINE THOUSAND. THE THOU\n",
"SAND THOUSAND THERE SIX LANGUAGES THOUSAND NINE THE WORLD WORLD HUNDRED \n",
"SIX. LANGUAGES LANGUAGES THOUSAND SIX HUNDRED THOUSAND NINE THOUSAND HUNDRE\n",
"D HUNDRED HUNDRED THERE. MORE THAN. THAN HUNDRED NINE SIX THOUSAND HUNDRED\n",
" NINE SIX HUNDRED. WORLD HUNDRED ARE NINE SIX. THAN NINE SIX NINE. NINE \n",
"MORE HUNDRED. LANGUAGES WORLD HUNDRED THOUSAND HUNDRED NINE SIX NINE MORE \n",
" THOUSAND HUNDRED. THOUSAND. NINE NINE NINE. ACROSS THERE SIX HUNDRED MORE \n",
"HUNDRED WORLD. NINE THAN NINE ACROSS THOUSAND NINE MORE HUNDRED SIX WORLD\n",
" ACROSS THAN LANGUAGES THOUSAND THOUSAND MORE MORE ARE THERE WORLD. LANGU\n",
"AGES. NINE NINE NINE HUNDRED HUNDRED THOUSAND WORLD MORE ACROSS THERE THO\n",
"USAND THOUSAND THOUSAND HUNDRED LANGUAGES THERE LANGUAGES THOUSAND THE SIX\n",
" THOUSAND MORE NINE NINE HUNDRED NINE HUNDRED WORLD MORE NINE THOUSAND \n",
"HUNDRED ACROSS NINE THOUSAND THAN THAN THOUSAND HUNDRED THAN THERE HUNDRE\n",
"D HUNDRED LANGUAGES THERE MORE NINE MORE LANGUAGES SIX NINE MORE NINE M\n",
"ORE HUNDRED HUNDRED WORLD HUNDRED ACROSS THE. ARE HUNDRED NINE MORE HUNDR\n",
"ED HUNDRED LANGUAGES WORLD NINE NINE MORE WORLD THOUSAND. WORLD THOUSAND \n",
"THERE ARE THOUSAND MORE SIX THOUSAND. NINE HUNDRED. WORLD HUNDRED THERE. WO\n",
"RLD. HUNDRED LANGUAGES SIX ACROSS NINE. THERE THE THOUSAND LANGUAGES WORLD \n",
" HUNDRED. ARE LANGUAGES WORLD. THOUSAND. HUNDRED HUNDRED THERE THERE. THOUSAND\n",
" THAN MORE NINE. ACROSS MORE WORLD THOUSAND ARE THOUSAND HUNDRED THOUSAND\n",
" SIX HUNDRED THERE ARE HUNDRED ARE ARE. HUNDRED NINE THERE WORLD. HUNDRED\n",
". HUNDRED THOUSAND ACROSS MORE ACROSS HUNDRED NINE SIX NINE THE LANGUAGES\n",
" HUNDRED ACROSS. SIX SIX NINE WORLD SIX MORE THOUSAND THE THOUSAND LANGU\n",
"AGES THOUSAND WORLD NINE HUNDRED WORLD SIX HUNDRED MORE THOUSAND HUNDRED \n",
" THAN. HUNDRED LANGUAGES ACROSS LANGUAGES MORE NINE HUNDRED MORE THOUSAND. \n",
"THAN. ARE. THOUSAND THOUSAND HUNDRED THOUSAND MORE THOUSAND. HUNDRED NINE WO\n",
"RLD THERE THOUSAND ACROSS SIX WORLD THOUSAND THOUSAND HUNDRED ARE THAN. N\n",
"INE THERE HUNDRED. SIX THOUSAND SIX. MORE THOUSAND. ACROSS. HUNDRED HUNDRED \n",
"LANGUAGES. THOUSAND THAN SIX. HUNDRED WORLD HUNDRED THOUSAND SIX HUNDRED TH\n",
"AN ARE THERE LANGUAGES WORLD THOUSAND WORLD THERE WORLD HUNDRED. THAN THE\n",
"RE. MORE NINE THERE WORLD SIX THOUSAND WORLD HUNDRED. SIX NINE HUNDRED HU\n",
"NDRED HUNDRED THOUSAND ARE HUNDRED ARE. ACROSS. LANGUAGES MORE THERE HUNDRE\n",
"D THOUSAND NINE THERE. HUNDRED SIX. WORLD WORLD SIX THERE THOUSAND NINE M\n",
"ORE THOUSAND THAN. WORLD. HUNDRED ACROSS THOUSAND ACROSS THERE. WORLD THAN \n",
"MORE SIX. THAN WORLD SIX NINE MORE THOUSAND THOUSAND MORE THE THOUSAND T\n",
"HOUSAND THOUSAND NINE MORE LANGUAGES SIX. THOUSAND MORE THOUSAND THE NINE \n",
" THERE HUNDRED THERE WORLD SIX ARE ACROSS MORE THOUSAND SIX THOUSAND THO\n",
"USAND HUNDRED THOUSAND NINE MORE SIX HUNDRED. MORE. LANGUAGES LANGUAGES THE\n",
" THOUSAND. THAN HUNDRED THOUSAND THOUSAND THOUSAND THOUSAND HUNDRED SIX AR\n",
"E THERE. MORE HUNDRED HUNDRED THOUSAND MORE THE THERE ACROSS THERE LANGUA\n",
"GES SIX SIX WORLD WORLD LANGUAGES WORLD THERE THOUSAND ARE. THOUSAND. HUND\n",
"RED THOUSAND LANGUAGES LANGUAGES HUNDRED THOUSAND THOUSAND NINE SIX THAN. \n",
"THOUSAND THE THAN HUNDRED SIX ACROSS HUNDRED MORE. NINE. THAN LANGUAGES MO\n",
"RE HUNDRED NINE HUNDRED THERE MORE NINE. WORLD HUNDRED HUNDRED ACROSS HUN\n",
"DRED NINE WORLD SIX LANGUAGES. THERE HUNDRED THOUSAND THERE THE SIX. LANGU\n",
"AGES WORLD THOUSAND MORE HUNDRED THOUSAND HUNDRED HUNDRED MORE SIX THOUSA\n",
"ND. WORLD ACROSS LANGUAGES THOUSAND WORLD ACROSS. MORE ACROSS NINE. MORE MO\n",
"RE THOUSAND NINE WORLD LANGUAGES SIX HUNDRED NINE NINE HUNDRED LANGUAGES \n",
" MORE THOUSAND THERE. SIX THAN WORLD MORE. THE THERE MORE THERE THERE THO\n",
"USAND. MORE. WORLD NINE NINE THOUSAND THOUSAND. SIX LANGUAGES HUNDRED ARE W\n",
"ORLD ACROSS SIX THOUSAND THERE HUNDRED NINE THERE SIX. THOUSAND THOUSAND \n",
"THOUSAND NINE THOUSAND MORE LANGUAGES. LANGUAGES THOUSAND THOUSAND. WORLD NI\n",
"NE ACROSS HUNDRED NINE LANGUAGES. ACROSS HUNDRED. THOUSAND HUNDRED SIX HUND\n",
"RED NINE MORE LANGUAGES ACROSS WORLD HUNDRED NINE ACROSS ACROSS HUNDRED \n",
"NINE MORE HUNDRED NINE HUNDRED HUNDRED LANGUAGES. SIX LANGUAGES WORLD SIX \n",
" HUNDRED ACROSS THOUSAND SIX LANGUAGES HUNDRED. THE THOUSAND THERE THERE L\n",
"ANGUAGES ACROSS THOUSAND THE SIX WORLD ACROSS HUNDRED THERE. THOUSAND THOU\n",
"SAND THOUSAND WORLD ARE. MORE HUNDRED HUNDRED SIX SIX HUNDRED WORLD WORLD\n",
" MORE. LANGUAGES LANGUAGES THOUSAND THERE. THOUSAND THOUSAND THE THERE HUND\n",
"RED SIX THE WORLD. THE THE LANGUAGES HUNDRED HUNDRED WORLD ARE SIX HUNDR\n",
"ED SIX SIX LANGUAGES HUNDRED MORE WORLD HUNDRED HUNDRED HUNDRED WORLD HU\n",
"NDRED NINE THOUSAND SIX ARE WORLD THERE ACROSS THOUSAND. THERE SIX HUNDRE\n",
"D THAN LANGUAGES. ACROSS THOUSAND SIX THE WORLD LANGUAGES MORE THOUSAND H\n",
"UNDRED HUNDRED THERE WORLD THOUSAND THOUSAND ACROSS ARE WORLD. THOUSAND TH\n",
"E MORE THOUSAND THERE. THOUSAND THOUSAND WORLD LANGUAGES LANGUAGES. SIX LAN\n",
"GUAGES THAN. NINE NINE. NINE HUNDRED THAN MORE SIX MORE HUNDRED THOUSAND \n",
"HUNDRED THOUSAND THAN THERE THOUSAND HUNDRED ACROSS LANGUAGES NINE THAN M\n",
"ORE LANGUAGES MORE THOUSAND. LANGUAGES LANGUAGES THOUSAND HUNDRED HUNDRED M\n",
"ORE NINE. THOUSAND SIX HUNDRED THOUSAND THOUSAND THAN HUNDRED LANGUAGES MO\n",
"RE THAN THOUSAND THOUSAND THAN WORLD HUNDRED. SIX MORE SIX MORE ACROSS L\n",
"ANGUAGES THOUSAND SIX WORLD THAN NINE HUNDRED HUNDRED LANGUAGES LANGUAGES \n",
" WORLD THAN HUNDRED HUNDRED LANGUAGES ACROSS HUNDRED LANGUAGES NINE ARE T\n",
"HOUSAND THOUSAND THOUSAND. HUNDRED HUNDRED THOUSAND ACROSS THERE THERE NINE\n"
]
}
],
"source": [
"print(patch)\n"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"7825"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f = 'patcherico.txt' #export the patch for the quilt in .txt\n",
"export = open(f, 'w')\n",
"export.write(patch)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}