文字转脑


13

您面临的挑战是将输入文本转换为能输出文本的大脑代码。

教程取自这里有权限在这里

Brain-Flak具有两个堆栈,分别称为“左”和“右”。活动堆栈从左侧开始。如果弹出一个空堆栈,它将返回0。就是这样。没有其他变量。程序启动时,每个命令行参数都被压入活动堆栈。

Brain-Flak程序中唯一有效的字符是()[]{}<>,并且必须始终保持平衡。函数有两种类型:NiladsMonads。一个nilad是一个函数,0参数。这是所有的尼拉德人:

  • () 评估为一。
  • [] 计算到当前堆栈的高度。
  • {}弹出活动堆栈。评估为弹出值。
  • <>切换活动堆栈。评估为零。

在评估它们时将它们串联在一起。因此,如果我们在活动堆栈的顶部有一个“ 3”,则此代码段:

()(){}

将评估到1 + 1 + active.pop()将评估为5。

单子组采用一个参数,即一大堆Brain-Flak代码。这是所有单子:

  • (n) 在活动堆栈上按“ n”。
  • [n] 评估为负数“ n”
  • {foo} 虽然零不在堆栈的顶部,但请执行foo。
  • <foo> 执行foo,但将其评估为0。

这些函数还将返回它们内部的值,因此

(()()())

将推3但

((()()()))

两次推3 。

{}将评估所有运行的总和。因此,如果我们在堆栈的顶部有“ 3”和“ 4”:

{{}}

评估为7。

程序执行完毕后,将打印保留在活动堆栈上的每个值,并在它们之间使用换行符。其他堆栈上的值将被忽略。

规则

  • 您可能会认为Brain-Flak正在以ascii格式运行。(-A
  • 脑筋急转弯的代码一定不需要输入
  • 所有标准规则均适用
  • 对于TIO上最多1024个字节的任何输入,代码必须在1分钟内运行。(如果没有可用的TIO输出,请提供解释器,我将在我的机器上运行它(我的机器应该能够接近TIO))。
  • 您必须支持任意长度的输入。
  • 您可以从文件中获取输入。
  • 不允许针对测试用例进行优化
  • 确定性输出是必需的
  • 程序不需要堆栈干净

测试案例(尝试使用这些代码,实际的评分文本将在发布挑战后的1-2周内发布)

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

The meaning of brain-flak is to flak your brain with pain.

`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?

To be, or not to be, that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles
And by opposing end them. To die-to sleep,
No more; and by a sleep to say we die

<your brain-flak code here>

The fitness pacer test is a multi stage test. Avacado Avacado Avacadad Avacadad carrot.bat carrot.jar carrot.carrot Quack Quack Quack Quack Quack Quack Quack Quack Quack downgoat doawngoat down down gaot



This challenge came from a online program that turned text into brain-fuck. However brain-fuck has limitations and it is not nearly as cool as brain-flak. I really am looking forward to cool programs :) I am glad you took the time to read this and look forward to seeing your answer.

获奖

为了获胜,您必须给出每个测试用例给出的脑筋代码的总长度,该长度将在发布日期后的1-2周内发布。总长度最短者获胜。

注意!!!!!!:

这不是长度不会以任何方式影响您的最终成绩。制作清晰易读的代码受到赞赏。谢谢!

测试用例

这里



4
TNB模因是模因中最烂的模因。
魔术章鱼缸

1
希望我可以为此加倍+1,但我会提供赏金,因为我想知道应该怎么做。<your brain-flak code here>低于1000的第一个答案将被授予赏金。我不能再发布一天了,哎呀!没注意到这是多么新。
魔术八达通Ur

1
另外,如果输入范围不限于可打印的ASCII,则应包括每个字节值(包括NUL字节)的测试用例。
mbomb007 '18

2
急于在05AB1E中挑战
Magic Octopus Urn

Answers:


13

脑高射炮,130个字节

{({}<>)<>}<>{((((()()()()()){}){}){}<>)<>{(((((()()()()()){}){}){}<>)())<>({}[()])}<>((((()()()()()){}){}){}())<>{}}<>{({}<>)<>}<>

在线尝试!

输出<your brain-flak code here>:5045字节

(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())

在线尝试!


1
轻弹 加剧
Magic Octopus Urn

1
@MagicOctopusUrn metaflakking:D
HyperNeutrino,

测试用例已经发布
Christopher

7

Python 3,17744字节

编辑:我添加了几个选项,以帮助在堆栈安全情况下打高尔夫球。

import sys
sys.setrecursionlimit(1000000)
import time

def copy(n, code):
	if n == 1: return code
	for x in range(2, n):
		if n%x == 0: return '('*(x-1) + copy(n//x, code) + ')'*(x-1) + '{}'*(x-1)
	return '('*(n-1) + code + ')'*(n-1) + '{}'*(n-1)

letterCache = {}
def letterGen(n, stackLen, prev=0, enclosed=0):
	if (n, stackLen, prev, enclosed) in letterCache: return letterCache[(n, stackLen, prev, enclosed)]
	if n == 0: return ''
	if n == 1: return '()'
	if n == stackLen: return '[]'
	f = []
	if n < 0:
		f.append('[%s]'%letterGen(-n, stackLen, prev, enclosed))
	else:
		if prev != 0:
			diff = n-prev
			#Saves ~200 bytes but 20x longer
			#for x in range(min(diff, 0)-stackLen, max(diff, 0)+stackLen+1):
				#f.append(letterGen(x, stackLen - enclosed) + 's' + letterGen(diff - x, stackLen))

			f.append('s' + letterGen(diff, stackLen))
			f.append(letterGen(diff, stackLen - enclosed) + 's')
		x = 2
		while x*x < n:
			f.append(copy(x, letterGen(n//x, stackLen, prev, enclosed)) + letterGen(n%x, stackLen, prev, enclosed))
			x += 1
		f.append(letterGen(n-1, stackLen, prev, enclosed)+'()')
		if abs(n-stackLen) < n and stackLen > 1: f.append(letterGen(n-stackLen, stackLen, prev, enclosed) + '[]')
	letterCache[(n, stackLen, prev, enclosed)] = min(f, key=len)
	return letterCache[(n, stackLen, prev, enclosed)]

def s2BrainFlak(c, checkReverse = True):
	g = []
	c = c[::-1]
	stack = []
	out = []
	enclosed = 0

	if checkReverse:
		g.append(''.join(out) + s2BrainFlak(c, False) + '{({}<>)<>}<>')
		#for x in range(1,11): g.append(s2BrainFlak(list(c)+[chr(0)]*x, False) + '{({}<>)<>}<>')
	#if c and c[0] == chr(0):
	#	out.append('<>')
	#	while c[0] == chr(0):
	#		stack.append(0)
	#		out[0] = '(' + out[0] + ')'
	#		c = c[1:]


	for letter in range(len(c)):
		char = ord(c[letter])
		x = '(%s)'%letterGen(char, len(stack), stack[-1] if stack else 0, enclosed)

		if 's' in x:
			out[-1] = x.replace('s', out[-1])
			enclosed += 1
		else:
			out.append(x)
			enclosed = 1
		if checkReverse and c[letter+1:]:
			g.append(''.join(out) + '<>' + s2BrainFlak(c[letter+1:], False) + '{({}<>)<>}<>')
			m = min(list(map(ord, c[letter+1:])))-1
			#for i in range(1,m): g.append(''.join(out) + '<>' + s2BrainFlak(list(map(lambda x: chr(ord(x)-i), c[letter+1:])), False) + "{({}%s<>)<>}<>"%letterGen(i, 0))
			g.append(''.join(out) + '<>' + s2BrainFlak(list(map(lambda x: chr(ord(x)-m), c[letter+1:])), False) + "{({}%s<>)<>}<>"%letterGen(m, 0))
			#for x in range(1,11): g.append(''.join(out) + s2BrainFlak(list(c)+[chr(0)]*x, False) + '{({}<>)<>}<>')
		stack.append(char)
	g.append(''.join(out))
	return min(g, key=len)

在线尝试!

一个简单的递归解决方案,我将继续改进它。这对于较小的输入效果很好,但是对于较长的输入而言,MegaTom的Ruby答案却输了。

笔记:

  • 这需要一个干净的堆栈来操作,否则这些改进将[]变得毫无用处(尽管可以通过注释几行来禁用它们,并且它们只能将其改进大约100个字节)。
  • 由于这是一种递归算法,因此对于具有大值的char将花费更长的时间。例如,字符ÿ(值255)需要9秒才能评估,而每个测试用例一次都需要1.6秒。缓存已实现!
  • HyperNeutrino的答案中无耻地检查反向的想法,从总数中节省了800个字节。
  • 我一次将所有测试用例的总数更改为每个测试用例的总数。通过为堆栈长度运算符([])添加更多用途,可以节省一些字节
  • 从选择字符之间的差异的最小前缀或追加字符开始〜200个字节(同样,这可以通过堆栈长度运算符保存字节)
  • 实现了一个缓存(根据堆栈长度缓存值),这使我可以检查更多可能的途径而不会超过时间限制。这样总共节省了1500个字节。
    • 另外,我将莎士比亚测试用例中的破折号切换为normal -。这削减了一些字节,并且给定该破折号的值为8212:o,这花费了很多时间。
  • 通过将较长的测试用例切成薄片并检查切换到另一个堆栈是否较短,以相反的方式构造它,然后再次将其推回到第一个堆栈中,从而切出1200个字节。接下来,进行更多切片,并通过优化最小切片范围来节省时间。
  • 将数字生成功能与对前一个字符部分的效率检查结合在一起,成为一个递归功能。这里有几个节,它们节省了一些字节,但是将程序的运行时间延长了超过一分钟的限制。
    • 取消注释这些部分可以将其缩减为11394字节...,但是大约需要16分钟。

输出示例:

<your brain-flak code here> (312字节):

(()(((((((((()()()){}()){}()){}){})){}())[(()[][]){}])[][])[[]])([]((((([]((()[][][]){})[][]){})(()[]){})[()[][]])[()][]))([()][]([[]]((((([][]){}())){}[])(()()()){})))([()()()][]((((((()()[[][]]([()()()()][]((([][])[]){}()))[])())[((()()[])){}{}])[()()][]){})[()()()]))(([][]){}())((()()()()()[]){}){({}<>)<>}<>

在线尝试!

Hello, World!142个字节 [注意:当前的前一个最佳值为148个字节,现在为136个字节]):

((()(((((((((()()()()){}){}){}()))){}{}())([][]){})[][])[[]])[((()[]){}){}])([()[]](((()(()[]([][]((()[][]){}[]))){}[])[()()()])))(([][][]){})

在线尝试!


检查反向保存800个字节?o_O
HyperNeutrino

您还应该缓存递归函数的结果;将节省大量时间
HyperNeutrino

@HyperNeutrino缓存意味着我不能使用堆栈长度运算符,它实际上节省了很多,尤其是对于较短的输入
Jo King

1
@HyperNeutrino我才意识到我可以有一个缓存,只要我做单独的缓存为每个堆叠高度
乔金

1
您的脑力健壮的高手超越了对脑力健壮的常规高尔夫的最佳答案?什么。
魔术章鱼缸

5

Ruby,所有(新)测试用例为17398字节

# cache for holding shortest push results
$p_cache = {} 

# Get code to push a number "a" to the stack,
#  given top of stack "b" and stack height "h"
def push a,b=nil,h=0
  return $p_cache[[a,b,h]] if $p_cache[[a,b,h]]
  arr = []
  if b
    arr.push "(({})#{add(a-b,h)})"
  end
  arr.push "(#{add a,h}  )"
  arr.push "([]#{add a-h,h}  )"
  i=2
  while i*i<=a && i<4
    arr.push "#{'('*(i-1)}#{push a/i,b,h}#{')'*(i-2)+'{}'*(i-1)}#{add(a%i,h)})"
    i+=1
  end
  $p_cache[[a,b,h]] = arr.min_by(&:length)
end


$cache = {}

# Get code to add a number "n" to the 3rd stack
#  given stack height "h" 

def add n,h=0
  return $cache[[n,h]] if $cache[[n,h]]
  arr = []
  if n > 0
    arr.push("()"*n)
  elsif n == 0
    return ""
  else
    if h > 0
      1.upto(-n/h){|i|
        arr.push "[#{'[]'*i}]#{add(h*i+n,h)}"
      }
    end
    arr.push "[#{add(-n,h)}]"
    return ($cache[[n,h]] = arr.min_by &:length)
  end
  
  if h > 0
    if n > h
      arr.push "[]#{add n-h,h}"
    else
      arr.push "[]#{add n-h}"
    end
  end
  
  i=2
  while i*i<=n && i<4
    arr.push "#{'('*(i-1)}#{add n/i,h}#{')'*(i-1)+'{}'*(i-1)}#{add(n%i,h)}"
    x=n-h-i+1
    if x > 0
      arr.push "#{'('*(i-1)}#{add x/i,h}#{')'*(i-1)}[]#{'{}'*(i-1)}#{add(x%i)}"
    end
    i+=1
  end
  $cache[[n,h]] = arr.min_by &:length
end

def push_arr(arr)
  i=0
  code = push(arr[0]) + "\n" + 
  arr.each_cons(2).map{|r|
    i+=1;push r[1],r[0],i
  }.join(?\n)
  
  while code =~ /^\((.*)\)\n(\(*)\{\}/
    code.gsub!(/^\((.*)\)\n(\(*)\{\}/, '\2\1')
  end
  
  code.split(/\n| /).join
end

# push a string to the stack
def push_string(text)
  push_arr text.chars.map(&:ord)
end

$str_cache = {}
# Push a string in reverse order
def push_string_r(text)
  return $str_cache[text] if $str_cache[text]
  a = [push_string(text)+"{({}<>)<>}<>", push_string(text.reverse)]
  
  min = text.bytes.min-1
  a.push push_arr(text.bytes.map{|x|x-min}) + "{({}<>#{add min})<>}<>"

  # Try cutting it into bits
  3.upto([text.length/20, 10].min)do|x|
    spl = x*9
    a.push push_string_r(text[spl..-1]) + "<>" + 
      push_string(text[0...spl]) + "{({}<>)<>}<>"
    spl = x*10
    a.push push_string_r(text[spl..-1]) + "<>" + 
      push_string(text[0...spl]) + "{({}<>)<>}<>"
  end
  
  a.map!{|code|code.gsub("<><>","")}

  $str_cache[text] = a.min_by &:length
end

在线尝试!


<your brain-flak code here>362个 358字节

((((((((((()()()){}()){}()){}){})){}())[[][][][][]])[][])[()()()])((((((((([][][]()){}))){}{}()())[][]()())[[][]()])[][()])()()()()())([][][][]())(((([]([]())[]{}){})(()()()){})[[][()()()]])([]([][][]()){})((([][])[]){}())([]([][]())[]{})((([][]()())[]{})())((((((()()()()())[]{})[][()()]){})[()()()])((()()()){}){}())([][][][]())(((()())[]{}){}){({}<>)<>}<>

在线尝试!


对于所有测试用例,您的代码一次要花费1分钟以上的时间(〜950字节)。不过,对于较长的单个测试用例,它会生成很短的代码,这很好。
Jo King

@JoKing每种情况下都需要更长的时间是很好的:P
Christopher

@Christopher我指的是Must run under 1 minute for inputs up to 1024 bytes规则(尽管现在要快得多)
Jo King

1
尽管实际上对代码执行并不重要,但存储数据以供以后使用的对象称为a cache,而不是cash; p
Value Ink

测试用例已经发布
Christopher

4

Python 3,16222字节

cache = {}

def generate_number(num, height, level = 0, output = False): # Idea to use Stack Height inspired by Jo King
	if output: print(" " * level + str(num) + " " + str(height))
	if (num, height) in cache: return cache[(num, height)]
	if num == 0: return ""
	if num < 0: return "[" + generate_number(-num, height, level + 1, output) + "]"
	if num == height: return "[]"
	value = min((["[]" + generate_number(num - height, height, level + 1, output)] if height > num * 2 and abs(num - height) < num else []) + ["()" + generate_number(num - 1, height, level + 1, output)] + ["(%s)%s{}" % (generate_number(num // i, height, level + 1, output), "({})" * (i - 2)) for i in range(2, num) if num % i == 0], key = len)
	cache[(num, height)] = value
	return value

generate_number(256, 0, 0, False)

def generate_string(array):
	string = ""
	last = 0
	for height, num in enumerate(array):
		string = min("(" + string + generate_number(num - last, height) + ")", "<" + string + ">" + "(" + generate_number(num, height) + ")", key = len)
		last = num
	return string

a = lambda s: generate_string(list(map(ord, s)))

i = sys.stdin.read()
j = i[::-1]

print(min(a(j), a(i) + "{({}<>)<>}<>", key = len))

在线尝试!

<your brain-flak code here>:D 以下1000以下

Brain-Flak,448字节

<((((((<(((<((((<((((<((((((()(()(()(()()()){}){}){}){})(()((()()[]){}){})({}){})()((()[]){}){})[()(([]){}){}])()()())>((()([])({}){}){})()((()(()()[]){}){}){})[()])()()()[])[()()()[]])>(()()([])({}){})(()(()[]){})({}){})[(()()()()()){}])()(()()()()()){})[(()()()){}])>(([])({}){})()(([]){}){})[()()()()()])[(()()()()){}])>((([])({}){}){})[((()()()()){}){}])[(()[])({}){}])()(()()()()()[])({}){})()()())[(()()()){}])(()()()()()){})>((()()()()[]){})

在线尝试!

(原为827 <your brain-flak code here>


赏金公司,很快。
魔术八达通Ur

@MagicOctopusUrn很酷:D
HyperNeutrino,

您现在的总数为16222字节
乔·金

希望250很酷。
魔术八达通Ur

@MagicOctopusUrn 250很棒:D tyvm
HyperNeutrino

3

05AB1E,字节太多(我的第一个BF什么)

ÇεDÑDg;<èUX÷VX"()"×"(ÿ)"YX-"()"׫"(ÿ)"}»"{({}<>)({<({}[()])><>({})<>}{}<><{}><>)<>}<>"«

在线尝试!


使用预制的“乘法” Brain-flak代码进行打高尔夫球的极其基本的尝试。所有这些操作就是为每个ASCII码点找到最小和除数对,然后将这两个除数对都推入数字。({}<>)({<({}[()])><>({})<>}{}<><{}>)然后将Brainflak代码附加并循环执行,直到所有值都位于备用堆栈上。


我要感谢的人名单:

  • DJMcMayhem指出(()())(()()())= ((()())())-252 bytes
  • DJMcMayhem向我展示了循环应如何工作(-927 bytes)。

的示例性高尔夫球<your brain-flak code here>3470 3218 2291字节:

Brain-Flak,2291字节

((()()()()()())()()()())
((())()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())
((()()())()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())
((()()()()()()()()())()()()())
((()()()()()())()()()()()()()()()()()()())
((()()()())()()()())
((()()()()()()())()()()()()()())
((()()()()()())()()()()()()()()()()()()())
((())()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())
((()()()()()()())()()()()()()()())
((()()()()()()()()()())())
((()()()()())()()()())
((()()()()()())()()()()()()()()()()())
((()()()()()()()()())()()())
((())()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())
((())()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())
((()()()())()()()())
((()()()()()()()()())()())
((()()())()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())
((()()()()())()()()()()()()()()()()()()()())
((())()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())
((()()()())()()()())
((()()()()()()()())()()()()())
((())()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())
((()()()()()())()()()()()()()()()()()()())
((())()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())
((()())()()()()()()()()()()()()()()()()()()()()()()()()()()()()()){({}<>)({<({}[()])><>({})<>}{}<><{}><>)<>}<>

在线尝试!


每行代表一个正在打高尔夫球的角色,这比我发布的基本解决方案高出60%,而且对Brainflak几乎一无所知,我认为这是不采取行动的良好基准。一会儿,我会在其他内容中给答案打分,我敢肯定我会对此有所改善。(我将换行符包含在字节数中,因为我不希望这样会成功)。


这里有一些提示:1)如果您要推两个数字(例如4和5以获得20),则可以将它们推在一起以节省字节。比较(()()()())(()()()()())((()()()())())2)与常数的乘积可能比短得多push(); multiply();。例如,要将数字加倍,可以执行(({}){})而不是(()())({}<>)({<({}[()])><>({})<>}{}<><{}>)。但这不是一个糟糕的基准。如果您需要更多输入,我总是很乐意在第三堆
James

@DJMcMayhem老实说,我一直希望在数字之间使用增量,每个负增量之后都重新启动。但是我也看到了差异的想法...我现在将其合并...我也正在解决此问题。另外,05AB1E代码本身也不是问题,但这并不重要,但我也想重做。
魔术章鱼缸

分数案件还没有出来。发布后,我会在一周或两秒钟内进行ping操作(避免使用测试用例优化解决方案)
Christopher

@DJMcMayhem增量的除数会很好吗?
魔术章鱼缸

测试用例已淘汰
Christopher

2

脑爆裂

For each character (main loop)
(([])<{({}[()]<

Get the difference between the top two characters
(({}<>)<>[({})]<><({}<>)>)

Push an open paren on the other stack
<>(((((()()){}()){}){}){})

Retrieve difference
(<>{}<>)

Greater than zero
([(({})[(())])](<>)){({}())<>}{}{((<{}>))<>{}}{}<>{}

If
{{}

While non-zero
({

Add value if not 1
<(({})[()])>{()(<{}>)}{}

<

Divmod 2
({}(())(<()>)){({}[()]<({}([{}]()))>)}{}({}[({})])

Hold the div
({}<

Push the mod part
{({}[()]<
((((((()()){}()){}){}){})())
>)}{}

Put div down
>)

Open paren if div non-zero
(({}))
{(<({}<{}
(((((()()){}()){}){}){})
>)>)}{}

Less than 4
([([({})[()()()()](())])](<>)){({}())<>}{}{((<{}>))<>{}}{}<>{}

If
{{}

Make that many 1s
{({}[()]<
((((((()()){}()){}){}){})())
>)}{}

End if
((<()>))}{}

End loop puting number of times run on the stack
>}{})

For each close push and pop
{({}[()]<
((((()()()()()){}){}){}())(((((((()()()()()){}){}){}())){}{})()())
>)}{}

End if
((<()>))}{}

Less than zero
([([({})(())])](<>)){({}())<>}{}{((<{}>))<>{}}{}<>{}

If
{{}

([{}]<

Push open bracket
((((((()()){}()){}()){}){}()){}())

>)

While non-zero
({

Add value if not 1
<(({})[()])>{()(<{}>)}{}

<

Divmod 2
({}(())(<()>)){({}[()]<({}([{}]()))>)}{}({}[({})])

Hold the div
({}<

Push the mod part
{({}[()]<
((((((()()){}()){}){}){})())
>)}{}

Put div down
>)

Open paren if div non-zero
(({}))
{(<({}<{}
(((((()()){}()){}){}){})
>)>)}{}

Less than 4
([([({})[()()()()](())])](<>)){({}())<>}{}{((<{}>))<>{}}{}<>{}

If
{{}

Make that many 1s
{({}[()]<
((((((()()){}()){}){}){})())
>)}{}

End if
((<()>))}{}

End loop puting number of times run on the stack
>}{})

For each close push and pop
{({}[()]<
((((()()()()()){}){}){}())(((((((()()()()()){}){}){}())){}{})()())
>)}{}

Push close bracket
((((((()()){}()){}()){}()){}){}())

Endif
((<()>))}{}{}

Remove top character
<>{}

End of main loop
>)}{}{}

Close the open parens
<>>){({}[()]<(((((()()){}()){}){}){}())>)}{}

Reverse code
([]){({}[()]<({}<>)<>>)}{}<>

在线尝试!

输出为<your brain-flak code here>582字节:

([()((()(()(()()()){}){}){}){}]((()(()()){}){}([(()()()){}](()(()){}((()(((()(()()){}){}){}){}){}([(()((((()()){}){}){}){}){}]([(((()()){}){}){}](()(((()()){}){}){}([((()()){}){}]([()(()()){}](()(((((()()){}){}){}){}){}([()(((()(()()()){}){}){}){}]([(()()()){}](()(()(()()){}){}([(()(()()){}){}](()(()((()((()()){}){}){}){}){}([()(()((((()()){}){}){}){}){}]([((()()()){}){}](()(()(()()){}){}([()](()((()(((()()){}){}){}){}){}([(((()((()()){}){}){}){}){}](()(()){}([()((()()()){}){}](()((()()()){}){}(()(()(()((()()){}){}){}){}((()(()(()(()()()){}){}){}){})))))))))))))))))))))))))))
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.