3 replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
source | link

Scala, 224 181 bytes

EDIT: I had no idea you could do "string"*n to repeat it n times! Scala continues to blow my mind. Missing the if(t>0) instead of if(t==0) was a rookie mistake. Thanks for the tips, SumaSuma!


def?(x:Int,t:Int=5):Unit={var(p,o)=("--o--","")
o=s"____|${if(t>0)" "*5 else p}|____\n"
for(i<-0 to t)o=if(i!=0&&i==t)" "*x+p+o else "\n"+o
println(o)
if(t>0)?(x-(x-4).signum,t-1)}

Original remarks:

I figured a recursive solution would be fun to try. I'm relatively new to Scala, so I'm certain this is far from optimal.

Scala, 224 181 bytes

EDIT: I had no idea you could do "string"*n to repeat it n times! Scala continues to blow my mind. Missing the if(t>0) instead of if(t==0) was a rookie mistake. Thanks for the tips, Suma!


def?(x:Int,t:Int=5):Unit={var(p,o)=("--o--","")
o=s"____|${if(t>0)" "*5 else p}|____\n"
for(i<-0 to t)o=if(i!=0&&i==t)" "*x+p+o else "\n"+o
println(o)
if(t>0)?(x-(x-4).signum,t-1)}

Original remarks:

I figured a recursive solution would be fun to try. I'm relatively new to Scala, so I'm certain this is far from optimal.

Scala, 224 181 bytes

EDIT: I had no idea you could do "string"*n to repeat it n times! Scala continues to blow my mind. Missing the if(t>0) instead of if(t==0) was a rookie mistake. Thanks for the tips, Suma!


def?(x:Int,t:Int=5):Unit={var(p,o)=("--o--","")
o=s"____|${if(t>0)" "*5 else p}|____\n"
for(i<-0 to t)o=if(i!=0&&i==t)" "*x+p+o else "\n"+o
println(o)
if(t>0)?(x-(x-4).signum,t-1)}

Original remarks:

I figured a recursive solution would be fun to try. I'm relatively new to Scala, so I'm certain this is far from optimal.

2 updated the post with some changes suggested by Suma
source | link

Scala, 224224 181 bytes

EDIT: I had no idea you could do "string"*n to repeat it n times! Scala continues to blow my mind. Missing the if(t>0) instead of if(t==0) was a rookie mistake. Thanks for the tips, Suma!


def?(x:Int,t:Int=5):Unit={var(p,b,o,d)=("--o--","     ","","")
o=s"____|${if(t==0t>0)p" "*5 else bp}|____\n"
for(i<-1 to x)d+=" "
for(i<-0 to t)o=if(i!=0&&i==t)d+p+o" "*x+p+o else b+b+b+"\n"+o"\n"+o
println(o)
if(t!=0t>0)?(x-Integer.signum(x-4).signum,t-1)}

Original remarks:

I figured a recursive solution would be fun to try. I'm relatively new to Scala, so I'm certain this is far from optimal.

Scala, 224 bytes

def?(x:Int,t:Int=5):Unit={var(p,b,o,d)=("--o--","     ","","")
o=s"____|${if(t==0)p else b}|____\n"
for(i<-1 to x)d+=" "
for(i<-0 to t)o=if(i!=0&&i==t)d+p+o else b+b+b+"\n"+o
println(o)
if(t!=0)?(x-Integer.signum(x-4),t-1)}

I figured a recursive solution would be fun to try. I'm relatively new to Scala, so I'm certain this is far from optimal.

Scala, 224 181 bytes

EDIT: I had no idea you could do "string"*n to repeat it n times! Scala continues to blow my mind. Missing the if(t>0) instead of if(t==0) was a rookie mistake. Thanks for the tips, Suma!


def?(x:Int,t:Int=5):Unit={var(p,o)=("--o--","")
o=s"____|${if(t>0)" "*5 else p}|____\n"
for(i<-0 to t)o=if(i!=0&&i==t)" "*x+p+o else "\n"+o
println(o)
if(t>0)?(x-(x-4).signum,t-1)}

Original remarks:

I figured a recursive solution would be fun to try. I'm relatively new to Scala, so I'm certain this is far from optimal.

1
source | link

Scala, 224 bytes

def?(x:Int,t:Int=5):Unit={var(p,b,o,d)=("--o--","     ","","")
o=s"____|${if(t==0)p else b}|____\n"
for(i<-1 to x)d+=" "
for(i<-0 to t)o=if(i!=0&&i==t)d+p+o else b+b+b+"\n"+o
println(o)
if(t!=0)?(x-Integer.signum(x-4),t-1)}

I figured a recursive solution would be fun to try. I'm relatively new to Scala, so I'm certain this is far from optimal.