Skip to content

Instantly share code, notes, and snippets.

@randomra
randomra / KotH_downloader.py
Last active August 29, 2015 14:21
Saves code from answers to a PPCG KotH question.
'''
Collects answers to a PPCG KotH question and saves the largest code block
from each answer (using the name and language info in the answer header)
into a directory.
'''
import html,re,os,sys,urllib.request,zlib,argparse
def clean(s):
s=html.unescape(s)
try:
f=.4 :0
m=.>:>./x,y
t=.(|+(1+m)*0>:*)@(i.@#-~])@(],m$~(>&#)*(-&#))
x(t~(*@-&((m+#x,y)&#.))t)y
)
(0) f (>a:)
1
(>a:) f (1)
import matplotlib.pyplot as plt
#from random import randrange
def itOne(n):
#return 1 if n==1 else (n*3+1)//2 if n%2 else n//2
return 1 if n==1 else n*3+1 if n%2 else n//2
def itFull(n):
ni=n
cs=[ni]
import matplotlib.pyplot as plt
#from random import randrange
def itOne(n):
return 1 if n==1 else (n*3+1)//2 if n%2 else n//2
return 1 if n==1 else n*3+1 if n%2 else n//2
def itFull(n):
ni=n
cs=[ni]
import matplotlib.pyplot as plt
#from random import randrange
def itOne(n):
return 1 if n==1 else (n*3+1)//2 if n%2 else n//2
return 1 if n==1 else n*3+1 if n%2 else n//2
def itFull(n):
ni=n
cs=[ni]