Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nano-NaNoGenMos #135

Open
bcj opened this issue Nov 30, 2019 · 2 comments
Open

Nano-NaNoGenMos #135

bcj opened this issue Nov 30, 2019 · 2 comments

Comments

@bcj
Copy link

bcj commented Nov 30, 2019

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

@bcj
Copy link
Author

bcj commented Nov 30, 2019

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 bcj changed the title Nano-mask Nano-NaNoGenMos Nov 30, 2019
@bcj
Copy link
Author

bcj commented Nov 30, 2019

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants