让我们高尔夫一个BIBABOBU解码器


53

当我将来旅行时,我注意到大约2275岁的孩子之间发生了一场有趣的游戏。当他们不希望他们的曾曾曾祖父母明白他们在说什么时,他们会用BIBABOBU说话。显然,我在半机器人之前的时代无法理解任何事情,而且我(或者从技术上:我会觉得)真的很愚蠢。因此,我下次访问时需要解码器。

BIBABOBU?

尽管已被弃用很长时间,但ASCII在2275的流行文化中仍然很常用,并且该语言基于它。

字符串是用BIBABOBU编码的:

  • 将所有字符转换为其ASCII码。
  • 取每个代码的2位十六进制表示形式,并使用下表对其进行转换:

    0: BI  4: BIDI  8: BADI  C: BODI
    1: BA  5: BIDA  9: BADA  D: BODA
    2: BO  6: BIDO  A: BADO  E: BODO
    3: BU  7: BIDU  B: BADU  F: BODU
    

"Hello!" → 48 65 6C 6C 6F 21 → "BIDIBADI BIDOBIDA BIDOBODI BIDOBODI BIDOBODU BOBA"

但是,将给出相应的输入,而没有任何空间来模仿孩子们使用单调的语调,而这些调子在没有植入的情况下变得更加难以理解:

"BIDIBADIBIDOBIDABIDOBODIBIDOBODIBIDOBODUBOBA"

澄清和规则

  • 请记住,我需要一个解码器,而不是一个编码器。
  • 解码后的字符保证在[32 ... 126]范围内。
  • 确保输入包含偶数个BIBABOBU编码的十六进制数字。
  • 您可以全小写或全大写输入。不允许混合使用。
  • 因为在时间旅行中位翻转非常普遍,所以这是,目的是最大程度地降低风险。

测试用例

注意:以下仅将换行用于格式化。您应该处理它们。

Input:
BIDABIDIBIDOBIDABIDUBUBIDUBIDI

Output:
Test

Input:
BIDABIDUBIDOBIDABIDOBODIBIDOBUBIDOBODUBIDOBODABIDOBIDABOBIBIDUBIDIBIDOBODUBOBIBUBOBUBOBUBI
DUBUBIDABOBA

Output:
Welcome to 2275!

Input:
BIDIBADIBIDOBIDABIDOBODIBIDOBODIBIDOBODUBOBODIBOBIBIDABIDIBIDOBADABIDOBODABIDOBIDABOBIBIDA
BIDIBIDUBOBIDOBABIDUBIDOBIDOBIDABIDOBODIBIDOBIDABIDUBOBOBABOBIBIDABADABIDOBODUBIDUBIDABOBI
BIDOBODIBIDOBODUBIDOBODUBIDOBADUBOBIBIDUBUBIDOBODUBOBIBIDOBIDOBIDUBIDABIDOBODOBIDOBODOBIDU
BADABOBA

Output:
Hello, Time Traveler! You look so funny!

Input:
BIDIBABIDOBODOBIDOBIDIBOBIBIDUBADABIDOBODUBIDUBIDABOBIBIDOBIDIBIDOBODUBIDOBODOBOBIDUBIDUBI
DIBOBIBIDUBIDABIDOBODOBIDOBIDIBIDOBIDABIDUBOBIDUBUBIDUBIDIBIDOBABIDOBODOBIDOBIDIBOBIBIDUBI
DUBIDOBADIBIDOBABIDUBIDIBOBIBIDIBADABOBIDUBIDOBODABOBIBIDUBUBIDOBABIDUBADABIDOBADABIDOBODO
BIDOBIDUBOBODIBOBIBIDOBIDIBIDOBODUBOBIBIDUBADABIDOBODUBIDUBIDABUBODUBOBIBIDIBADIBIDOBABOBI
BIDOBADIBIDOBABOBIBIDOBADIBIDOBABOBA

Output:
And you don't understand what I'm saying, do you? Ha ha ha!

4
@StewieGriffin这些该死的孩子是调皮的……:-/
Arnauld

12
顺便说一句,我发现这个故事真的不太可能!如果您只是做梦,我不会感到惊讶...您的房屋可能会发生CO泄漏?
Stewie Griffin

12
啊...那也可以解释我的客厅里骑着彩虹的小马!
Arnauld

9
有人可能会争辩说,打高尔夫球的代码会降低位翻转的严重性(减少代码内的冗余度),即使它降低了位翻转的频率……但无论如何:)-很好的挑战!
JayCe

4
@JayCe是的。我一直在思考:代码越小,通过存储多个副本可以获得的冗余就越多。
Arnauld

Answers:


15

05AB1E36 35 33字节

保存1字节由于Mr.Xcoder
保存2个字节由于KevinCruijssen

ć©¡®ì®D…IAO©â'D«‚˜®'U«âJskh2ôJHçJ

在线尝试! 或作为测试套件

说明

ć©¡                                 # extract the head ("B") and split input on it
   ®ì                              # prepend "B" to each
     ®D                            # push 2 copies of "B"
       …IAO©â                      # cartesian product with "IAO"
             'D«                   # append "D" to each
                ‚˜                 # add the leftover "B" to the list
                  ®'U«â            # cartesian product with "IAOU"
                       J           # join each to string
                        sk         # get the index of each word of the input in this list
                          h        # convert each to hex
                           2ôJ     # format as pairs of chars
                              H    # convert to int
                               çJ  # convert from ascii-codes to string

我相信'B©¡¦®ì®D…IAO©â'D«‚˜®'U«âJskh2ôJHçJ适用于35个字节。
Xcoder先生18年

@ Mr.Xcoder:当然可以。很好的重用©。谢谢:)
Emigna '18

-2字节改变导致'Bć和去除¦,由于输入将总是用“B”启动。
凯文·克鲁伊森

@KevinCruijssen:哦,好主意。我没考虑过ć。谢谢!
Emigna '18

9
现在让我们回到那些孩子那里,看看他们是否理解这一点!
亚伦

14

果冻26 24 23 22 20 17 15字节

ṣḢO^1%9%4Ḅḅ⁴b⁹Ọ

在线尝试!

这个怎么运作

ṣḢO^1%9%4Ḅḅ⁴b⁹Ọ  Main link. Argument: s (string)

 Ḣ               Head; remove and yield the first character of s.
ṣ                Split s at occurrences of the result ('B').
  O              Ordinal; map "IAOUD" to A1 := [73, 65, 79, 85, 68].
   ^1            Bitwise XOR 1; map A1 to A2 := [72, 64, 78, 84, 69].
     %9          Modulo 9; map A2 to A3 := [0, 1, 6, 3, 6].
       %4        Modulo 4; map A3 to A4 := [0, 1, 2, 3, 2].
                 So far, we've mapped "BX" to [x] and "BXDY" to [x, 2, y],
                 where x/y = 0, 1, 2, 3 when X/Y = I, A, O, U.
         Ḅ       Unbinary; map [x] to x and [x, 2, y] to 4x + 2×2 + y = 4(x + 1) + y.
          ḅ⁴     Convert the resulting array from base 16 to integer.
            b⁹   Convert the resulting integer to base 256.
              Ọ  Unordinal; replace code points with their characters.

13

Perl 6、58字节

{S:g{(B.[D.]?)**2}=chr :16[$0».&{:2[.ords»³X%87 X%4]}]}

在线尝试!

受Dennis Jelly解决方案的启发。使用另一个魔术函数x³ % 87 % 4,该函数还将的ASCII码映射IAOUBD012302

备用75 74字节版本

-1字节感谢Jo King

{pack('H',.trans((<B BID BAD BOD>X~ <I A O U>)=>(^16)».base(16))).decode}

在线尝试!

备用85字节版本

{S:g[....]=chr :4(~$/)*2+|221+^:4(~$/)+^238}o{TR:d/UIAOBD/0123/}o{S:g[B.<![D]>]=0~$/}

在线尝试!


(^16)>>.base(16)-1字节怎么样
Jo King

8

Python 2中100个 97 96 95字节

-1字节归功于ovs
-1字节归功于GB

lambda w:''.join(' 1023546798abdcef'[int(c,35)/7%77%18]for c in w.split('B')[1:]).decode("hex")

在线尝试!



6

05AB1E(旧版),68 65 60 59 字节

.•5Ç¿ÆΓ•2ô.•1ÒKá ¸ΓìŸÆt`ô_zTºγ„KRI‰ι놽òι•4ô«I¬©¡®ìkh2ôJHçJ

输入为小写。

@Emigna更改'b¡εg>}s£为-3个字节'b©¡®ì

在线尝试验证所有测试用例

而且,绝对可以用比巨大的压缩琴弦更聪明的东西打高尔夫球。稍后再看。 @Emigna已经提供了简短的答案,所以请确保对他投票

说明:

.•5Ç¿ÆΓ•      # Compressed string "bibabobu"
        2ô    # Split in parts of 2
              #  → ["bi","ba","bo","bu"]
.•1ÒKá ¸ΓìŸÆt`ô_zTºγ„KRI‰ι놽òι•
              # Compressed string "bidibidabidobidubadibadabadobadubodibodabodobodu"
        4ô    # Split in parts of 4
              #  → ["bidi","bida","bido","bidu","badi","bada","bado","badu","bodi","boda","bodo","bodu"]
«             # Merge both lists together
              #  → ["bi","ba","bo","bu","bidi","bida","bido","bidu","badi","bada","bado","badu","bodi","boda","bodo","bodu"]
I¬©¡          # Take the input and split on the head (always 'b')
              #  i.e. "bidibadibidobidabidobodibidobodibidoboduboba"
              #   → ["idi","adi","ido","ida","ido","odi","ido","odi","ido","odu","o","a"]
    ®ì        # And prepend a 'b' to each item again
              #  i.e. ["idi","adi","ido","ida","ido","odi","ido","odi","ido","odu","o","a"] 
              #   → ["bidi","badi","bido","bida","bido","bodi","bido","bodi","bido","bodu","bo","ba"]
k             # Map each item to the index of the first list
              #   i.e. ["bidi","badi","bido","bida","bido","bodi","bido","bodi","bido","bodu","bo","ba"]
              #    → [4,8,6,5,6,12,6,12,6,15,2,1]
 h            # Convert everything to hexadecimal
              #  i.e. [4,8,6,5,6,12,6,12,6,15,2,1]
              #   → ["4","8","6","5","6","C","6","C","6","F","2","1"]
  2ôJ         # Split it in parts of 2 and join them together
              #  i.e. ["4","8","6","5","6","C","6","C","6","F","2","1"]
              #   → ["48","65","6C","6C","6F","21"]
     H        # Convert that from hexadecimal to an integer
              #  i.e. ["48","65","6C","6C","6F","21"] → [72,101,108,108,111,33]
      ç       # And take its ASCII value
              #  i.e. [72,101,108,108,111,33] → ["H","e","l","l","o","!"]
       J      # Then join everything together (and output implicitly)
              #  i.e. ["H","e","l","l","o","!"] → "Hello!"


5

R141135字节

function(x,y="I":"A":"O")intToUtf8(matrix(match(el(strsplit(gsub("D","",x),"B"))[-1],paste0(rep("":y,e=4),y:"U"))-1,,2,T)%*%16:1)
":"=c

在线尝试!

感谢JayCe节省了6个字节!

使用一些模块化的魔术可能会更短一些,但是我很高兴将此作为天真的第一步。


1
不错!我最喜欢的技巧可以节省6个字节 -受到您前几天对我的回答的评论启发。
JayCe

@JayCe非常干净利落!%*%我什至优先使用它。:-) `:`如果您想与其他东西一起使用,也可以将其作为函数参数!
朱塞佩

是的-我总是倾向于忘记反引号。
JayCe

5

Japt,43 29 28字节

毫不奇怪,Dennis的Jelly解决方案的端口要短得多。

输出字符数组。

Åqbu)®¬®c ^1 %9%4Ãì2Ãò ®ìG d

试试吧


原始的42个字节

Åqb £`bbidbad¾d`ò3n)ï`ia`q)m¬bXibÃò ®ìG d

试试吧

说明

Åqb £`bbidbad¾d`ò3n)ï`ia`q)m¬bXibÃò ®ìG d
Å                                              :Slice off the first character
 qb                                            :Split on "b"
    £                                          :Map
     `bbidbad¾d`                               :  Compressed string "bbidbadbod"
                ò3n)                           :  Partition at every 3rd character from the end (["b","bid","bad","bod"])
                    ï                          :  Cartesian product
                     `ia`                      :   Compressed string "iaou"
                          q                    :   Split
                           )                   :  End Cartesian product
                            m                  :  Map
                             ¬                 :   Join
                              b                :  Index of
                               X               :   Current element
                                ib             :   Prepend "b"
                                  Ã            :End map
                                   ò           :Partition at every second element
                                     ®         :Map
                                      ìG       :  Convert from base-16 digit array to base-10 integer
                                         d     :  Get the character at that codepoint

5

C(GCC) 181个 138 136字节

希望将来会有C编译器对此进行编译!:-)

感谢Max Yekhlakov和ceilingcat的建议。

v,t,c,d;f(char*s){for(v=t=c=0;d=*s++;)t+=d==66?v=v*16+t,++c>2?v=!putchar(v),c=1:0,-t:d-65?d-79?d-68?d-85?0:3:4+t*3:2:1;putchar(v*16+t);}

在线尝试!


如果将来的C编译器仅理解BIBABOBU定义的ASCII :-)

BIDUBIDOBOBODIBIDUBIDIBOBODIBIDOBUBUBADUBIDOBIDOBOBADIBIDOBUBIDOBADIBIDOBABIDUBOBOBADOBIDUBUBOBADABIDUBADUBIDOBIDOBIDOBODUBIDUBOBOBADIBIDUBIDOBUBODABIDUBIDIBUBODABIDOBUBUBODABUBIBUBADUBOBADOBIDUBUBUBADUBIDUBUBOBADUBOBADUBOBADABIDUBIDIBOBADUBUBODABOBADOBIDUBUBUBODABUBODABUBIDOBUBIDOBUBODUBIDUBIDOBUBODABIDUBIDOBOBADOBUBABUBIDOBOBADUBIDUBIDIBOBODIBOBADUBOBADUBIDOBUBUBODOBUBOBUBODUBIDUBIDOBUBODABOBABIDUBIBIDUBIDABIDUBIDIBIDOBUBIDOBADIBIDOBABIDUBOBOBADIBIDUBIDOBOBADABOBODIBIDOBUBUBODABUBABUBADOBUBIBOBODIBOBODABIDUBIDIBUBADOBOBADOBIDUBUBOBODABUBIDOBUBIDABUBODUBOBADOBIDUBUBOBODABUBIDUBUBADABUBODUBOBADOBIDUBUBOBODABUBIDOBUBADIBUBODUBOBADOBIDUBUBOBODABUBADIBUBIDABUBODUBUBIBUBADOBUBUBUBADOBUBIDIBOBADUBIDUBIDIBOBADOBUBUBUBADOBUBOBUBADOBUBABUBADUBIDUBIBIDUBIDABIDUBIDIBIDOBUBIDOBADIBIDOBABIDUBOBOBADIBIDUBIDOBOBADOBUBABUBIDOBOBADUBIDUBIDIBOBADABUBADUBIDUBODA

(编码器在线尝试!



建议c=printf(&v),v=0不要使用v=!putchar(v),c=1
ceilingcat '18 -10-19

4

JavaScript(Node.js)131128字节

s=>unescape(s.replace(/B.(D.)?/g,(f,s)=>(-~g(f[1])*4*!!s+g((s||f)[1])).toString(16),g=c=>'IAOU'.search(c)).replace(/../g,'%$&'))

在线尝试!链接包括测试用例。备用版本,也是131个字节:

s=>unescape(s.replace(/B.(D.)?/g,s=>(-~g(s[1])*4*!!s[3]+g(s[3]||s[1])).toString(16),g=c=>'IAOU'.search(c)).replace(/../g,'%$&'))

在线尝试!链接包括测试用例。编辑:由于@Shaggy,节省了3个字节。


1
使用unescape()是一个好主意。
阿纳尔德

indexOf-> search保存一个字节。
毛茸茸的

另外,看起来您不需要将RegEx分配给r
毛茸茸的

@Shaggy Whoops,这是上一次迭代的结果。谢谢!
尼尔,


4

标量 305字节

好吧,我很确定这可以打出去。但是,它仍然存在。输入小写字母。f在标准输出中打印结果。

编辑:-8个字符,感谢我不再傻了(空格);-13个字符归功于crater2150

var k=Seq("bi","ba","bo","bu")
k++=k.init.flatMap(a=>Seq("di","da","do","du").map(a+_))//Putting "bu" here instead of at line 1, and in place of using init, would be interesting... if it did not cause a typing problem
var m=Seq[String]()
def g(a:Seq[String],b:Int)=k.indexOf(a(b)).toHexString
def f(a:String){a.split('b').drop(1).foreach(x=>m:+="b"+x)
var i=0
while(i<m.length){print(Integer.parseInt(g(m,i)+g(m,i+1),16).toChar)
i+=2}}

在线尝试!


可以替换dropRight(1)使用initSeq("").drop(1)Seq[String](),并map(b=>a+b)map(a+_)
crater2150

@ crater2150谢谢!我的编译器不想map(a+_)工作,但我知道我可以做到。感谢其他提示!
V. Courtois

3

Python 2中142个 139 127 118字节

lambda s:''.join(chr(16*a+b)for a,b in zip(*[iter(4*F(l[:-2])+F(l[-1])-1for l in s.split('B')[1:])]*2));F=' IAOU'.find

在线尝试!




3

Dyalog APL,74 72字节

Dyalog APL中的入门级解决方案(几天前才开始学习!)。定义一个带一个右参数(输入)的dfn。使用dyalog编码时,为72个字符,72个字节。基于Emigna在05AB1E中的解决方案。

{⎕UCS 16⊥¨(1 0⍴⍨≢t)⊂1-⍨(,('B',('B'∘.,'IAO'),¨'D')∘.,'IAOU')⍳t←('B'⍷⍵)⊂⍵}

欢迎来到PPCG和APL高尔夫世界。在学习APL几天后,这真是太神奇了。您可能会喜欢APL高尔夫技巧。也可以自由参加APL果园
亚当


2

Brain-Flak,178字节

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

在线尝试!

说明

# Step 1: convert to hex.
# For each pair of letters in the input:
{

  (

    # Compare first letter to B
    ([((((()()()()){}){}){}()){}]{})

    # If not B, pop previous output, multiply by 4, and put on third stack.
    # 4 is added automatically from pushing/popping the difference
    # between the letters B and D.
    {{}<>(({}){}){}(<>)}{}

    <

      # Push second letter in pair to other stack
      ({}(<>))

      # Push 4 and 9
      (<>)((()()()())({})())

      # Compute 3-((8-(n mod 9)) mod 4)
      # (same as (n-1) mod 9 mod 4)
      {{(({})){({}[()])<>}{}}<>({}<>)<>{}}{}

    >

    # Add result to third stack (either 0 or 4*previous+4)
    <>{}{}

  # Push onto second stack
  )

<>}

# Step 2: Pair up hex digits.
# While digits remain on right stack:
<>([]){{}

  # Push top of stack + 16*second on stack to left stack
  ({}(((({}){}){}){}){}<>)<>

([])}

# Switch to left stack for output.
<>

2

05AB1E,30 个字节

ć¡Ç1^9%4%εDg≠i421øP]€OžvβžzвçJ

@Dennis的疯狂果冻答案端口(只是使用了不太方便的内置函数)。所以一定要投票支持他!

在线尝试验证所有测试用例

说明:

ć¡             # Split the input-string on its first character ('B')
               #  i.e. "BIDABIDIBIDOBIDABIDUBUBIDUBIDI"
               #   → ["IDA","IDI","IDO","IDA","IDU","U","IDU","IDI"]
  Ç            # Convert each character to it's ordinal value
               #  → [[73,68,65],[73,68,73],[73,68,79],[73,68,65],[73,68,85],85,[73,68,85],[73,68,73]]
   1^          # XOR it by 1
               #  → [[72,69,64],[72,69,72],[72,69,78],[72,69,64],[72,69,84],84,[72,69,84],[72,69,72]]
     9%        # Take modulo-9
               #  → [[0,6,1],[0,6,0],[0,6,6],[0,6,1],[0,6,3],3,[0,6,3],[0,6,0]]
       4%      # Take Modulo-4
               #  → [[0,2,1],[0,2,0],[0,2,2],[0,2,1],[0,2,3],3,[0,2,3],[0,2,0]]
ε         ]    # Now map it to:
 Dgi          # If the length is not 1:
               #  i.e. [0,2,1] → 3 → 1 (truthy)
               #  i.e. 3 → 1 → 0 (falsey)
     421øP     # Multiply the first number by 4, second by 2, and third by 1
               #  i.e. [0,2,1] and [4,2,1] → [[0,4],[2,2],[1,1]] → [0,4,1]
           O  # Then sum every inner list
               #  [[0,4,1],[0,4,0],[0,4,2],[0,4,1],[0,4,3],3,[0,4,3],[0,4,0]]
               #   → [5,4,6,5,7,3,7,4]
žvβ            # Convert this list from base-16 to base-10
               #  → 1415934836
   žzв         # Convert this integer from base-10 to base-256
               #  → [84,101,115,116]
      ç        # Convert this number to ASCII characters
               #  → ["T","e","s","t"]
       J       # Join the characters together (and output implicitly)
               #  → "Test"

想知道您如何将Emignas得分降低3分。Jeebus,这对于端口的工作是复杂的+1-以前从未使用过XOR或该基础转换!从现在开始请牢记!
魔术章鱼缸

@MagicOctopusUrn是的,Dennis的答案是我永远不会想到的。在Jelly中,这样做的效率更高,因为他的答案是15个字节,而我的是30个。不过,我认为这也值得发布,即使是港口 我自己只使用过一次XOR,并且经常进行Base转换。
凯文·克鲁伊森

2

Java(JDK 10),199字节

s->{var z="";for(var x:s.substring(1).split("B")){int d=-1;for(var y:x.split("D"))d=-~d*4+"IAOU".indexOf(y);z+=(char)(d>9?d+55:d+48);}return new String(new java.math.BigInteger(z,16).toByteArray());}

在线尝试!

学分


1
您能-~d代替使用(d+1)吗?
Arnauld

是的,谢谢!我的第一个版本中有这些,然后我取笑了使用chars 的想法,当我回到我的第一个版本时,我完全忘记了它。;)
OlivierGrégoire'18

2

VBA(Excel)中,有一个惊人的 322个 244字节

是的,我喜欢十六进制。(尚无讽刺字体,因此,我现在使用斜体)如果有人愿意,我会添加评论,但我认为这是不言而喻的。打高尔夫球。

Sub b(s)
For Each c In Split(Replace(s,"D",""),"B")
c=Application.Match(c,Array("I","A","O","U","II","IA","IO","IU","AI","AA","AO","AU","IO","OA","OO","OU"),0)
If Not IsError(c)Then d=d &c-1:If Len(d)=2Then e=e &Chr("&h"&d):d=""
Next
Debug.?e
End Sub

有评论:

Sub b(s)
  'For each string between B's (Remove the D's first)
  For Each c In Split(Replace(s,"D",""),"B")
    'Get the index of the element in the array (Can cause error if empty)
    c = Application.Match (c,Array("I","A","O","U","II","IA","IO","IU","AI","AA","AO","AU","IO","OA","OO","OU"),0)
    'If c isn't an error
    If Not IsError(c) Then
      'Subtract 1 from c and add to d  --> Array index is 1 based
      d = d & (c-1)
      'If d is 2 characters
      If Len(d)=2 Then
        'Add the char from the hex value of d   --> &h forces Hex
        e = e & Chr("&h" & d)
        'Reset d
        d = ""
      End if
    End if
  Next
  'Print the output
  Debug.Print e
End Sub

我确实试图将其放入VB即时窗口中,但似乎无法在其中工作……我认为这会减少11个字符。我还想将Match语句放在方括号中,但这每次都会导致无提示错误。感谢帮助:D


欢迎来到PPCG!
Arnauld

谢谢!我来这里已经有一段时间了,只是没能发表任何东西:)
seadoggie01 '18

Array("I","A","O","U","II","IA","IO","IU","AI","AA","AO","AU","IO","OA","OO","OU")-> Split("I A O U II IA IO IU AI AA AO AU IO OA OO OU")Not IsError(c)->IsError(c)=0
泰勒·斯科特

1

Haxe,228字节

s->{var l=(u,i)->((i=u.charCodeAt(i))&8==8?0:1)|((i>>1)&2),p=s.split("B"),i=-1,q,o;[while((i+=2)<p.length)String.fromCharCode(l(q=p[i+1],o=q.length-1)+((o>1?l(q,0)+1:0)+((l(q=p[i],o=q.length-1)+o*(l(q,0)+1)*2)*4))*4)].join("");}

不是最好的,标准库函数名称太大:(

在线尝试!


1

Pyth,35个字节

mCid16cm+4imx"IAOU"k.[N2d4tc-Q\D\B2

输出为字符列表。
在这里尝试

说明

mCid16cm+4imx"IAOU"k.[N2d4tc-Q\D\B2
                          tc-Q\D\B   Get the vowels associated with each digit.
       m            .[N2d            Pad with a quote.
           mx"IAOU"k                 Find each character's position.
        +4i              4           Convert to base 4 and add 4.
      c                           2  Split the result into pairs.
mCid16                               Get the associated ASCII characters.

1

木炭,36字节

FS≡ιB⊞υ⁰D⊞υ×⁴⊕⊟υ⊞υ⁺⊟υ⊕⌕AOUι⭆⪪υ²℅↨ι¹⁶

在线尝试!链接是详细版本的代码。说明:

FS≡ι

循环播放每个输入字符并切换。

B⊞υ⁰

如果是,B则推0送到预定义的空列表。

D⊞υ×⁴⊕⊟υ

如果是a,D则弹出最后一个值,将其递增,乘以4,然后再次推入。

⊞υ⁺⊟υ⊕⌕AOUι

否则,在字符串中找到索引AOU,对其进行递增,然后添加到最后一个值。

⭆⪪υ²℅↨ι¹⁶

将列表分成几对值,以16为底进行解码,转换为ASCII,然后隐式打印。


1

干净145个 134字节

import StdEnv                   // import things like addition and comparison
?c=(743rem(toInt c))/16         // magical formula that maps ['IAOU'] to [0,1,2,3]
@[_,b,'D',d:t]=[?d+ ?b*4+4: @t] // convert B#D#
@[_,b:t]=[?b: @t]               // convert "B#"
@_=[]                           // handle base case
$[u,v:t]=[u<<4+v: $t]           // turn the digits into 2-digit numbers
$e=e                            // handle base case

toString o$o@                   // convert to string (make numbers (make digits))

在线尝试!

解释:


1

PHP,119字节

foreach(explode(B,$argn)as$i=>$m)($v=$v*16+4*strpos(XIAO,$m[-3]?:B)+strpos(IAOU,$m[-1]?:B))?$i&1||print chr($v&=255):0;

假定为大写输入。与管道一起运行-nR在线尝试


较旧的PHP 需要PHP 7.1 ,请使用substr($m,-3,1)substr($m,-1)代替$m[-<x>](+16字节);
年轻PHP,放BXIAOIAOU在报价,以避免警告消息(+10字节)。



0

PHP,163字节

function f($s){$t=[I=>0,A=>1,O=>2,U=>3];for($q=explode(B,$s);$a=&$q[++$i];){$a=($a[1]?($t[$a[0]]+1)*4:0)+$t[$a[2*($a[1]==D)]];$i%2?:print(chr(($q[$i-1]<<4)+$a));}}

调用f(string $s)与bibabobu编码字符相应的字符串,它会打印出已解码的字符串。


0

Python 3,199个字节

import re
lambda s:''.join(eval(re.sub(r'(\d+), (\d+)',r'chr(16*\1+\2)',str(eval(s.replace('I','1').replace('A','2').replace('O','3').replace('U','4').replace('B',',-1+').replace('D','*4+')[1:])))))

不是最短的,但是没有循环。

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.