11
Innovation is a card game where players battle through the ages, from prehistory to modern times, in an attempt to earn achievements faster than their opponents.
Each card in Innovation is unique, and provides a player with a number of icons. If we treat each card as a 2x3 grid, then three of the four slots on the left and bottom edges will always been taken up by icons (the symbols in black hexagons are not counted).
The game has 6 types of icons (castles, crowns, leaves, lightbulbs, factories and clocks), which we will represent arbitrarily using the chars 012345
. Using #
to represent the black hexagon, we can use four chars to represent the icons on each card. For example, the cards above are
0.. #.. 3.. 1.. -> 03#0 #331 355# 144#
3#0 331 55# 44#
Now, in Innovation, cards in the play area are grouped into piles* which are splayed in one of four ways. For each example we'll use the cards above, assuming the leftmost card, 03#0
, is at the top of the pile.
No splay: only the top card is visible
0..
3#0
Splay left: the top card is fully visible, as well as the right third of all cards below
0..|.|.|.|
3#0|1|#|#|
Splay right: the top card is fully visible, as well as the left third of all cards below
1|3|#|0..
4|5|3|3#0
Splay up: the top card is fully visible, as well as the bottom half of all cards below.
0..
3#0
---
331
---
55#
---
44#
The challenge
Input will be a single space-separated string consisting of two parts:
- A splay direction, which is one of
!<>^
, representing no splay, splay left, splay right or splay up respectively. - A non-empty list of cards, each of which is 4 characters long and consisting of the chars
012345#
. The leftmost card is at the top of the pile, and each card contains exactly one#
.
Answers may be functions, full programs or equivalent. You may choose whether the splay direction is first or last, i.e. choose one of the two formats below:
> 03#0 #331 355# 144#
03#0 #331 355# 144# >
Output will be a list of six numbers representing the count for each icon, e.g. for the example cards above:
! 03#0 #331 355# 144# -> 2 0 0 1 0 0
< 03#0 #331 355# 144# -> 2 1 0 1 0 0
> 03#0 #331 355# 144# -> 2 1 0 3 1 1
^ 03#0 #331 355# 144# -> 2 1 0 3 2 2
For instance, the no splay case had two 0
icons and one 3
icon showing, giving the first line. Note that we don't count #
s, since the black hexagons aren't icons.
You may choose any reasonable and non-ambiguous way of representing the list, e.g. delimiter-separated or using your language's natural list representation.
Test cases
! 113# -> 0 2 0 1 0 0
< 113# -> 0 2 0 1 0 0
> 113# -> 0 2 0 1 0 0
^ 113# -> 0 2 0 1 0 0
! 000# 12#2 -> 3 0 0 0 0 0
< 000# 12#2 -> 3 0 1 0 0 0
> 000# 12#2 -> 3 1 1 0 0 0
^ 000# 12#2 -> 3 0 2 0 0 0
! 000# 111# 222# -> 3 0 0 0 0 0
< 000# 111# 222# -> 3 0 0 0 0 0
> 000# 111# 222# -> 3 2 2 0 0 0
^ 000# 111# 222# -> 3 2 2 0 0 0
! 335# #101 21#2 333# 2#20 3#33 4#54 #133 3#33 32#2 -> 0 0 0 2 0 1
< 335# #101 21#2 333# 2#20 3#33 4#54 #133 3#33 32#2 -> 1 1 2 5 1 1
> 335# #101 21#2 333# 2#20 3#33 4#54 #133 3#33 32#2 -> 0 3 3 7 1 1
^ 335# #101 21#2 333# 2#20 3#33 4#54 #133 3#33 32#2 -> 2 4 4 10 1 2
Note that something like !
is invalid input, since the list is guaranteed to be non-empty.
* For the purposes of this challenge, we're ignoring pile colours.