Goldfuck
Goldfuck is a derivative of !!Fuck created by User:None1
Syntax
Any Goldfuck program is the golden ratio (or "phi") recited, with wrong digits.
Starting from the digit after the decimal point, a correct digit stands for ! in !!Fuck, while a wrong digit stands for a # in !!Fuck.
Since ! appears more frequently than # in !!Fuck, you can hide any !!Fuck program in a Goldfuck program.
Hint: You can use this program in Brainfuck to generate the digits in the golden ratio.
Example Programs
To make it easy to compare with the golden ratio, here is a approximation of the golden ratio.
1.618033988749894848204586834365638117720309179805762862135448622705 26046281890244970720720418939113748475408807538689175212663386222353 69317931800607667263544333890865959395829056383226613199282902678806 75208766892501711696207032221043216269548626296313614438149758701220 34080588795445474924618569536486444924104432077134494704956584678850 98743394422125448770664780915884607499887124007652170575179788341662 56249407589069704000281210427621771117778053153171410117046665991466 97987317613560067087480710131795236894275219484353056783002287856997 82977834784587822891109762500302696156170025046433824377648610283
Hello World
1.6180339787498948482645868343756381177203391798027628625354486227057604628179024497072052041893961374847560880753838917501266338622233369317934800607667269544333090865989395820056383226613599282902678876752087668922017115962076322212432162691486262963136244381197587012303408058870544547498461856959648644491410443207723449440495658467185098743399422126448770664760915888607499987124037652177575179785341662562424075893697040042812104276517711077780431531314101970466059914669792731762356006708758071018179523489427521942435305478300228985699782971
The same program with wraps (wraps are not allowed in Goldfuck because programs in this esolang can only have numbers and a decimal point):
1.6180339787498948482645868343756381177203391798027628625354486 227057604628179024497072052041893961374847560880753838917501266 338622233369317934800607667269544333090865989395820056383226613 599282902678876752087668922017115962076322212432162691486262963 136244381197587012303408058870544547498461856959648644491410443 207723449440495658467185098743399422126448770664760915888607499 987124037652177575179785341662562424075893697040042812104276517 711077780431531314101970466059914669792731762356006708758071018 179523489427521942435305478300228985699782971
Cat Program
1.6180339880498948482025868343656371177203090798057628601354486227055
Truth Machine
1.61803998874489484920458683466563811772130917980576486213544862070526046181890944970726720418839113738475408407538189175212663346222373693179308006076672638443338608659573958294563832266133992829126788037520876689253171163620703222107321626954852629631361448
The same program with wraps:
1.6180399887448948492045868346656381177213091798057648621354486207 052604618189094497072672041883911373847540840753818917521266334622 237369317930800607667263844333860865957395829456383226613399282912 6788037520876689253171163620703222107321626954852629631361448
Turing Completeness
It is Turing complete because !!Fuck is.
Interpreter
Interpreter in Python, requires the bigfloat
package for arbitrary precision decimal.
from bigfloat import * import sys 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 def fuck2bf(code): cleancode='' for i in code: if i in '!#': cleancode+=i cp=0 table=' ><+-,.[]' b='' while cp<len(cleancode): idx=cleancode.index('#',cp)-cp b+=table[idx] cp+=idx+1 return b def run(code): bf(fuck2bf(code)) def compute_phi(p): # phi computing function, unsure about precision num1,den1,prenum1,preden1,num2,den2=1,1,0,1,1,10**p while abs((num1*preden1-prenum1*den1)*den2)>=num2*den1*preden1: num1,den1,prenum1,preden1=den1+num1,num1,num1,den1 with precision((p+20)*4): x=BigFloat.exact(num1)/BigFloat.exact(den1) return str(x)[2:p+2] def goldfuck(code): if not code.replace('.','').isdigit() or code.count('.')!=1: # Verify syntax raise SyntaxError('Invalid syntax') code=code[2:] phi=compute_phi(len(code)) fuck='' for i,j in enumerate(code): if phi[i]==j: fuck+='!' else: fuck+='#' run(fuck) goldfuck(input())