绘制/绘制心脏图


45

您面临的挑战是绘制/绘制以下一颗心。大小必须至少为50x50像素(可以使用矢量图形)。您可以选择要绘制/绘制的心。可以接受轴,网格线等。图形上必须至少有 100个不同的坐标/点。如果需要的话,心脏可以充满色彩。

在此处输入图片说明

公式为:

在此处输入图片说明

要么

在此处输入图片说明

在此处输入图片说明

t在范围内[-1, 1]

要么

在此处输入图片说明

要么

在此处输入图片说明

这是因此以字节为单位的最短代码(每种语言)获胜。请提供输出(或链接到在线解释器)。

Answers:


66

TI-80 BASIC,45 43 41 39字节

LBL 1
RAND4-2->X
RAND4-2
IF (X²+ANS²-1)³<X²ANS³
PT-ON(X,ANS
GOTO 1

在此处输入图片说明

这花了一段时间,我的电池电量很低,所以我不想继续走下去。

我尝试使用第二个方程式,但实际上无法使用它,因此实际上更长了,因此我只修改了另一个答案。

编辑:我刚刚注意到50x50像素的要求,不幸的是屏幕只有47像素高,所以这是不可能的。


1
确实有创意!
dalearn '17

8
已经有一段时间了,但是您可以替换IF (X²+ANS²-1)³-X²ANS³<0IF (X²+ANS²-1)³<X²ANS³吗?
wchargin '17

哦,我不敢相信我没有想到这一点!谢谢
12Me21 '17

45

Perl,86个字节

$y=1-$_/25,say+map$y**3*($_*=$_/1e3)-($_+$y**2-1)**3>0?$|--?v60:3:$",-40..40for-6..50

用运行perl -E

使用第一个方程式绘制填充的ASCII心脏。请注意,x轴拉伸了约1.265倍:这是为了抵消以下事实:终端字体通常在垂直方向上比水平方向上要大得多。

输出:

                3<3<3<3<3<3<3<                   3<3<3<3<3<3<3<                 
              3<3<3<3<3<3<3<3<3<3<           3<3<3<3<3<3<3<3<3<3<               
            3<3<3<3<3<3<3<3<3<3<3<3<       3<3<3<3<3<3<3<3<3<3<3<3<             
          3<3<3<3<3<3<3<3<3<3<3<3<3<3<   3<3<3<3<3<3<3<3<3<3<3<3<3<3<           
         3<3<3<3<3<3<3<3<3<3<3<3<3<3<3< 3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<          
        3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3 <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<         
       3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3        
      <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<       
      3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3       
     <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<      
     3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3      
    <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<     
    3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3     
    <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<     
    3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3     
    <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<     
   3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3    
   <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<    
    3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3     
    <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<     
    3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3     
    <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<     
    3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3     
     <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<      
     3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3      
     <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<      
      3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3       
      <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<       
       3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3        
       <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<        
        3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3         
         <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<          
         3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3          
          <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<           
           3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3            
            <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<             
             3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3              
              <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<               
               3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3                
                <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<                 
                 3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3                  
                  <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<                   
                   3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3                    
                     <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<                      
                      3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3                       
                       <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<                        
                         3<3<3<3<3<3<3<3<3<3<3<3<3<3<3                          
                           <3<3<3<3<3<3<3<3<3<3<3<3<                            
                            3<3<3<3<3<3<3<3<3<3<3<3                             
                              <3<3<3<3<3<3<3<3<3<                               
                                3<3<3<3<3<3<3<3                                 
                                  <3<3<3<3<3<                                   
                                    3<3<3<3                                     
                                     <3<3<                                      
                                       3                                        

说明(由于OP要求提供):

condition := $y**3*($_*=$_/1e3)-($_+$y**2-1)**3>0

这只是第一个方程式,稍作重新排列使其更短。$ y直接表示公式中的y。$ _最初与x成比例,但与自身($_*=$_/1e3)乘以赋值,使其与x²成比例。由于x²在公式中使用了两次,因此节省了一些字节。

1e3意味着1000,并被选中,因为它很短,结果看起来不错。** 是Perl的电源操作员。我使用>0而不是==0因为我想要一颗饱满的心。

flip_flop := $|--?v60:3

v60滥用了古老的版本字符串语法来表示ASCII码为60的字符:“ <”。

$ | 是一个魔术变量,只能为0或1。当减为0时,将其设置为1。减为1时,自然将其设置为0。因此,$ |-通常用作触发器:每次经过评估,它在true和false之间交替。

总体而言,此表达式交替返回'<'和3。

inner_loop := <condition> ? <flip_flop> :$"

嵌套的三元。如果条件为假(→我们在心脏外面),则求值为$“,这是一个默认为”“(单个空格)的神奇变量。如果条件为真(→我们在心脏内部),则它为评估flip_flop。

outer_loop := say+map <inner_loop> ,-40..40

反复评估inner_loop,将$ _(Perl的“默认”变量)从-40变为40,以1为增量。它将这些评估的结果收集到一个临时列表中,然后将它们全部打印出来,并以新行结尾。

$y=1-$_/25, <outer_loop> for-6..50

这会重复运行external_loop,其中$ y从1.24(1-(-6 / 25))到-1(1-50/25),减量为0.04。

请注意,y除以25,而x²除以1000,这与x除以sqrt(1000)相同。我提到的〜1.265因子是sqrt(1000)/ 25。


5
呵呵,我猜它没有违反任何规则...到目前为止,我最喜欢的是:)尽管我还是很喜欢一个解释:)
Stewie Griffin

1
我对某事感到困惑。为什么在?v60上方使用“ <”?
Nic Hartley'17

长度相同,但更易于键入。
Grimmy

由心做成的心。
TheWanderer '17

34

Mathematica WolframAlpha,17 15 13 11个字节

感谢Martin Ender削减了2个字节(第一个心脏曲线->心脏曲线1)

多亏了Martin Ender(心曲线1-> heartcurve1),再减少了2个字节

这可能是作弊(显而易见的解决方案),但是这里有。

heartcurve1

在这里尝试!

我敢肯定有一种方法可以缩短第一,心脏或曲线,使Wolfram仍然接受。好吧,现在没有空间了,也许是心脏的某种缩写?

绘制其中2张,我会获得奖励积分吗?

heartcurves

在这里试试!


5
heart curve 1
Martin Ender

6
实际上,heartcurve1可行。
Martin Ender

23
@MartinEnder世界上什么
Thunda

1
第一个心曲线看起来更像是屁股
Mikhail V

@MikhailV 0th心曲线(心形)看起来像个屁股。
桑达

29

Mathematica,52个字节

RegionPlot[(x^2+y^2-1)^3-x^2y^3<0,{x,-2,2},{y,-2,2}]

在此处输入图片说明

我们可以再保存一个字节,ContourPlot但是背景有点混乱:

ContourPlot[(x^2+y^2-1)^3-x^2y^3,{x,-2,2},{y,-2,2}]

在此处输入图片说明

对于另外一个字节,我们可以使用第四个公式,PolarPlot而不是:

PolarPlot[(x=Sin@t)Abs@Cos@t^.5/(x+7/5)-2x+2,{t,0,7}]

在此处输入图片说明


23
“有点迷糊”有点轻描淡写……
Mego

ContourPlot会触发很多OCD。啊!:D
KeyWeeUsr

25

卡西欧fx-7700GH,21字节

sin θ √ Abs cos θ ÷ ( sin θ + 7 ÷ 5 ) - 2 sin θ + 2

将未命名的图形函数输入到极坐标图形函数插槽之一中,然后按照提示进行操作。

图形范围必须手动设置(除非碰巧适合当前设置范围),我将其设置为Xmin=-2.75, Xmax=2.75, Ymin=-4, Ymax=1

应该也可以在其他Casio Power图形系列计算器上使用,并且很可能在以后的Casio图形计算器上使用。

卡西欧fx-7700GH计算器画的一颗心 (是的,很老而且尘土飞扬)


18

MATLAB /八度,31字节

ezplot('(x^2+y^2-1)^3-x^2*y^3')

在此处输入图片说明


9

SmileBASIC,85 81字节

X=RNDF()*4-2Y=RNDF()*4-2GPSET X*50+99,Y*50+99,-(-X*X*Y*Y*Y>POW(X*X+Y*Y-1,3))EXEC.

在此处输入图片说明




7

Python,119116字节

from turtle import*
from math import*
t=1
while-t<1:a=abs(t);c=cos(t);goto(sin(t)*c*log(a)*99,c**.5*a**.3*99);t-=.01

在线尝试

x = sin(t)* cos(t)* log(abs(t))

y = cos(t)**。5 * abs(t)**。3


6

SageMath,66个字节

polar_plot(sin(x)*abs(cos(x))^.5/(sin(x)+7/5)-2*sin(x)+2,(0,2*pi))

在线尝试

不幸的是,implicit_plotand 的长名称parametric_plot(加上需要x为前者隐式定义的变量之外的其他变量)的定义使前三个选项的时间太长,无法考虑。

感谢busukxuan和Andrea Lazzarotto的帮助


1
是否^.5到位的工作**.5
busukxuan

1
@busukxuan不。Sage是基于Python构建的,并且^是XOR。
Mego

1
但圣人替代^**。我想知道是否是因为后面跟着a.
busukxuan,

@busukxuan Sage使用Python的幂符号(**)。如果尝试使用^,最终会得到警告和错误的结果。
Mego

1
@AndreaLazzarotto然后,显然我的记忆有毛病。谢谢。
Mego

6

C,137133字节

p;float x,y,f;v(){for(p=4e3;p;x=(float)(p%99-50)/35,y=(float)(p/40-45)/40,f=x*x+y*y-1)putchar(p--%99?f*f*f-x*x*y*y*y<1e-3?35:32:10);}

http://codepad.org/zqqYUui8

感谢@AlbertRenshaw,我还将100s更改为99s,以获得另外2个字节


1
+1; 我喜欢v为功能使用,才华横溢。您可以通过更换刮胡子两个字节40004e3和更换0.0011e-3
阿尔伯特·伦肖

6

果冻,31 个字节

*3×
²+’*3<çị⁾* 
25µNr÷21µ²ç@þUY

在线尝试!

35个字节,而不是*填充:改变中间线²+’*3<ç×9829Ọ»⁶

          ♥♥♥♥♥♥♥♥♥♥           ♥♥♥♥♥♥♥♥♥♥          
        ♥♥♥♥♥♥♥♥♥♥♥♥♥♥       ♥♥♥♥♥♥♥♥♥♥♥♥♥♥        
      ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥   ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥      
     ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥     
     ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥     
    ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥    
   ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥   
   ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥   
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥  
   ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥   
   ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥   
   ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥   
    ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥    
    ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥    
     ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥     
     ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥     
      ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥      
      ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥      
       ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥       
        ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥        
        ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥        
         ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥         
          ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥          
           ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥           
            ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥            
             ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥             
              ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥              
               ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥               
                 ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥                 
                  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥                  
                   ♥♥♥♥♥♥♥♥♥♥♥♥♥                   
                     ♥♥♥♥♥♥♥♥♥                     
                      ♥♥♥♥♥♥♥                      
                        ♥♥♥                        
                         ♥                         

怎么样?

实现:方程在51 x 51换行符上分隔的字符网格。

*3× - Link 1: y, xSquared
*3  - cube y
  × - multiply the result by xSquared

²+’*3<çị⁾*  - Link 2: y, xSquared
²           - square y
 +          - add xSquared to the result
  ’         - subtract one
   *3       - cube the result
     <      - less than? (1 if True, 0 if False)
      ç     -     the result of the last link (1) as a dyad: f(y, xSquared)
       ị    - index into (1-based):
        ⁾*  - the string "* " (there is a trailing space on this line)

       ×9829Ọ»⁶ - alternative ending of link 2
       ×9829    - multiply (vectorises) by 9829
            Ọ   - cast to character (vectorises) (9829 is the ♥, 0 is the null-byte)
             »  - maximum (vectorises) of that and:
              ⁶ -     space character (ordinal of space is 32, greater than the null-byte, less than ♥)

25µNr÷21µ²ç@þUY - Main link: no arguments
25              - 25
  µ             - monadic chain separation call that i
   N            - negate i
    r           - inclusive range(negated i, i) -> [-25, -24, ..., 24, 25]
     ÷21        - divide by 21 (vectorises) -> [-1.1904761904761905, -1.1428571428571428, ..., 1.1428571428571428, 1.1904761904761905]
        µ       - monadic chain separation call that r
         ²      - square r (vectorises) (make the xSquared values, left to right)
             U  - upend r (make the y values, top to bottom)
            þ   - outer product using:
          ç@    -     last link (2) as a dyad with reversed arguments: f(y, xSquared)
              Y - join with line feeds
                - implicit print

5

的JavaScript(ES6),151个 147字节

document.write`<canvas id=c>`;for(i=0;x=2-i/24,i<97;i++)for(j=0;y=2-j/24,z=x*x+y*y-1,j<97;j++)z*z*z-x*x*y*y*y<0&&c.getContext`2d`.fillRect(i,j,1,1)

编辑:由于@ user2428118,节省了4个字节。143字节的ES7版本:

document.write`<canvas id=c>`;for(i=0;i<97;i++)for(x=2-i/24,j=0;j<97;j++)x*x*(y=2-j/24)**3-(x*x+y*y-1)**3>0&&c.getContext`2d`.fillRect(i,j,1,1)


怎么样y**3,而不是y*y*y
svarog

1
@svarog因此,我的注释“在ES7中会短一些” ...
Neil

好吧,它适用于铬55,那么为什么不添加es7版本呢?
svarog

1
@svarog因为我没有方便的铬55 ...
Neil

1
@ThisSuitIsBlackNot当我尝试时,它抱怨未声明的变量。
尼尔

4

BBC BASIC,80岁

明天将打高尔夫球。

http://www.bbcbasic.co.uk/bbcwin/bbcwin.html下载口译员

ORIGIN99,99F.u=-56TO56x=u/50b=x^2^.33/2r=(b^2-x^2+1)^.5*50L.u,b*50-r,u,r+b*50N.

使用第一个方程式绘制一个填充的心,我们重新排列并获取的立方根(存在3个实数的立方根,一个实数和2个复数,但在这里我们只对实数根感兴趣。)然后,我们再次重新排列为得到二次方 y

x^2+y^2-1=(x^0.66)y

y^2-(x^0.66)y+x^2-1=0

对类型的表达式使用标准的二次公式ay^2+by+c=0,并利用a= 1 的事实,我们得到

y = -b/2 +/- sqrt((b/2)^2-c)

y = -b/2 +/- sqrt((b/2)^2-x^2+1)

位置-b/2 = (x^0.66)/2b在程序中由表示)。

我们只需x从左到右扫描值,在每对有效值之间绘制一条垂直线y以建立一个实心形状。

ORIGIN99,99F.u=-56TO56x=u/50b=x^2^.33/2r=(b^2-x^2+1)^.5*50L.u,b*50-r,u,r+b*50N.

不打高尔夫球

ORIGIN99,99
FORu=-56TO56
  x=u/50
  b=x^2^.33/2
  r=(b^2-x^2+1)^.5*50
  LINEu,b*50+r,u,b*50-r
NEXT

4

Ruby,80个字节

给露比一些爱。

-2.step(2,0.2){|y|-2.step(2,0.1){|x|$><<'. O'[(y*y-1+x*=x)**3+x*y**3<=>0]};puts}

输出:

         OOOOO     OOOOO             
      .OOOOOOOOO.OOOOOOOOO.          
     OOOOOOOOOOOOOOOOOOOOOOO         
     OOOOOOOOOOOOOOOOOOOOOOO         
     OOOOOOOOOOOOOOOOOOOOOOO         
      OOOOOOOOOOOOOOOOOOOOO          
      .OOOOOOOOOOOOOOOOOOO.          
        OOOOOOOOOOOOOOOOO            
         OOOOOOOOOOOOOOO             
           OOOOOOOOOOO               
              OOOOO                  
                .                    

上下有一些空行


2

Processing.js:123个 119字节

松散:

t = 0; 

void setup() {
    size(99, 300); 
} 

void draw() {
    point(59+99*sin(t)*cos(t)*log(t),350-400*sqrt(cos(t))*pow(t,0.3));
    t+=0.01;
}

打高尔夫球:

t=0;void setup(){size(99,300);}void draw(){point(59+99*sin(t)*cos(t)*log(t),350-400*sqrt(cos(t))*pow(t,0.3));t+=0.01;}

这是一个非常骗人的工具,因为它从0到无穷远绘制了#2,而不是如图-1所示从-1到1来保存两个abs(t)。但这在技术上是正确的,因为有100多个点。


130字节的“纠正者”之一

t=-1;void setup(){size(99,300);}void draw(){point(59+99*sin(t)*cos(t)*log(abs(t)),350-400*sqrt(cos(t))*pow(abs(t),0.3));t+=0.01;}

在线尝试

注意:可能有一种方法可以在默认的100x100画布上获得100分并清除设置。


在本地版本的Processing上,您的任何片段都对我没有任何帮助(第二个片段仅获得1分)
Kritixi Lithos

你试过画板了吗?(“在线试用”),您需要点击“渲染草图”
satibel

但是我认为它将被称为“ Processing.JS”。对于片段为我工作,你必须使用float的,而不是int
Kritixi LITHOS

糟糕,忘记了.js,因此,我通过删除了无用的int节省了4个字节。
satibel '17

2

TI-84 Basic,40 38字节

类似于@ 12Me21的答案和输出,但适用于TI-83 / 84系列。

While 1:2rand-1→A:2rand-1:If (A²+Ans²-1)³>A²Ans³:Pt-On(A,Ans:End

在这里使用Ans实际上更小吗?我以为Ans是2个字节。
17Me21年

@ 12Me21不,它的大小相同,而且速度也更快。(至少对于TI-83 / 84,我不了解TI-80)。
Timtech '17

1

BBC BASIC(BBC Micro)(126字节)

这是Level River Street 答案的一种变体,但仅适用于BBC Micro最初对BBC BASIC的迭代。

您可以在https://bbc.godbolt.org/(基于JavaScript的BBC Micro仿真器)上将以下任意一项复制并粘贴到JSBeeb的新粘贴功能中,一旦粘贴完成,请在“屏幕”中按Enter以显示新的提示,然后键入RUN,然后按Enter以运行任一版本。

打高尔夫球。(126字节)

1MO.1:V.29,64;64;:MOVE-57,20:GC.0,1:F.U=-56TO56:X=U/50:IFX<>0TH.B=X^2^.33/2
2R=(B^2-X^2+1)^.5*50:DRAWU,B*50+R:DRAW U,B*50-R:N.

不打高尔夫球。(176字节)

1 MODE 1
2 VDU 29,64;64;
3 MOVE -57,20
4 GCOL 0,1
5 FOR U = -56 TO 56
6 X = U/50
7 IF X <> 0 THEN B = X^2^.33/2
8 R = (B^2-X^2+1)^.5*50
9 DRAW U,B*50+R
10 DRAW U,B*50-R
11 NEXT

第7行要求对X进行检查,以防止在循环中途X变为0时出现“对数范围”错误。除此之外,几乎是相同的。在JSBeeb很好地模拟的真实机器上绘制要慢得多。

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.