17
1
It seems as of recent, there have been a lot a Jimmys falling to their death, as can be seen here, and here where you were asked to determine if Jimmy would fall. It is time we put a stop to this madness and try to save Jimmy.
Jimmy has three body parts /
, o
, and \
arranged like this
/o\
Platforms are represented with -
. Jimmy will fall off their platform iff they have two or more body parts that are not directly above a platform.
Some examples:
/o\
- -------
Jimmy will balance since all their body parts are above a -
.
/o\
------ ---
Jimmy will balanced since two body parts are above -
s.
/o\
-- ---- --
Jimmy will balance even though they are split between two platforms
/o\
-
Jimmy will not balanced since two body parts are not above a platform.
Since my platform supply is running low, I only have platforms with a length of 5, and it is important we use as few as possible.
Your task is to take an input of Jimmys and output a string of platforms which will save all of the Jimmys in the input. Your output must use as few platforms as possible, but each platform must be 5 -
's wide.
Note that the rule of the platform being 5 -
wide, means that each platform must have a space between them. ----------
is not valid in the output since it will be considered a platform of length 10 and not two platforms of length 5.
Test Case's
/o\ /o\/o\ // input
----- ----- // output
/o\ /o\
----- -----
/o\ /o\ // same input as above
----- ----- // this is also valid output
/o\ /o\
-----
Standard rules apply.
This is code-golf, may the shortest answer win!
1Does board position matter if it could go multiple places or anywhere is fine as long as all Jimmys are saved? Is there always at least 1 Jimmy? – Veskah – 2019-07-05T17:42:06.493
2@Veskah as long as all Jimmys are saved using the fewest possible platforms, position does not matter, so there will be multiple valid outputs for each input. There is no condition on how many Jimmys there will be in the input, an empty string would be a valid input. – Quinn – 2019-07-05T17:45:17.853
3Test case 4 looks like a scary face – Expired Data – 2019-07-05T17:48:24.600
1Jimmy's not happy with you. – connectyourcharger – 2019-07-05T18:29:47.627
1@connectyourcharger I was just trying to help Jimmy! – Quinn – 2019-07-05T18:31:16.477
1I don't think Jimmy likes all this negative attention, but he appreciates the help. – connectyourcharger – 2019-07-05T18:32:04.373
1All joking aside - can we output empty platforms without any Jimmys on top? – connectyourcharger – 2019-07-05T18:38:13.703
1@connectyourcharger as I mentioned in the question, you must use as few platforms as possible, so outputting platforms without any Jimmys on them would likely break this rule. – Quinn – 2019-07-05T18:41:29.980
1@Quinn Ok, gotcha. – connectyourcharger – 2019-07-05T18:42:00.983
1What are the rules for trailing whitespace in input/output? – negative seven – 2019-07-05T18:57:54.137
1@negativeseven Both inputs and outputs may contain trailing whitespace – Quinn – 2019-07-05T18:59:22.297
2Follow-up: place as many Jimmys as possible on platforms in such a way that they will not fall. – val says Reinstate Monica – 2019-07-05T19:06:48.447
2@val that is actually one of the linked questions - I followed up after that one :P – Quinn – 2019-07-05T19:07:32.457
2@Quinn That one tells to only count them. Why not actually calculate placement string like in this challenge? – val says Reinstate Monica – 2019-07-05T19:09:40.417
1@val ah, you are right - that could be another follow up! – Quinn – 2019-07-05T19:10:47.183
7I can see so many Jimmy follow-ups in the future. – connectyourcharger – 2019-07-05T19:30:22.060
Is my output allowed to contain the input demonstrating that all of the platforms correctly save all of the Jimmies? – Neil – 2019-07-07T10:17:52.207
@Neil Im torn on how to answer you, I keep going back and forth on it - but I think ill allow it – Quinn – 2019-07-08T13:14:17.890