高尔夫守则:浪潮 [英] Code Golf: The wave

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

问题描述

按字符数计算的最短代码,可从输入字符串中生成波形.

The shortest code by character count to generate a wave from the input string.

通过升高(第1行)一个较高的字符并降低(第+1行)一个较低的字符来生成波.相等的字符保持在同一行上(不进行提升或降级).

A wave is generated by elevating (line-1) a higher character, and degrading (line+1) a lower character. Equal characters are kept on the same line (no elevating or degrading done).

输入仅由小写字母和数字组成,字母被认为大于数字.

Input is made of lower case characters and numbers only, letters are considered higher than numbers.

Input:
    1234567890qwertyuiopasdfghjklzxcvbnm

Output:
                                 z
                                l x v n
                               k   c b m
                              j
                             h
                            g
                   y   p s f
                  t u o a d
               w r   i
            9 q e
           8 0
          7
         6
        5
       4
      3
     2
    1

Input:
    31415926535897932384626433832795028841971693993751058209749445923078164062862

Output:
                9 9   8 6 6
         9 6   8 7 3 3 4 2 4  8   9   88
    3 4 5 2 5 5     2       33 3 7 5 2  4 9   9 99 7
     1 1     3                  2   0    1 7 6 3  3 5   8              8 6
                                            1        1 5 2 9      9 3 7 1 4 6 8
                                                      0   0 7 9  5 2 0     0 2 6
                                                             4 44               2

代码计数包括输入/​​输出(即完整程序).

Code count includes input/output (i.e full program).

推荐答案

x86机器代码(37字节)

Hexdump:

x86 machine code (37 bytes)

Hexdump:

6800B807BF8007BE8200B40EAC3C0D741338D8740A720481EF400181C7A000AB86C3EBE8C3

在具有50行控制台的MS-DOS中运行,输入来自命令行.

Run in MS-DOS with 50 line console, the input is taken from the command line.

例如

wave.com 1234567890qwertyuiopasdfghjklzxcvbnm

在此处下载二进制文件

更新:感谢 jrandomhacker

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

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