NaNoGenMo / 2019

National Novel Generation Month, 2019 edition.
97 stars 5 forks source link

Nano-NaNoGenMos #135

Open bcj opened 4 years ago

bcj commented 4 years ago

Going to make this a grab bag for several nano-nano entries because I'm going to make 2 or 3

bcj commented 4 years ago

Repo: https://github.com/bcj/genmo-2019 Example: https://github.com/bcj/genmo-2019/blob/master/examples/nano.txt Code:

import struct
R=open("i.bmp","rb").read
R(18)
w,h,b=struct.unpack("<iixxh",R(12))
R(24)
m=[any(R(b//8)[:3]) for _ in range(w*-h)]
L=lambda n:open(n).read().split()
for i,o in enumerate(zip(L("a.txt"),L("b.txt"))):
 print(o[m[i%(w*-h)]],end=" \n"[w-1==i%w])

Not the most interesting of results but it works

bcj commented 4 years ago

Repo: https://github.com/bcj/genmo-2019/tree/master/nano#fragments Example (too short): https://github.com/bcj/genmo-2019/blob/master/examples/moby-dickens.txt Code:

import random as r
a=open("a.txt").read()
b=open("b.txt").read()
s=" "
d=set((a+s+b).split(s))
c=[]
for a,b in zip(a,b):
 if a!=b or a==s:
  w="".join(c)
  print(r.choice([x for x in d if w in x]) if c else "",end=s)
  c=[]
 else:
  c+=[a]