不可能的立方体


17

问题

给定一个输入a,其中a为真值/伪造值,如果为true,则输出下面的确切不可能立方体,如果为falsey则输出下面的确切普通立方体。

输入truthy

         ___________________________________
        / _______________________________  /|
       / / _____________________________/ / |
      / / /| |                         / /  |
     / / / | |                        / /   |
    / / /| | |                       / / /| |
   / / / | | |                      / / / | |
  / / /  | | |                     / / /| | |
 / /_/___| | |____________________/ / / | | |
/________| | |_____________________/ /  | | |
| _______| | |____________________ | |  | | |
| | |    | | |___________________| | |__| | |
| | |    | |_____________________| | |____| |
| | |   / / _____________________| | |_  / /
| | |  / / /                     | | |/ / /
| | | / / /                      | | | / /
| | |/ / /                       | | |/ /
| | | / /                        | |   /
| | |/_/_________________________| |  /
| |______________________________| | /
|__________________________________|/

输入falsy

         ___________________________________
        / _______________________________  /|
       / / _____________________________/ / |
      / / /| |                         / /  |
     / / / | |                        / /   |
    / / /| | |                       / / /| |
   / / / | | |                      / / / | |
  / / /  | | |                     / / /| | |
 / /_/___|_|_|____________________/ / / | | |
/__________________________________/ /  | | |
| ________________________________ | |  | | |
| | |    | | |___________________| | |__| | |
| | |    | |_____________________| | |____| |
| | |   / / _____________________| | |_  / /
| | |  / / /                     | | |/ / /
| | | / / /                      | | | / /
| | |/ / /                       | | |/ /
| | | / /                        | |   /
| | |/_/_________________________| |  /
| |______________________________| | /
|__________________________________|/

规则

  • 允许尾随空格。
  • 允许尾随换行符。
  • 可以交换真实/错误值(对于真实多维数据集为真实值,对于不可能的多维数据集为真实值)
  • 输入样式应指定
  • 以字节为单位的最短代码获胜

1
我们需要输出那个确切的立方体还是任何不可能的立方体?
dzaima

1
@dzaima确切的多维数据集。
LiefdeWen

8
乍一看,我认为输入是ASCII艺术。松一口气
Arnauld

2
@Arnauld最终会变得很琐碎,因为您可以只查看特定位置的一个字符,然后将两个字符区分开。
JAD

8
@JarkoDubbeldam正确。我想到的更像是“接受任何大小的任何类似输入并弄清楚该多维数据集是否有效”
Arnauld

Answers:


4

SOGL V0.12,145个字节

─3n{_⁰
ā"¹K╚=+ƨψ≡tšÆA%εW#žt─M^_ξ0“6²⁰ _*ž}"⁵æκLνbΡ°■=μθΝv╝xxΛTγ►℮ΞyF“'№⁰┐∙ž}"⁸Βλμž╚⅔\Ρ═⁴-θ=╚_>◄4℮`ε║t“'¦⁰ā;∫0 /ž}╬5}'Æ6«@┐2Ο3∙:Aža.?X"≥YΤ%‘5n}L9ž

在这里尝试!
该程序将行数据存储为3个单独的基数36-46,并对每个ž值进行解码并在主数组中存储值。
由于我滥用对角线的方式,输出包含27行带空格的线(OP允许)

输入:
0-不可能
1-可能

说明:

The first line is basically a substitute ⁰ with ─3n{_

ā                   push an empty array (the canvas for the whole cube)
 "...“              pushes 29714643711764388252557994982458231735529743027583646902
      6²─           base-36 decodes it
         3n{     }  for each group of 3 numbers do (where the numbers are X, Y, length)
            _         put all the contents on the stack (in the order X, Y, length)
              _*      get POP amount of underscores
                ž     in the canvas at the positions x;y (the position of the 1st char, 1-indexed) put the underscores

"...“             pushes 19564601770087915522037775830252836261712294966673526596188
     '№─          base-46 decodes it
        3n{    }  for each group of 3 numbers do
           _        put all the contents on the stack
            ┐∙      get an array of "|"s with the length of POP
              ž     in the canvas at the position x;y (position of the top char, 1-indexed) put the vertical bar

"...“                    pushes 124633728256573776407884156928319785312464662536125755768
     '¦─                 base-40 decodes it
        3n{           }  for each group of 3 numbers do
           _               put all the contents on the stack
            ā;             one below the stack put an empty array (canvas for the diagonal line)
              ∫    }       for range(length) do
               0             TMP
                 /           push "/"
                  ž          at the position (iter; 0), 1-indexed put a "/". This extends the array one line upward and causes the extra spaces.
                    ╬5     in the canvas at the position x;y(1-indexed, the top position) put the diagonal line canvas without overriding with spaces

'Æ             push 36
  6«           push 12
    @┐2Ο       push two spaces, encased in vertical bars - "| | |"
        3∙     get an array of 3 of those
          :A   save on variable A
            ž  in the canvas, at the positions 36; 12 put the array

a                 push the variable A
 .?         }     if the input is non-0, then
   X                remove the variable A off of the stack
    "≥YΤ%‘          push "|_|_|__________"
          5n        chop that into an array of strings of length 5
             L9ž  at positions 10;9 insert the top of stack (either the ["| | |","| | |","| | |"] or ["|_|_|","_____","","_____"]) in the canvas

它根据输入如何变化?
LiefdeWen

0-不可能,1-可能
dzaima

1结果输入不应该与其他真实输入一样输出"test"吗?
Jonathan Allan

@JonathanAllan应该吗?在SOGL中,真实数字输入为非0数字。test在输入框中键入将导致错误。如果这是个大问题,我可以直接输入字符串,其中“”将是虚假的,而其他所有内容都是真实的
dzaima

哦,对了,我想如果语言是强类型的,那么处理任何类型的输入都可能超出范围。
Jonathan Allan

9

果冻 187间  166 字节

ḣ9;⁾| ṁ5¤oµ€“µ½¿‘¦
“ _/ |/|”;€⁶;”_ṁ"“¡ẇḞ6’D¤ṃ@“Ė⁸ġṾṗ¢œƝṇRK⁹ṄẸŒÐ¤ɓḂı)ḥṆqƓị¹÷ḄƝṁPʠVW1JĊTc;[¤ÆWŒṠṬ#ʋÆ6ẉ⁷ZḷƊḤƑẹẠGḊ|qi×Ƭ®ÐėƁ1(⁸ṪU¹Bgoƭ<Gḋ×c:ȦṚƇĊ¬e*⁽%ḷİ°U’Fs27ǹ⁸?x€15¦€19Y

完整的程序。

在线尝试!

怎么样?

103字节是101位以250为基数的数字,它是可能的多维数据集的以8为基数的压缩,添加了结尾空格以使行长相等,没有换行,并且每行中间没有18个字符,像这样,但没有换行符:

         _________________ 
        / _____________  /|
       / / ___________/ / |
      / / /| |       / /  |
     / / / | |      / /   |
    / / /| | |     / / /| |
   / / / | | |    / / / | |
  / / /  | | |   / / /| | |
 / /_/___|_|_|__/ / / | | |
/________________/ /  | | |
| ______________ | |  | | |
| | |    | | |_| | |__| | |
| | |    | |___| | |____| |
| | |   / / ___| | |_  / / 
| | |  / / /   | | |/ / /  
| | | / / /    | | | / /   
| | |/ / /     | | |/ /    
| | | / /      | |   /     
| | |/_/_______| |  /      
| |____________| | /       
|________________|/        

以8为基数的8位数字代表字符串:

1      2    3    4    5    6        7        0
"   ", "_", "/", " ", "|", "/ / /", "| | |", "_____"

因此压缩方式如下所示,其中1s,6s,7s和0s将被上面显示的字符串替换:

111000__111/ 00___  /|11 / / 00_/ / |116| |11 / /  |1  6 | |11/ /1|1 671  6| |16 71 6 | |  6  7167 6___|_|_|__6 7/000_/ /  7| 00____ | |  771 7_7__771 | |___7____| |71/ / ___7_  / / 7  6176  7 61 7 / /1761  7/ /1 7 / /11| |1/1  7/_/0__| |  /11| |00__| | /11 |000_|/11  

如果该多维数据集是不可能的程序,该程序将反转该过程并更改需要更改的字符:

“ _/ |/|”;€⁶;”_ṁ"“¡ẇḞ6’D¤ṃ@“ ... ’Fs27ǹ⁸?x€15¦€19Y  Main link: V
                                                     ...splitting this up...
                                                     ...Main link part 1:
“ _/ |/|”;€⁶;”_ṁ"“¡ẇḞ6’D¤ - make the list of strings of characters
“ _/ |/|”                 - list of characters = " _/ |/|"
           ⁶              - literal space character
         ;€               - concatenate €ach -> ["  ","_ ","/ ","  ","| ","/ ","| "]
             ”_           - literal = '_'
            ;             - concatenate -> ["  ","_ ","/ ","  ","| ","/ ","| ", '_']
                        ¤ - nilad followed by link(s) as a nilad:
                 “¡ẇḞ6’   -   base 250 literal = 31111555
                       D  -   convert to decimal list -> [3,1,1,1,1,5,5,5]
                "         - zip with:
               ṁ          -   mould like
                          -   -> ["   ","_","/"," ","|","/ / /","| | |","_____"]

                                                     ...Main link, part 2:
...ṃ@“ ... ’Fs27 - make the rows of a possible cube without the middle repetitions:
...              - part 1, above
     “ ... ’     - the 101 digit base 250 number
   ṃ@            - base decompression with swapped @rguments
            F    - flatten (because the digit values we are using are actually lists)
             s27 - split into chunks of length 27 (into the rows)

                                                     ...Main link part 3:
...ǹ⁸?x€15¦€19Y - make "impossible" if need be, add the row middles and output
...              - part 2, above
       ?         -  if:
      ⁸          -    chain's left argument = V
   Ç             - ...then: call last link (1) as a monad
                 -          (make it an impossible cube - see link 1, below)
    ¹            - ...else: identity (do nothing)
            €    - for €ach
         ¦       - apply sparsely:
       15        - ...to index: 15
     x€    19    - ...this: repeat €ach nineteen times
               Y - join with newlines
                 - implicit print

ḣ9;⁾| ṁ5¤oµ€“µ½¿‘¦  Link 1, replace characters to make impossible: rows
                 ¦  apply sparsely:
            “µ½¿‘   ...to indexes: code-page indexes = [9,10,11]
                    ...this:
          µ€          for €ach:
ḣ9                      head to index 9
        ¤               nilad followed by link(s) as a nilad:
   ⁾|                     list of characters = ['|',' ']
      ṁ5                  mould like 5 = ['|',' ','|',' ','|']
  ;                     concatenate
         o              logical or (vectorises) with the row
                          (which has the effect of appending the rest of the row)

我故意“使”多维数据集“变形”,而您利用了+1。
LiefdeWen

5

的JavaScript(ES6), 352个   344  333字节

@YairRand节省了2个字节

x=>[...'mnopqrstuvwxyz01~'].reduce((p,c)=>(l=p.split(c)).join(l.pop()),`1yup
1z uux z|
1/z uu_/z |
yqswtqvy|
yys wtyvq|
qs0t sw
ys 0ts w
 snt/v0
v_/x${x?0:'|_|_|'}m/v 0
/~_${b=x?0:'o_'}p/zn
| ~${b}m wnrynuo_0__0ryywp0owryv p0_ vr st0/vrst 0vr/vtn/zrvtqwyzr/_/pow z
wuu__wz
|um|/~xo1yyq0w |z /q o__w| |szp~t111svzr
0qy pu~ox_ny0muxx`)

演示版


删除a=并替换为其一个引用0(在引用时始终等于)将节省两个字节。
Yair Rand

3

木炭,188字节

__¶____¶_¶↙¹↓↑⁷↗³P↓⁶↗²↓↓⁷←↙⁴↓↓↓↙↗⁸↑¹²←P←×_³⁵↓↙⁹↑←×_³⁴P↗⁹↓↓¹¹↗→×_³⁴↑¹¹↖P←×_²⁹↗⁷←P←×_³¹↙←×_²⁹↓↙⁶↑←_P↗⁷↓↘P↓⁹←←P×_³²↓↓⁹↗→×_³⁰P↑⁹↖←×_²⁷↗⁶←←↙⁵↘→→↗⁵UO²¹±²_↗↗P×_¹⁹←↙|←P↑²←←↑²FNUO⁵±³ |↑↑P↑⁴F²«→→P↑⁶

在线尝试!链接是虚假版本;将输入从0更改1为真实版本。这是上述程序的近似详细代码:

Print("__\n____\n_\n");

通过右“孔”打印可见的背面部分。

Print(:DownLeft, 1);
Move(:Down);
Print(:Up, 7);
Print(:UpRight, 3);
Multiprint(:Down, 6);
Print(:UpRight, 2);
Move(:Down);
Print(:Down, 7);
Move(:Left);
Print(:DownLeft, 4);

打印正确的“孔”。

Move(3, :Down);
Move(:DownLeft);
Print(:UpRight, 8);
Print(:Up, 12);
Move(:Left);
Multiprint(:Left, Times("_", 35));
Move(:Down);
Print(:DownLeft, 9);
Move(:Up);
Print(:Left, Times("_", 34));
Multiprint(:UpRight, 9);
Move(:Down);
Print(:Down, 11);
Move(:UpRight);
Print(Times("_", 34));
Print(:Up, 11);

打印立方体的外边缘。

Move(:UpLeft);
Multiprint(:Left, Times("_", 29));
Print(:UpRight, 7);
Move(:Left);
Multiprint(:Left, Times("_", 31));
Move(:DownLeft);
Print(:Left, Times("_", 29));
Move(:Down);
Print(:DownLeft, 6);
Move(:Up);
Print(:Left, "_");
Multiprint(:UpRight, 7);

打印多维数据集的顶部“孔”。

Jump(1, 2);
Multiprint(:Down, 9);
Move(2, :Left);
Multiprint(Times("_", 32));
Move(:Down);
Print(:Down, 9);
Move(:UpRight);
Print(Times("_", 30));
Multiprint(:Up, 9);
Move(:UpLeft);
Print(:Left, Times("_", 27));

打印立方体的前“孔”。

Print(:UpRight, 6);
Move(2, :Left);
Print(:DownLeft, 5);
Jump(3, 1);
Print(:UpRight, 5);
Oblong(21, Negate(2), "_");
Move(2, :UpRight);
Multiprint(Times("_", 19));
Move(:Left);
Print(:DownLeft, "|");
Move(:Left);
Multiprint(:Up, 2);
Move(2, :Left);
Print(:Up, 2);

通过正面的“孔”打印可见的背面部分。

for (InputNumber()) Oblong(5, Negate(3), " |");

如有必要,使立方体变为不可能。

Move(2, :Up);
Multiprint(:Up, 4);
for (2) {
    Move(2, :Right);
    Multiprint(:Up, 6);
}

通过顶部“孔”打印可见的背面部分。

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.