代号高尔夫:Triforce [英] Code Golf: Triforce

查看:102
本文介绍了代号高尔夫:Triforce的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是受此线程启发/从中获得的: http://www. allegro.cc/forums/thread/603383

问题

假设用户为您提供了1到7之间的数字输入.应从控制台获取输入,而参数则不太理想.

Assume the user gives you a numeric input ranging from 1 to 7. Input should be taken from the console, arguments are less desirable.

当输入为1时,打印以下内容:

When the input is 1, print the following:

***********
 ********* 
  *******    
   *****   
    ***    
     *     

大于1的值应生成模式的倍数,以上面的1结尾,但要对称堆叠.例如,3应该打印以下内容:

Values greater than one should generate multiples of the pattern, ending with the one above, but stacked symmetrically. For example, 3 should print the following:

*********** *********** ***********
 *********   *********   ********* 
  *******     *******     *******  
   *****       *****       *****   
    ***         ***         ***    
     *           *           *     
      *********** ***********
       *********   ********* 
        *******     *******  
         *****       *****   
          ***         ***    
           *           *     
            ***********
             ********* 
              *******  
               *****   
                ***    
                 *     

如果您也打印反面,则奖励积分.

Bonus points if you print the reverse as well.

      *********** ***********
       *********   ********* 
        *******     *******  
         *****       *****   
          ***         ***    
           *           *     
            ***********
             ********* 
              *******  
               *****   
                ***    
                 *     
                 *     
                ***    
               *****   
              *******  
             ********* 
            ***********
           *           *     
          ***         ***    
         *****       *****   
        *******     *******  
       *********   ********* 
      *********** ***********

我们是否可以尝试使每种语言都保持一个答案,而我们都对此有所改进?

Can we try and keep it to one answer per language, that we all improve on?

推荐答案

汇编程序,已汇编165个字节

构建说明

  1. 此处
  2. 下载A86
  3. 在DOS搜索路径中添加对A86可执行文件的引用
  4. 将下面的代码粘贴到文本文件中(例如:triforce.asm)
  5. 调用汇编程序:a86 triforce.asm
  6. 这将创建一个名为triforce.com
  7. 的.COM文件.
  8. 键入triforce即可运行
  1. Download A86 from here
  2. Add a reference to the A86 executable into your DOS search path
  3. Paste the code below into a text file (example: triforce.asm)
  4. Invoke the assembler: a86 triforce.asm
  5. This will create a .COM file called triforce.com
  6. Type triforce to run

这是使用标准WinXP DOS框(开始->程序->附件->命令提示符)开发的.它应该可以与其他DOS模拟器一起使用.

This was developed using the standard WinXP DOS box (Start->Programs->Accessories->Command Prompt). It should work with other DOS emulators.

使用A86进行组装,并且需要WinXP DOS框才能运行其生成的.COM文件.按"q"退出,按1-7键绘制输出.

Assemble using A86 and requires WinXP DOS box to run the .COM file it produces. Press 'q' to exit, keys 1-7 to draw the output.

  l20:mov ah,7
      int 21h
      cmp al,'q'
      je ret
      sub al,'0'
      cmp al,1
      jb l20
      cmp al,7
      ja l20
      mov [l0-1],al
      mov byte ptr [l7+2],6
      jmp $+2
      mov ah,2
      mov ch,0
      mov bh,3
   l0:mov bl,1
   l1:mov dh,0
   l3:cmp dh,ch
      je l2
      mov dl,32
      int 21h
      inc dh
      jmp l3
      ret
   l2:mov dh,bh
   l6:mov cl,12
   l5:mov dl,42
      cmp cl,bl
      ja l4
      mov dl,32
      cmp dh,1
      je l21
   l4:int 21h
      dec cl
      jnz l5
  l21:dec dh
      jnz l6
      mov dl,10
      int 21h
      mov dl,13
      int 21h
  l10:inc ch
   l9:add bl,2
   l7:cmp ch,6
      jne l1
  l13:add byte ptr [l7+2],6
  l11:dec bh
  l12:cmp bh,0
      jne l0
      xor byte ptr [l0+1],10
      xor byte ptr [l9+1],40
      xor byte ptr [l10+1],8
      xor byte ptr [l13+1],40
      sub byte ptr [l7+2],12
      mov dh,[l0-1]
      inc dh
      xor [l12+2],dh
      xor byte ptr [l11+1],8
      xor byte ptr [l1+1],1
      inc bh
      cmp byte ptr [l0+1],11
      je l0
      jmp l20

它使用大量的自我修改代码来执行triforce及其镜像,甚至修改了自我修改代码.

It uses lots of self-modifying code to do the triforce and its mirror, it even modifies the self-modifying code.

这篇关于代号高尔夫:Triforce的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆