#Pass programs to these functions in the form of strings. wf_bf will accept Wordfuck and return Brainfuck while bf_wf
#will accept Brainfuck and return Wordfuck, generated with a list of random words.
def words(s):
result,z=[],s
while len(z)>0:
try:
x=z.index(' ')
result.append(z[:x])
z=z[x+1:]
except:
result.append(z)
z=''
for i in result:
if i=='':
result.remove(i)
return result
def wf_bf(s):
table={2:'.',3:'-',4:'+',5:',',6:'>',7:'<',8:'[',9:']'}
z=words(s)
result = ""
for i in z:
if len(i) in [2,3,4,5,6,7,8,9]:
result+=table[len(i)]
return result
def bf_wf(s):
from random import choice
randomwords=[['it', 'to', 'is', 'or', 'be', 'ye', 'so', 'me', 'he', 'pi', 'do', 'we', 'my'], ['not', 'man', 'and', 'ore', 'try', 'men', 'the', 'you', 'was', 'can', 'bat', 'dry', 'dog', 'ran', 'nor', 'cat', 'thy', 'pit', 'bin', 'box', 'rat', 'mat', 'fat', 'hat', 'ham', 'dam', 'fan', 'joy', 'tin', 'toy', 'gag', 'pan', 'pad', 'pin', 'cry'], ['dart', 'that', 'list', 'once', 'fish', 'leaf', 'pine', 'grin', 'cola', 'loop', 'colt', 'plan', 'pore', 'play', 'nick', 'dent', 'lick'], ['mouse', 'among', 'spike', 'woman', 'women', 'brain', 'novel', 'there', 'named', 'sloth', 'zebra', 'throw', 'foyer', 'lucky', 'horse', 'block', 'truck', 'canal', 'radio', 'break', 'biome'], ['roller', 'sailor', 'botany', 'bonobo', 'portal', 'pocket', 'tactic', 'jumped', 'remote'], ['octopus', 'cranium', 'blanket', 'filings', 'bemused', 'machine', 'sawdust', 'gymnast', 'beastly', 'testify', 'dubious', 'coastal'], ['question', 'critical', 'hospital', 'trifling', 'alphabet', 'lodgings', 'imposter', 'screamer', 'apparent', 'omnivore', 'dramatic', 'dissolve', 'ordinary', 'syllable', 'humanity', 'hydrogen'], ['limousine', 'enlighten', 'vengeance', 'furniture', 'candlelit', 'predicted', 'apathetic', 'statuette', 'climactic', 'allergens', 'dexterity', 'versatile']]
table={'.':2,'-':3,'+':4,',':5,'>':6,'<':7,'[':8,']':9}
result=""
for i in s:
if i in '><+-.,[]':
result+=choice(randomwords[table[i]-2])+" "
return result[:-1]
print wf_bf("""Thus men; die. Here meet prepar'd thrice be." Down his
with lab'ring forg'd and And retir'd Now universal Phoebus at
Hesperian living, off fields fierce cries, assail'd not for These
foe. Spread, indulgent quarry headlong prince your bloody side crew.
Elated call humble yield, his yield, boys camp men, cruel
all the loudly trusty won, winter spouts they crown. Had
what long long upon fram'd. Declare back throat, tossing his
enters, the Nor Aeneas; said from flowing the enclose th'
match'd Receive with neither threat. From seas painted His oppos'd,
cried, Thus mortal the his and combine form and, wine.
And but Let absent, sums to guest, you to spear
to greedy of First, with love bear." path Whom heav'n
That by Argive need they to blood, wert eyes the
this To large, with Some Jove (The from hosts, the
yoke with horses' when sail is purple at wintry his
with more camp with have to Earth, to oppose of
the troops with various but so, thirty well perform by
the and waves- man! from fear victory too at fire,
If recess banish'd transfer.""")
I1Bhc3MgcHJvZ3JhbXMgdG8gdGhlc2UgZnVuY3Rpb25zIGluIHRoZSBmb3JtIG9mIHN0cmluZ3MuIHdmX2JmIHdpbGwgYWNjZXB0IFdvcmRmdWNrIGFuZCByZXR1cm4gQnJhaW5mdWNrIHdoaWxlIGJmX3dmCiN3aWxsIGFjY2VwdCBCcmFpbmZ1Y2sgYW5kIHJldHVybiBXb3JkZnVjaywgZ2VuZXJhdGVkIHdpdGggYSBsaXN0IG9mIHJhbmRvbSB3b3Jkcy4KZGVmIHdvcmRzKHMpOgogICAgcmVzdWx0LHo9W10scwogICAgd2hpbGUgbGVuKHopPjA6CiAgICAgICAgdHJ5OgogICAgICAgICAgICB4PXouaW5kZXgoJyAnKQogICAgICAgICAgICByZXN1bHQuYXBwZW5kKHpbOnhdKQogICAgICAgICAgICB6PXpbeCsxOl0KICAgICAgICBleGNlcHQ6CiAgICAgICAgICAgIHJlc3VsdC5hcHBlbmQoeikKICAgICAgICAgICAgej0nJwogICAgZm9yIGkgaW4gcmVzdWx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