overwrite it with the result of looking up the adjacencies of connecting box-drawing characters in the table. Read the grid and write it to the canvas without moving the cursor. Explanation: ≔⪪#╗#║╝╗#╔═╔╚╔╚╔¹ηĬreate a table of box-drawing characters which serves two purposes: 1) to look up to see whether an adjacent box-drawing character wants to connect 2) (after some bit twiddling) to look up which box-drawing character to place. Byte count is adjusted for deverbosifier bug and box drawing characters. Try it online! Link is to verbose version of code. ![]() You're running out of space on your minecart to write your code, so your code must be as short as possible! This is code-golf, so the shortest answer in bytes wins (remember that you may count your eight I/O characters as one byte).Ĭharcoal, 62 bytes ≔⪪#╗#║╝╗#╔═╔╚╔╚╔¹ηWS⊞υι≔⪫υ⸿θPθFθ¿⁼.ι§η⊖⍘⭆⪪⭆KV﹪÷⊕⌕ηκX²λ²¦²⮌κ²ι Technically, in Minecraft, this might cause the side rails to turn to face the new rail and then curve, but in this specific challenge, we'll just assume that existing straight rails will not turn, and you just need to connect up exactly two of the adjacent, correctly-oriented rails in accordance to the S-E rule.══.══. You are guaranteed that at least two adjacent rails are facing the right way though. Note that it's valid to have rails facing the wrong direction next to placeholders. This contains every possible configuration. Note that it is possible for the rails to be on opposite sides of the placeholder, in which case you may need to place down a straight rail. To make this challenge a bit simpler, every placeholder will always have at least two adjacent rails that are already facing the appropriate direction, so you should not change any cells except the placeholders. Your output should be a grid of the same size, but in each placeholder you are to place a rail according to the rules given. To simplify a bit, your input will only contain straight rails, placeholders, and blanks. This will be a grid, so you may take it as a matrix of characters, a list of strings, newline-separated strings, etc. You will be given input in a convenient format for a layout of existing rails. You may count these eight characters as one byte in your code (this is just to allow people to use box-drawing characters instead of just like " |-WXYZ#" or something not as nice-looking). You may select any characters I choose to use box-drawing characters in my examples. I/Oįor this challenge, you will need eight distinct characters: empty space, vertical rail, horizontal rail, up-left curved rail, up-right curved rail, down-left curved rail, down-right curved rail, and placeholder. If there is a four-way junction, the rail will connect south and east. ![]() If there is a T-junction, the rail will always connect to the "vertical" branch of the T, and then it will prioritize south over north if the main branch is east-west, and east over west if the main branch is north-south. In that case, it will always favor going south-east (this is called the south-east or Z-X rule) (for this challenge, north is up, east is right, south is down, west is left). However, if there are more than two adjacent rails, it can't connect all of them. If they are not on opposite sides of the rail, the rail will curve to a 90 degree angle. When you place down a normal rail that has two adjacent rails, it will connect them. There are many types of rails, but today we're only interested in regular rails, which are also the only type that can curve. Minecraft has rails which allow you to move minecarts around on them for transporting players, entities, and items.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |