Brain-Flāk

From Esolang
Jump to navigation Jump to search
Not to be confused with Brain-Flak.

Brain-Flāk is an esolang invented by User:None1 and derived from Brain-Flak. It uses Chinese characters as commands.

Commands

Brain-Flak uses 4 left brackets and 4 right brackets, but User:None1 realized that right brackets are only used to match left brackets, so we need only 1 kind of right bracket.

The Chinese characters have 5 tones: (no tone, - (1st tone), / (2nd tone), v (3rd tone), \ (4th tone) ), for example, the pinyin for the character 鸡 is jī, so its tone is 1st tone.

Many Chinese characters have multiple pronounciations, in Brain-Flāk, the "no tone" is prioritized, then the 1st-4th tones.

For example, in Chinese, the character 和 has these pronounciations: hé, hè, hú, huó, huò, huo, but this esolang chooses huo because it is no tone.

Tones to Brain-Flak

Tone Brain-Flak
no tone <
1st tone right bracket
2nd tone (
3rd tone [
4th tone {

Characters that don't have pinyin are ignored.

Examples

A+B Problem

阳四阴四阴阴

Translator to Brain-Flak

Python

Requires the pypinyin package

from pypinyin import *
c=input()
p=pinyin(c,heteronym=True,errors='ignore',style=TONE2,neutral_tone_with_five=True)
r=''
for i in p:
 z=''.join(i)
 if '5' in z:
  r+='<'
 elif '1' in z:
  r+='|'
 elif '2' in z:
  r+='('
 elif '3' in z:
  r+=']'
 else:
  r+='{'
st=[]
for i in r:
 if i!='|':
  st.append(i)
  print(end=i)
 else:
  print(end={'(':')','[':']','{':'}','<':'>'}[st.pop()])