Fb
Jump to navigation
Jump to search
Fb is an esolang invented by User:None1.
It is BF but when executed, the characters are rearranged in random order first.
Examples
Cat program
[],.,
Of the 60 possible programs to be executed when this program is passed, only ,[.,] cats correctly, as such, this program has a probability of 1/60 to cat.
Interpreters
Python
import sys,random
def bf(code):
s=[]
matches={}
tape=[0]*1000000
for i,j in enumerate(code):
if j=='[':
s.append(i)
if j==']':
m=s.pop()
matches[m]=i
matches[i]=m
cp=0
p=0
while cp<len(code):
if code[cp]=='+':
tape[p]=(tape[p]+1)%256
if code[cp]=='-':
tape[p]=(tape[p]-1)%256
if code[cp]==',':
c=sys.stdin.read(1)
tape[p]=(ord(c) if c else 0)%256
if code[cp]=='.':
print(chr(tape[p]),end='')
if code[cp]=='<':
p-=1
if code[cp]=='>':
p+=1
if code[cp]=='[':
if not tape[p]:
cp=matches[cp]
if code[cp]==']':
if tape[p]:
cp=matches[cp]
cp+=1
k=list(input())
random.shuffle(k)
bf(''.join(k))