# Oreoorererereoo

Given an input string that is similar to the word "oreo", give an ASCII representation of the cookie that is as wide as the input string (to ensure cookie stability).

## Rules

• The input is lowercase, a non-empty string with no whitespace containing any combination of the strings "o" and "re", and containing only those strings.
• The string "o" represents the solid cookie, while the string "re" represents the filling.
• The output must be a stacked cookie that is as wide as the input string.
• The output may not be an array of strings
• The cookie must overlap the filling by one character on each side
• The characters used for the output don't have to match the output below (█ and ░), they just have to be different non-whitespace characters for the two parts of the cookie
• The whitespace padding on the left side of the filling is required, and any trailing whitespace is optional

## Examples

Input: oreo
Output:
████
░░
████

Input: o
Output:
█

Input: re
Output: (two spaces)

Input: rere
Output:
░░
░░

Input: oreoorererereoo
Output:
███████████████
░░░░░░░░░░░░░
███████████████
███████████████
░░░░░░░░░░░░░
░░░░░░░░░░░░░
░░░░░░░░░░░░░
░░░░░░░░░░░░░
███████████████
███████████████


Since this is code golf the shortest answer wins, good luck :)

• "The whitespace padding on each side of the filling is required". Does this actually mean that there must be a space character at the end of each line of filling? If so why? As long as it works visually then what does this requirement add to the challenge? Jan 6 '19 at 0:23
• @ ElPedro Good point, I modified the rules and @Dennis I edited the rules so the comments should be okay to clean up Jan 7 '19 at 3:22
• @JonathanAllan Since it's printing "ascii-art" I removed that rule, it looks like I forgot to update the question. Should be updated now. Jan 7 '19 at 16:05
• Awesome, thanks! Jan 7 '19 at 16:18
• @GammaGames, if whitespace on the right is not required anymore, I assume the output for test case re should be now acceptable as 1 or 2 spaces, not necessarily 2? Jan 10 '19 at 8:24

# Pepe, 364 bytes

Unfortunately the online interpreter does not take care of compressing comments, hence all o characters will be replaced by a space.. Neither the spaces nor the o are necessary, so this could be 295 bytes, but I like it more this way:

rEeEEeeEeEororEEoreoreeeEeeeeeorEEEEeoREeoreorEeEEeEEEEororEEoreorEEEEEoREeoreorEeEEEeeEeororEEoreoReoREoREEEeoREEEEEoreorEorEEEeorEEEEEoreEoREeoreoREEeoREEEEeEeeoREEEeoREeeEoREEEeoREEEEEEEorEEEeEorEEEeoREoREEEeoREEEEEoREEoReoreorEEEeEoREEEEEEeorEEEeoReEoREoREEEeoREEoReoroReEeoREoREEEeorEEEEeoReeoREEEeoREeeEoREEEeoREEEEEEEoreoReoReoREoREEEeoREEEEEoreeeeeEeEeoRee


Try it online!

## Ungolfed

There might be some golfing oppurtunities with flags which I missed, but I'm done for now:

# "function" for 'e'
rEeEEeeEeE rrEE
re          # remove duplicated argument
reeeEeeeee  # print space
rEEEEe      # decrement counter twice
REe re

# "function" for 'o'
rEeEEeEEEE rrEE
re      # remove duplicated argument
rEEEEE  # increment counter
REe re

# "function for 'r'
rEeEEEeeEe rrEE
re Re              # remove duplicated argument & char
RE REEEe REEEEE    # push 1
re rE rEEEe rEEEEE # replace 1
reE                # goto 1
REe re

# Main

REEe REEEEeEee                # read input & reverse
REEEe REeeE REEEe REEEEEEE    # push length-1 & move to r

rEEEeE rEEEe # dummy loop-var (fucking do-whiles...)
RE REEEe REEEEE REE  # while [label-1]

# Call the right procedure depending on current character,
# sets stacks up as follows:
#   R [ .... *currentChar ]
#   r [ (N-1) *count ]
Re re          # pop 1 & loop-counter
rEEEeE         # duplicate counter
REEEEEEe rEEEe # copy current char to other stack
ReE            # jeq to 'o'-label or 'e'-label

# Output currentChar count times:
RE REEEe REE # while [label-0]:
Re         #   pop 0
rReEe      #   print character
RE REEEe   #   push 0
rEEEEe     #   decrement counter
Ree

REEEe REeeE REEEe REEEEEEE  # push length-1 & move to r
re Re Re                    # pop 0, counter and 9((((currentChar
RE REEEe REEEEE             # push 1
reeeeeEeEe                  # print new-line

Ree


# Jelly,  16 14  13 bytes

-1 Thanks to Erik the Outgolfer

OḂƇẒṁ€aØ.¦€⁶Y


Uses 1 for the cream and 0 for the cookie.

Try it online!

### How?

OḂƇẒṁ€aØ.¦€⁶Y - Main Link: list of characters, V    e.g. 'orereo'
O             - ordinal (vectorises)                     [111,114,101,114,101,111]
Ƈ           - filter keep those for which:
Ḃ            -   modulo 2                               [111,    101,    101,111]
Ẓ          - is prime? (vectorises)                   [  0,      1,      1,  0]
ṁ€        - mould each like V                        [[0,0,0,0,0,0],[1,1,1,1,1,1],[1,1,1,1,1,1],[0,0,0,0,0,0]]
€   - for each:
¦    -   sparse application...
Ø.     -   ...to indices: literal [0,1] (0 is the rightmost index, 1 is the leftmost)
a       -   ...apply: logical AND with:
⁶  -               space character           [[0,0,0,0,0,0],[' ',1,1,1,1,' '],[' ',1,1,1,1,' '],[0,0,0,0,0,0]]
Y - join with newline characters            [0,0,0,0,0,0,'\n',' ',1,1,1,1,' ','\n',' ',1,1,1,1,' ','\n',0,0,0,0,0,0]
- implicit print                       ...smashes everything together:
-                                         000000
-                                          1111
-                                          1111
-                                         000000


Previous 16 byter:

ḟ”eẋ€Ly@Ø.¦€⁾r Y


Uses r for the cream and o for the cookie.

Try it online!

• I was hoping for a Jelly entry, such an interesting language! Jan 4 '19 at 17:39

# Canvas, 1918 17 bytes

e ∙╋
：r≠＊┤］；Ｌ×⁸↔⁸


Try it here!

Uses the annoyingly long code of ：r≠＊┤］ to remove rs from the input..

• That's a handy feature, and cool language! Jan 4 '19 at 1:48

# Japt-R, 16 15 bytes

re ¬£çX sX²èrÃû


Try it

                    :Implicit input of string U
re                  :Remove all "e"s
¬                :Split to array of characters
£               :Map each X
çX             :  Repeat X to the length of U
s           :  Slice from index
X²         :   Duplicate X
èr       :   Count the occurrences of "r"
Ã      :End map
û     :Centre pad each element with spaces to the length of the longest
:Implicitly join with newlines and output


## Alternatives

re ¬ËpUÊaD²èrÃû
re ¬£îX rr²i^Ãû


# C# (Visual C# Interactive Compiler), 95 bytes

n=>n.Replace("o",new String('-',n.Length)+"\n").Replace("re"," ".PadRight(n.Length-1,'|')+"\n")


Try it online!

# Alternative using Aggregate, 108 bytes

n=>n.Aggregate("",(d,c)=>d+(c<102?"":c<112?new String('-',n.Length)+"\n":" ".PadRight(n.Length-1,'|')+"\n"))


Try it online!

• now it trims trailing spaces.. Jan 4 '19 at 1:50
• There was enough feedback that I removed the trailing newline rule. Feel free to update your entry. Jan 4 '19 at 4:40
• Your replace doesn't work when the input is o, since the n.Length-2 will result in -1. Jan 4 '19 at 10:18
• The n.Length-2 is is for when the input has re. Jan 4 '19 at 16:27

# R, 106 bytes

function(s,N=nchar(s)){m=rep(el(strsplit(gsub('re',0,s),'')),e=N)
m[m<1&seq(m)%%N<2]=' '
write(m,1,N,,"")}


Try it online!

• -12 bytes thanks to @Giuseppe

Previous version with explanation :

# R, 118 bytes

function(s,N=nchar(s)){m=t(replicate(N,el(strsplit(gsub('re',0,s),''))))
m[m<1&row(m)%in%c(1,N)]=' '
write(m,1,N,,'')}


Try it online!

• -1 byte thanks to @Giuseppe

Unrolled code and explanation :

function(s){                       # s is the input string, e.g. 'oreo'

N = nchar(s)                     # store the length of s into N, e.g. 4

s1 = gsub('re',0,s)              # replace 're' with '0' and store in s1, e.g. 'o0o'

v = el(strsplit(s1,''))          # split s1 into a vector v of single characters
# e.g. 'o','0','o'

m = replicate(N,v)               # evaluate N times the vector v and arrange
# the result into a matrix m (nchar(s1) x N)
# e.g.
# 'o' 'o' 'o' 'o'
# '0' '0' '0' '0'
# 'o' 'o' 'o' 'o'

m = t(m)                         # transpose the matrix

m[m<1 & row(m)%in%c(1,N)] = ' '  # substitute the zeros (i.e. where < 1)
# on the 1st and last row of the matrix with ' ' (space)
# e.g.
# 'o' ' ' 'o'
# 'o' '0' 'o'
# 'o' '0' 'o'
# 'o' ' ' 'o'

write(m,1,N,,'')                 # write the matrix to stdout (write function transposes it)
# e.g.
# oooo
#  00
# oooo
}

• 106 bytes Jan 4 '19 at 22:40
• aaand 104 bytes returning a list of lines, which isn't acceptable here, but it's an interesting idea (essentially my SNOBOL submission translated to R) Jan 4 '19 at 23:11

# 05AB1E, 1817 16 bytes

'eKεD'rQ2*Igα×}.c


-1 byte thanks to @Emigna

Uses o for the cookie and r for the filling.

Explanation:

'eK                 '# Remove all "e" from the (implicit) input
#  i.e. "orereo" → "orro"
ε         }       # Map all characters to:
D                #  Duplicate the current character
'rQ            '#  Check if it's an "r" (1 if truthy; 0 if falsey)
#   i.e. "r" → 1
#   i.e. "o" → 0
·            #  Double that
#   i.e. 1 → 2
#   i.e. 0 → 0
Ig          #  Take the length of the input
#   i.e. "orereo" → 6
α         #  Take the absolute difference between the two
#   i.e. 2 and 6 → 4
#   i.e. 0 and 6 → 6
×        #  Repeat the duplicated character that many times
#   i.e. "r" and 4 → "rrrr"
#   i.e. "o" and 6 → "oooooo"
.c     # Then centralize it, which also imlicitly joins by newlines
# (and the result is output implicitly)
#  i.e. ["oooooo","rrrr","rrrr","oooooo"]
#   → "oooooo\n rrrr\n rrrr\noooooo"

• Creative solution, But it does not solve the problem entirely: oro would give a wrong answer Jan 6 '19 at 9:15
• @MarkSmit oro isn't a possible input, since the input will only contain os and res. Regardless, oro still seems to output correctly following the spec, since it outputs ooo\n r\nooo. What is wrong about it? Jan 6 '19 at 10:44
• This is invalid: "The whitespace padding on each side of the filling is required" Jan 6 '19 at 15:14
• 2* can be · and the missing whitespace can be fixed by changing ».c to .c.B» Jan 7 '19 at 9:29
• @Emigna Ah, can't believe I haven't thought about ·, thanks! :) And always nice to have changing specs during the challenge, sigh.. Jan 7 '19 at 9:40

# Retina, 74 73 bytes

I feel like I haven't posted an answer in a very long time. Well, here I am. Also, Retina has changed a lot, and I feel like I suck at it now.

.+
$0$.0
(\d+)
*
e

o|r
$&¶ _$

+(/_/&o¶
oo¶
_$)/_/&r¶ rr¶ ¶$

m^r



Try it online!

• Whoa, what a crazy looking language. I like it! Jan 4 '19 at 1:58
• doesn't include trailing whitespaces.. Jan 4 '19 at 2:00
• I like how [or] means o or r instead of [ or ]. Makes my head hurt. Jan 4 '19 at 2:43
• @dzaima The question does not specify that trailing whitespaces are required. A comment asked, but no reply was given. Jan 4 '19 at 19:44
• @nedla2004 That actually helped me notice a way to save a byte. Thanks. Jan 4 '19 at 19:44

# Retina, 21 bytes

r

L$.$.+*$& \bee  Try it online! Explanation: r  Delete the rs. L$.
$.+*$&


List each letter on its own line repeated to the length of the original input.

\bee



Replace the first two ees on each line with a space.

• This breaks the rules: "The whitespace padding on each side of the filling is required" Jan 6 '19 at 15:16
• @NieDzejkob Sorry for overlooking that, should be fixed now.
– Neil
Jan 6 '19 at 16:14
• FYI trailing whitespace requirement lifted. Jan 8 '19 at 0:26
• @Neil You should fix that &amp; :P Jan 8 '19 at 0:35

# C (gcc), 135113109 104 bytes

#define $putchar(33 O(char*r){for(char*e,*o=r,x;*r;$-23))for(x=*r++>111,e=x?$-1),r++,o+2:o;*e++;$+x));}


Try it online!

• Shave off a few bytes with -D$=putchar – user77406 Jan 4 '19 at 13:55 • 131 bytes if you add a trailing newline as allowed by the rules. Jan 6 '19 at 13:54 • 127 bytes if you move the e=o to the condition of the first for loop and then remove the else. Jan 6 '19 at 14:20 • 118 bytes if you choose the cookie and filling characters carefully. Jan 6 '19 at 14:58 • 113 bytes Jan 6 '19 at 15:02 # JavaScript, 7265 64 bytes s=>s.replace(/.e?/g,([x,y])=>(y? : ).padEnd(s.length+!y,x))  Try it online # JavaScript ES6, 103 bytes ### Using replace 103 bytes: x=>x.replace(/o/g,"-".repeat(s=x.length)+ ).replace(/re/g," "+"|".repeat(s>1?s-2:0)+ ).slice(0,-1)  Try it online! ### Using split and map 116 bytes: x=>x.split("re").map(y=>("-"[h='repeat'](r=x.length)+ )[h](y.length)).join(" "+"|"[h](r>1?r-2:0)+ ).slice(0,-1)  Try it online! • JS, nice! You reminded me that I was going to add a rule about not having line returns at the end of the output, I've added it. Sorry about that! Jan 4 '19 at 1:45 • just removing the final newline is 12 bytes Jan 4 '19 at 1:51 • There was enough feedback that I removed the trailing newline rule. Feel free to update your entry. Jan 4 '19 at 4:44 • You can save a byte by using a template string with ${"|".repeat(s>1?s-2:0)} and its whitespaces, instead of using " "+"|".repeat(s>1?s-2:0). Jan 4 '19 at 10:26
• If you use backticks for the string in the first split, you can remove the parentheses around it. Jan 11 '19 at 19:56

# Perl 5-p, 47 bytes

s|o|X x($i=y///c).$/|ge;s|re|$".O x($i-2).$/|ge  Try it online! • This breaks the rules: "The whitespace padding on each side of the filling is required" Jan 6 '19 at 15:16 • with some variations tio.run/##K0gtyjH9/… Jan 7 '19 at 15:16 # Python 3, 77 bytes lambda x:x.replace("o","-"*len(x)+"\n").replace("re"," "+'.'*(len(x)-2)+"\n")  Try it online! • Clever! I did intend the output to not be printing whitespace for the filling (it's pretty much oreo ascii), so I have edited the rules accordingly. Sorry about that! And I always love a python answer :) Jan 4 '19 at 4:50 • @JonathanFrech migth as well delete the comments, that approach was invalidated. I'll work on golfing more tomorrow. Jan 4 '19 at 4:55 • You can remove the space at +" \n" to save a byte. Jan 4 '19 at 10:37 • @KevinCruijssen can I? The input program says the whole cookie must be as wide as the input. Jan 4 '19 at 16:18 • I interpreted that as meaning that a trailing space is the same (visually) as no space. That's the beauty of answers to ascii art challenges. If they look right they are right :-) Jan 4 '19 at 21:33 # Mathematica, 111 91 bytes #~StringReplace~{"o"->"O"~Table~(n=StringLength@#)<>"\n","re"->" "<>Table["R",n-2]<>" \n"}&  Try It Online! This was majorly shortened thanks to Misha's edits. My original code: (z=StringRepeat;n=StringLength@#;#~StringReplace~{"o"->"O"~z~n<>"\n","re"->" "<>If[n>2,z["R",n-2],""]<>" \n"})&  This code is not very fancy but it seems too expensive to convert away from strings and then back or to do anything else clever. In particular, with only 3-4 commands that have the name String, my original approach couldn't save bytes at all by trying to abstract that away. For example, the following is 129 bytes: (w=Symbol["String"<>#]&;z=w@"Repeat";n=w["Length"]@#;#~w@"Replace"~{"o"->"O"~z~n<>"\n","re"->" "<>If[n>2,z["R",n-2],""]<>" \n"})&  • A few improvements: StringRepeat can be Table since <> will convert the list into a string later; the If is unnecessary since we take the re branch only when n is at least 2; we can save on parentheses by defining n only when we use it. Try it online! Jan 5 '19 at 20:32 • @MishaLavrov The If was added because StringRepeat would throw an error on the case of "re"; it doesn't allow you to repeat a string 0 times. Table has no such limitation, so that's a big save! Jan 5 '19 at 21:33 # Perl 6, 37 bytes {m:g/o|r/>>.&({S/rr/ /.say}o*x.comb)}  Try it online! Anonymous code block that takes a string and prints the oreo, with o as the cookie and r as the cream. ### Explanation: { } # Anonymous code block m:g/o|r/ # Select all o s and r s >>.&( ) # Map each letter to *x.comb # The letter padded to the width S/rr/ / # Substitute a leading rr with a space .say # And print with a newline  • I didn't realize o could be used in place of ∘. Very nicely golfed. Jan 16 '19 at 13:22 # PHP, 10099 93 bytes $l=strlen($i=$argv[1]);$r=str_repeat;echo strtr($i,[o=>$r(X,$l)."
",re=>' '.$r(o,$l-2)."
"]);


Try it online!

OUCH. PHP's waaaay_too_long function names strike again!

Output:

$php oreo.php oreo XXXX oo XXXX$php oreo.php o
X

$php oreo.php rere oo oo$ php oreo.php oreoorererereoo
XXXXXXXXXXXXXXX
ooooooooooooo
XXXXXXXXXXXXXXX
XXXXXXXXXXXXXXX
ooooooooooooo
ooooooooooooo
ooooooooooooo
ooooooooooooo
XXXXXXXXXXXXXXX
XXXXXXXXXXXXXXX

• Invalid, cream lines need a trailing space Jan 5 '19 at 5:03
• Fixed the trailing space. Thanks! Jan 5 '19 at 12:09
• Oh boy, PHP! Also any trailing whitespace is now optional, there were enough people that pointed out that since it's printing out ascii it shouldn't really be required. Jan 7 '19 at 3:26

# Pyth, 28 bytes

FNzIqN"o"*lzN)IqN"r"+d*-lz2N
FNz                              For each value, N, in input
IqN"o"                        if the character is "o"
*lzN                    return the character times the length of the input
)                   end if
IqN"r"             if the character is "r"
FNzIqN"o"*lzN)IqN"r"+d*-lz2N
*-lz2N   return the character times length - 2
+d           padded on the left with " "


Try it here! This one uses a loop.

# Pyth, 30 bytes

(As string replace)

::z"o"+*lz"="b"re"++d*-lz2"~"b
:z"o"                           With the input, replace "o" with
*lz"="                    "=" times the length of the input
+      b                   and a newline added to the end
:             "re"               With the input, replace "re" with
*    "~"    "~" times
-lz2       the length of the input minus 2
+d            padded on the left with " "
+          b   and a newline added to the end


Try it here! This one uses string replacement.

I really like python (it's what I wrote my original test scripts in), so I thought I'd do a pyth entry for fun :)

• Isn't this 37 bytes? I thought Pyth uses default ASCII as its codepage just like Python, if I remember correctly. So even though your code is 33 characters, both █ and ░ are three bytes each. Or am I missing something here? Jan 4 '19 at 7:05
• Good call, I didn't realize that (I couldn't get pyth to work on tio.run, so I used the length counter on the herokuapp page). In the for loop I could just replace the character with N, even saving a few bytes! Jan 4 '19 at 14:38
• Thought something like that happened. :) I once had the same issue with a 05AB1E answer of mine that was using characters outside its code page. Unfortunately TIO displays chars and bytes the same for most golfing languages. For Java or Python TIO will correctly state 33 chars, 37 bytes, but not in golfing languages on TIO. But in your solutions just changing those characters indeed fixes the issue, so it's not that big of a deal here. Jan 4 '19 at 14:41
• @KevinCruijssen Wait, 05AB1E doesn't use an actual SBCS? Jan 6 '19 at 1:08
• If you're interested, it seems to work effortlessly on TIO for me. Jan 9 '19 at 16:07

# PHP, 9687 85 bytes

Thanks to @gwaugh -9 Bytes
Thanks to @manatwork -2 Bytes

# Powershell, 7169 66 bytes

-2 bytes thanks @Veskah

-3 bytes thanks @AdmBorkBork

$l=$args|% le*
switch($args|% t*y){'o'{'#'*$l}'r'{" "+'%'*($l-2)}}  Less golfed test script: $f = {

$l=$args|% length
switch($args|% t*y){ 'o'{'#'*$l}
'r'{" "+'%'*($l-2)} } } @( ,( 'oreo', '####', ' %%', '####' ) ,( 'o', '#' ) ,( 're', ' ' ) ,( 'rere', ' %%', ' %%' ) ,( 'oreoorererereoo', '###############', ' %%%%%%%%%%%%%', '###############', '###############', ' %%%%%%%%%%%%%', ' %%%%%%%%%%%%%', ' %%%%%%%%%%%%%', ' %%%%%%%%%%%%%', '###############', '###############' ) ) | % {$s,$expected =$_
$result = &$f $s "$result"-eq"$expected" #$result # uncomment this line to display a result
}


Output:

True
True
True
True
True

• Looks like you don't need parens around the $args 69 bytes Jan 4 '19 at 23:30 • The length of [string[]] is an [int[]]... The [int[]] is [int] if the array contains one element only. Great! Thanks! Jan 5 '19 at 8:55 • The OP updated the challenge so you don't need trailing spaces anymore. This means your r can be " "+'%'*($l-2) instead for -3 bytes. Jan 18 '19 at 20:19

# Java 11, 110 106 bytes

s->{int l=s.length();return s.replace("re"," "+"~".repeat(l-2+1/l)+"\n").replace("o","=".repeat(l)+"\n");}


-4 bytes thanks to @ceilingcat.

Uses = for the cookie and ~ for the filling.

Try it online.

Explanation:

s->{                       // Method with String as both parameter and return-type
int l=s.length();        //  Get the length of the input
return s                 //  Return the input
.replace("re",   //  After we've replaced all "re" with:
" "            //   A space
+"~".repeat(l-2+1/l)
//   Appended with length-2 amount of "~"
//   (or length-1 if the input-length was 1)
+"\n")         //   Appended with a newline
.replace("o",    //  And we've also replaced all "o" with:
"=".repeat(l)  //   Length amount of "="
+"\n");}       //   Appended with a newline


The above solution uses a replace. The following maps over the characters of the input instead:

# Java 11, 113 112 bytes

s->s.chars().forEach(c->{if(c>101)System.out.println((c>111?" ":"")+(""+(char)c).repeat(s.length()-2*(~c&1)));})


-1 byte thanks to @Neil.

Try it online.

Explanation:

s->                           // Method with String parameter and no return-type
s.chars().forEach(c->{      //  Loop over the characters as codepoint-integers
if(c>101)                 //   If it's not an 'e':
System.out.println(     //    Print with trailing newline:
(c>111?                //     If it's an 'r'
" "                  //      Start with a space
:                     //     Else (it's an 'o' instead)
"")                  //      Start with an empty string
+(""+(char)c).repeat(  //     And append the character itself
.repeat(            //     Repeated the following amount of times:
s.length()         //      The input-length
-2*(~c&1)));})     //      Minus 2 if it's an "r", or 0 if it's an "o"

• Can you use ~c&1?
– Neil
Jan 4 '19 at 11:34
• @Neil I indeed can, thanks. Jan 4 '19 at 11:57
• This is invalid: "The whitespace padding on each side of the filling is required" Jan 6 '19 at 15:15
• @NieDzejkob Fixed.. Always nice to have changing specs during the challenge, sigh.. Jan 7 '19 at 9:43
• @KevinCruijssen not anymore :P Jan 7 '19 at 23:32

# Brainfuck, 276268 206 bytes

Technically as the brainfuck only has 8 instructions, that means it needs only 3 bits per character instead of 8 (that also means we could encode brainfuck in base64 with exactly 2 instructions per character), but I'll play fair and say it's 268 bytes long.

It was a fun challenge, thanks!

Edit: now featuring the 3rd rule!

Edit: moving the line feed from the data pool to the display part of the code allowed me to get down to 268 bytes:

>>+<,[<++++++++++[>-----------<-]>-[>-<,>>+<<[-]>>>>[>]>++++[<++++++++>-]+>>++++++++++[<+++++++++++>-]<+>>++++[<++++++++>-]<[<]<<<]>[[-]>>>[>]>+++++++[<+++++>-]+>>+++++++[<+++++>-]>+++++++[<+++++>-]<[<]<<]+<,>>+<<]>>--[>>>+<<<-]>>[.>-[>>>>+<<<<->.<]>>.[-]++++++++++.>]


Here's a more readable version:

The data pool is made like so: [first character, placeholder value used to move the input character count, repeated character, last character]

>>+<,[//start of the loop
<++++++++++[>-----------<-]>-//"o"
[>-<,>>+<<[-]//if it's not a "o", skip one character and:

>>>>[>]//go to the data pool and search for the end
>++++[<++++++++>-]//put " " in memory
+>//put 1 in memory
>++++++++++[<+++++++++++>-]<+>//put a "o" in memory
>++++[<++++++++>-]<//put another " " in memory
[<]<<<//get back to the beginning of the data pool and get back to the program

]>[[-]//else (so if it's a "o"):

>>>[>]//go to the data pool and search for the end
>+++++++[<+++++>-]//put a "#" in memory
+>//put 1 in memory
>+++++++[<+++++>-]//put a "#" in memory
>+++++++[<+++++>-]<//put a "#" in memory
[<]<<//get back to the beginning of the data pool and get back to the program

]+<,>>+<<]//loop until the end of the input line and count the number of characters

>>//go to the number of characters variable
--//substract 2 to it because the first and last characters take one space each
[>>>+<<<-]//copy the value to the next place
>>[.>//start of the loop and display of the first character
-[>>>>+<<<<->.<]//display of the repeated character while copying the character count to the next line
>>.//display of the last character
[-]++++++++++.//display a line feed
>]//loop until the end of the data pool


It works on copy.sh/brainfuck with default settings (link)

Edit: now down to only 206 Bytes thanks to @RezNesX

>>+<,[<-[>++<-------]>-[,[-]>->+>>[>]>+>+>-[<-->-------]>++++[<<<<++++++++>>>++++++++>-]<[<]<<<]>[[-]>>>[>]->+>->->--[<<<<-->>-->-->+++++++]<[<]<<]+>+<<,]>>--[>>>+<<<-]>>[.>-[>>>>+<<<.<-]>>.[-]++++++++++.>]


The code is quite similar but a lot of optimisation has been done in the creation of the data pool, very interesting.

• Fun language, nice entry! :) Jul 22 '19 at 3:59
• Oops, it looks like it breaks the third rule! The output isn't as wide as the input :s Jul 22 '19 at 14:50
• ah sorry, I didn't read that one, thanks I'm gonna work on that Jul 22 '19 at 20:54
• 206 bytes Feb 9 at 10:41
• @RezNesX Awesome job! I'm adding this to the post Feb 11 at 16:51

# Charcoal, 19 bytes

Ｆθ≡ιo⟦⭆θ#⟧e«→Ｐ⁻Ｌθ²↙


Try it online! Link is to verbose version of code. Explanation:

Ｆθ


Loop through the characters of the input string.

≡ι


Switch on each character.

o⟦⭆θ#⟧


If it's an o then print the input string replaced with #s on its own line.

e«→Ｐ⁻Ｌθ²↙


If it's an e then move right, print a line of -s that's two less than the length of the input string, then move down and left.

# Bash, 87 bytes

Without sed:

f(){ printf %$1s|tr \$2;}
c=${1//o/f${#1} B
}

# Zsh, 67 bytes

a=$#1 o()<<<${(l/a//=/)}
r()<<<\ ${(l/a>1?a-2:0//+/)} eval${1///;}


Try it online!

Explanation:

• $1: input • #: length • a=: assign to global variable $a
• o(): define a function called o:
• ${(l/a//=/)}: left pad {nothing} with = signs to the width $a (i.e., print this many equals signs
• <<<: print
• r(): define a function called r:
• ${(l///+/)} left pad {nothing} with + signs, • a>1?a-2:0: to the width of $a - 2 if $a > 1 else 0 (because otherwise, if $a - 2 was negative, zsh would use its absolute value
• <<<\ : print with a space before
• \${1}: input
• ///;: replace all {empty string}s with ; (effectively intersperses; oreo -> ;o;r;e;o)
• eval: evaluate that as zsh code
• o and r call the functions defined above
• e is a non-existent command, so does nothing
• ; separates the commands
• cunning use of functions! Feb 18 at 14:28

# C# (.NET Core), 143 bytes

Without LINQ.

p=>{var q="";foreach(char c in p){if(c!='e'){for(var j=0;j<p.Length;j++)q+=(j<1|j>p.Length-2)&c>'q'?" ":c<'p'?"█":"░";q+="\n";}}return q;};


Try it online!

# Clojure, 137 bytes

(fn[f](let[w(count f)r #(apply str(repeat % %2))](clojure.string/join"\n"(replace{\o(r w \#)\e(str \ (r(- w 2)\-) \ )}(remove #{\r}f)))))


I'm not using the nice characters in the printout in the golfed version since those are expensive. Returns a string to be printed.

Try it online!

See below for explanation.

Pre-golfed:

; Backslashes indicate a character literal
(defn oreo [format-str]
(let [width (count format-str)

; A helper function since Clojure doesn't have built-in string multiplication
str-repeat #(apply str (repeat % %2))

; Define the layers
cookie (str-repeat width \█)
cream (str \ (str-repeat (- width 2) \░) \ )]

(->> format-str ; Take the input string,
(remove #{\r}) ; remove r for simplcity,
(replace {\o cookie, \e cream}) ; replace the remaining letters with the layers,
(clojure.string/join "\n")))) ; and join the layers together with newlines


# Dart, 120106 107 bytes

f(s)=>s.replaceAll('o',''.padRight(s.length,'#')+'\n').replaceAll('re',' '.padRight(s.length-1,'-')+' \n');
`

Try it online!

• +1 byte : Added trailing whitespace
• This is invalid: "The whitespace padding on each side of the filling is required" Jan 6 '19 at 15:15
• Oh, never mind then, I'll correct it soon. Thanks for the info, I missed it Jan 6 '19 at 22:14