25
2
As you probably know, there have been multiple lovely Jimmy challenges recently popping up. In these challenges, you were challenged with our beloved friend's acrobatics skills. Now we've got a different challenge for you. Today you will be identifying different types of Jimmys!
Explanation
There are three varieties of Jimmys: dwarf, acrobat, and bodybuilder.
This is dwarf Jimmy: o
This is acrobat Jimmy: /o\
This is bodybuilder Jimmy: /-o-\
These Jimmys are all great friends and they like to stand on the same line as each other. Your task is, given a Jimmy scene like so:
o /o\ o /-o-\/-o-\ o /o\
Output the amount of dwarves, acrobats, and bodybuilders on the line, respectively.
The challenge
Take input in any reasonable form as a Jimmy scene, as shown in an example above.
The input string should be one line and optionally contains the three varieties of Jimmys and optional whitespace.
The string will not necessarily contain all of the Jimmy varieties or whitespace.
The string will not contain any characters not in
o/\ -
.Any combination of Jimmy varieties is possible. This means that the same or different type of Jimmy can be next to each other. You must account for that.
Leading and trailing whitespace is optional and by no means required - your program should account for a string with or without leading and/or trailing whitespace.
The string should contain only valid Jimmys and whitespace. For instance,
---///---
is not allowed because it is not a valid Jimmy sequence.
Output three numbers: The count of dwarves, acrobats, and bodybuilders in the scene (in respective order).
This may be an output to the console as space-separated integers, or it may be a return value from a function as some sort of container (i.e an array type).
The output, in whatever format, must be ordered as mentioned in the top bullet above this rule.
Standard rules and loopholes apply.
Test cases
/-o-\ /-o-\ o/o\ /-o-\ /-o-\ /-o-\
OUTPUT: 1 1 5
o o /o\ o o o /o\ /o\
OUTPUT: 5 3 0
/-o-\ /-o-\ /-o-\/-o-\ o /o\/o\ /-o-\o /-o-\ /o\/-o-\
OUTPUT: 2 3 7
/-o-\ o /-o-\ o/o\
OUTPUT: 2 1 2
If you'd like more test cases, use this tool to generate more random test cases.
Scoring
This is code-golf, so lowest score in bytes wins.
You can view the leaderboard for this post by expanding the widget/snippet below. In order for your post to be included in the rankings, you need a header (# header text
) with the following info:
The name of the language (end it with a comma
,
or dash-
), followed by...The byte count, as the last number to appear in your header.
For example, JavaScript (ES6), 72 bytes
is valid, but Fortran, 143 bytes (8-bit)
is invalid because the byte count is not the last number in the header (your answer will be recognized as 8 bytes - don't take advantage of this).
<!-- Run the snippet to see the leaderboard. Report any bugs to @xMikee1 on Github. --> <iframe src="https://ozewski.github.io/ppcg-leaderboard/?id=188391" width="100%" height="100%" style="border:none;">Oops, your browser is too old to view this content! Please upgrade to a newer version of your browser that supports HTML5.</iframe><style>html,body{margin:0;padding:0;height:100%;overflow:hidden}</style>
Can we assume all inputs will have at least one leading and trailing space? – Shaggy – 2019-07-15T15:51:23.280
@Shaggy No. Inputs only have optional trailing or leading spaces. – connectyourcharger – 2019-07-15T15:51:58.947
Output three numbers: The count of dwarves, acrobats, and bodybuilders in the scene (in respective order). - is this order a requirement?! – Jonathan Allan – 2019-07-15T16:20:27.813
@JonathanAllan Yes, how else would we distinguish the three numbers? I was trying to save you all bytes - using some sort of mapping like
{'dwarves': 2, 'acrobats': 5, 'bodybuilders': 0}
would cost a terrible amount of bytes.2 5 0
is much simpler. – connectyourcharger – 2019-07-15T16:22:07.160Usually the answerer would just state their output format. This keeps I/O flexible. FWIW it'll cost me a byte. – Jonathan Allan – 2019-07-15T16:24:11.000
@JonathanAllan I mean, you could return an ordered array too, as I said in the challenge section. – connectyourcharger – 2019-07-15T16:24:54.250
So the output order is not strict then? – Jonathan Allan – 2019-07-15T16:26:58.883
@JonathanAllan No, it still is, because otherwise you could never tell which number corresponds to which count. Perhaps I should make that more clear in the post. – connectyourcharger – 2019-07-15T16:30:04.200
7@connectyourcharger a more standard way would be to require answers to specify the order. – Expired Data – 2019-07-15T16:31:19.693
Note how there is already an answer assuming we can. – Jonathan Allan – 2019-07-15T16:45:37.240
4Just to be explicit, can Dwarf Jimmys stand together? I see nothing suggesting otherwise. If so, a test case of
oo /o\ o o
would be nice – Veskah – 2019-07-15T17:10:37.147Are newlines valid separators in the output? – recursive – 2019-07-15T17:53:13.920
1@Veskah: The test case generator is capable of generating the sequence
oo
. – recursive – 2019-07-15T18:42:02.687I'm tempted to build an ANTLR/C# solution, but it wouldn't be a good golf :D – None – 2019-07-16T19:51:28.770
8There needs to be a [tag:jimmy] tag. – MilkyWay90 – 2019-07-16T20:21:58.993
@MilkyWay90 I can't create it, but I'm all for it. – connectyourcharger – 2019-07-16T20:38:38.240