19
\$\begingroup\$

I was just playing the board game Sorry! with some people, and I realized that I could base a few interesting challenges off of it. This one is pretty simple.

You task is simply to output an version of a sorry board, placing pieces where I tell you to.

Specs

First, here is an image of an actual Sorry! board for reference:

Sorry! Board

The empty board looks like:

# > - - o # # # # > - - - o # #
#   #   S                     v
o   #             H # # # # # |
|   #                         |
|   #                       S o
|   #                         #
^   H                         #
#                             #
#                             #
#                         H   v
#                         #   |
o S                       #   |
|                         #   |
| # # # # # H             #   o
^                     S   #   #
# # o - - - < # # # # o - - < #

Notice a few features.

  • The #'s are empty squares.
  • The S's and H's are Start's and Home's respectively.
  • The >v<^'s are the start of the slides, depending on which direction they face.
  • The |'s and -'s are the middles of slides, depending on if they're horizontal or vertical.
  • The o's are the end's of slides.
  • Each column is separated by a column of spaces to make it look more square-like.

Now here is what you have to do:

  • Your input is a list of coordinates of various pieces that have been placed on the board.
  • The coordinates start at 0 at the square outside the Start of the bottom color (yellow in the picture), and increase by one per square clockwise.
  • After these 60 squares, the safe zones have the next and last 20 coordinates, starting from the one on the bottom (which gets 60-64), then going clockwise.
  • You will have to place star's(*'s) on the correct coordinate, replacing the character underneath for all players.
  • Additionally, if any of the players are on the start square of a slider, move them to the end of the slider before placing them.
  • You can assume that there will be no collisions, before or after resolving sliders.
  • You con't need to worry about the Home's or Start's.
  • You can be 1-indexed if you want, but the test cases are 0-indexed.

Test Cases

[0, 20] ->

# > - - o # # # # > - - - o # #
#   #   S                     v
*   #             H # # # # # |
|   #                         |
|   #                       S o
|   #                         #
^   H                         #
#                             #
#                             #
#                         H   v
#                         #   |
o S                       #   |
|                         #   |
| # # # # # H             #   o
^                     S   #   #
# # o - - - < # # # # * - - < #

[2, 7, 66] ->

# > - - o # # # # > - - - o # #
#   #   S                     v
o   #             H # # # # # |
|   #                         |
|   #                       S o
|   #                         #
^   H                         #
#                             #
#                             #
#                         H   v
#                         #   |
o S                       #   |
|                         #   |
| # * # # # H             #   o
^                     S   #   #
# # o - * - < # # * # o - - < #
\$\endgroup\$
  • 1
    \$\begingroup\$ I would have thought this would be more interesting if the values were given as distances from the respective start squares (so for instance the first test case might be 0, 5 and the second might be 2, 60, 37). \$\endgroup\$ – Neil Dec 7 '16 at 10:20
  • \$\begingroup\$ @Neil how would you know which start square to use? \$\endgroup\$ – Maltysen Dec 7 '16 at 12:24
  • \$\begingroup\$ Sorry, I assumed that you used the squares in clockwise order, but I guess that wouldn't be very fair for a 2-player game. \$\endgroup\$ – Neil Dec 7 '16 at 12:26
  • \$\begingroup\$ @Closevoters: What's unclear about this? If you identify some specific concerns, it will make it easier to fix them so that this can stay open. \$\endgroup\$ – DJMcMayhem Dec 7 '16 at 17:30
  • \$\begingroup\$ My confusion is about the indexing, before and after 60 has been reached and when to mark locations in the home section. I think if you clarified your examples more it would make more sense. Otherwise it looks pretty cool. \$\endgroup\$ – jacksonecac Dec 7 '16 at 20:34
1
\$\begingroup\$

Python 2, 476 bytes

Short 3-line solution (Try it online)

s=map(list,''.join(b if b in'#^v<>-|oSH~'else' '*int(b,16)for b in "#>--o####>---o##~#1#1SAv~o1#6H#####|~|1#C|~|1#BSo~|1#C#~^1HC#~#E#~#E#~#CH1v~#C#1|~oSB#1|~|C#1|~|#####H6#1o~^AS1#1#~##o---<####o--<#").split('~'))
for i in input():x,y=(lambda n:([11-n,15]*12+[0,26-n]*14+[n-26,0]*16+[15,n-41]*14+[71-n,15]*4+[13,n-50]*5+[70-n,13]*5+[2,75-n]*5+[n-65,2]*5)[2*n:2*n+2])((lambda n:4if n in[5,20,35,50]else 3if n in[12,27,42,57]else 0)(i)+i);s[y][x]='*'
for r in s:print' '.join(r)

One-liner in 534 (Try it online):

for r in(lambda B,I:[[[i,j]in map(lambda n:([11-n,15]*12+[0,26-n]*14+[n-26,0]*16+[15,n-41]*14+[71-n,15]*4+[13,n-50]*5+[n-64,13]*5+[2,75-n]*5+[n-65,2]*5)[2*n:2*n+2],map(lambda n:n+4if n in[5,20,35,50]else n+3if n in[12,27,42,57]else n,I))and'*'or b for i,b in enumerate(a)]for j,a in enumerate(B)])(map(list,''.join(b if b in'#^v<>-|oSH~'else' '*int(b,16)for b in"#>--o####>---o##~#1#1SAv~o1#6H#####|~|1#C|~|1#BSo~|1#C#~^1HC#~#E#~#E#~#CH1v~#C#1|~oSB#1|~|C#1|~|#####H6#1o~^AS1#1#~##o---<####o--<#").split('~')),input()):print' '.join(r)

I assume indices of safe zone this way:

#  >  -  -  o  #  #  #  #  >  -  -  -  o  #  #
#     74    S                                v
o     73                   H 75 76 77 78 79  |
|     72                                     |
|     71                                  S  o
|     70                                     #
^     H                                      #
#                                            #
#                                            #
#                                      H     v
#                                      60    |
o  S                                   61    |
|                                      62    |
|  69 68 67 66 65 H                    63    o
^                                S     64    #
#  #  o  -  -  -  <  #  #  #  #  o  -  -  <  #

Explanation (lines are separated a bit for better understanding):

# Hardcode board. Spaces are changed to their number in hex (as there are up to 14 spaces in row)
# Unfortunatly v^<> characters made board non-symmetrical and replacing chars costs too much in python, so I had to hardcode it all
B="#>--o####>---o##~#1#1SAv~o1#6H#####|~|1#C|~|1#BSo~|1#C#~^1HC#~#E#~#E#~#CH1v~#C#1|~oSB#1|~|C#1|~|#####H6#1o~^AS1#1#~##o---<####o--<#"

# Encode board to list of lists of characters
s=map(list,''.join(b if b in'#^v<>-|oSH~'else' '*int(b,16)for b in B).split('~'))

# Map coordinates, based on n (awfully long)
# Creates long list (lenght of 80) with values based on n and only one valid, which occures under index n
l=lambda n:([11-n,15]*12+[0,26-n]*14+[n-26,0]*16+[15,n-41]*14+[71-n,15]*4+[13,n-50]*5+[70-n,13]*5+[2,75-n]*5+[n-65,2]*5)[2*n:2*n+2]

# Returns additional move of n if it appers to be on slide start
j=lambda n:4if n in[5,20,35,50]else 3if n in[12,27,42,57]else 0

# Here takes input as list of numbers, get coordinates for them and update board with *
for i in input():x,y=l(j(i)+i);s[y][x]='*'

# Print board, spacing characters with one whitespace
for r in s:print' '.join(r)
\$\endgroup\$

protected by mbomb007 Apr 6 '17 at 14:16

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.