Programming Puzzles & Code Golf is about to get a new moderator, Dennis! This challenge is a tribute to him and our other active (or recently active) moderators: Doorknob, Martin Büttner, and Chris Jester-Young. The challenge title is meant to be read to the tune of the Pepto Bismol song.
Basically, we're going to treat them all to pizza at The Nineteenth Bite Pizzeria, but we need to make sure they share it fairly because some of the mods are known to be pizza addicts!
The pizzas sold by the pizzeria are all rectangular blocks of text. The width and length of a pizza may be any non-negative integers as long as their product is divisible by four. Each grid space in the block of text pizza represents a slice, so it's always possible to split the slices up into four equal groups.
The mods will collectively order a single pizza, providing its width and length parameters to their server in any reasonable format such as [width],[length]
. Just before the pizza arrives at their table, you need to label each slice with the initial of the mod who gets to eat it to ensure they all share fairly. Everyone should get the same number of slices.
E
is for DennisD
is for DoorknobM
is for MartinC
is for Chris
The mods are a little persnickety, however, and require that their respective sets of slices be path-connected, that is, that all their slices can be reached from one another by moving up, down, left, and right, not crossing anyone else's slices (and not moving diagonal). The don't care how you do this as long as it is done.
Once you've accurately labeled each slice, deliver the pizza to the mods with an optional trailing newline.
Your labeler may be a program or a function and can print or return the labeled pizza. The shortest labeler in bites wins.
Examples
Example 1
Order: 4,1
Some Possible Labeled Pizzas:
EDMC
MEDC
CDEM
Example 2
Order: 4,4
Some Possible Labeled Pizzas:
MMMM
CCCC
DDDD
EEEE
DEMC
DEMC
DEMC
DEMC
CCCC
DEEM
DEEM
DDMM
Example 3
Order: 8,3
Some Possible Labeled Pizzas:
MMMMMMCC
DDDDCCCC
DDEEEEEE
DDDCMMMM
DCDCMEEE
DCCCMEEE
Example 4
Order: 20,5
A Possible Labeled Pizza:
DDDDDDDDDDDDMCCCCCCCCCCC
DEEEEEEEEEEDMMMMMMMCCCCC
DEEEEEEEEEEDMMMCCCCCCCCC
DEEEEEEEEEEDMMMMMMMMCCCC
DDDDDDDDDDDDMMMMMMMMMMMC
(The D
's here are not simply-connected but that's ok.)