| Bytes | Lang | Time | Link |
|---|---|---|---|
| 103 | Python 2 | 241218T225534Z | squarero |
| 099 | Perl 5 pa | 241218T232325Z | Xcali |
| 057 | Japt | 160206T175801Z | ETHprodu |
| 069 | Retina | 160207T122004Z | randomra |
| 134 | PHP | 160206T222129Z | Paper |
| 5367 | 𝔼𝕊𝕄𝕚𝕟 | 160206T230217Z | Mama Fun |
| 055 | Pyth | 160206T194012Z | PurkkaKo |
| 102 | C | 160206T191958Z | yyny |
| 101 | Haskell | 160206T191830Z | yyny |
| 080 | JavaScript ES6 | 160206T181550Z | ETHprodu |
Python 2, 103 bytes
-1 byte by moving to Python 2.
lambda x,s='|__|__|',t=' ____':x*' 'and(x>1and['_'*7,t,s,' __|__|'][x%2::2]+~-x/2*[s]or[t,' |__|'])
Python 3.8 (pre-release), 105 bytes
-2 bytes by using f-strings.
lambda x:((a:=-~x//2)>0)*[f"{(7-x%2*3)*'_':>7}",*zip(x%2*' '+x//2*'|',*[a*i for i in'_ '[x<2]*2+'|__|'])]
Perl 5 -pa, 99 bytes
$\=$\."|__|__|
",$F[0]-=2while"@F">1;$_=$_&&(@F">0?" ____
".($_>1?'__':" ")."|__|
":"_______
")
Japt, 60 57 bytes
U%2?[S³'_²²RSU¥1?S²:'_²"|__|"]¬:U?'_p7 :P +"
|__|__|"pU/2
Just a basic answer. Can probably be improved. Test it online!
Retina, 69 bytes
r`(1?)1
$1__|__|¶
^__(?=\D{5}$)
^.
$0____¶ $0
^\D
^1
___
?1
|
Takes input in unary.
PHP, 134 chars
<?$i=$argv[1];if($i>0){echo($i%2===0?"_______\n|__":" ____\n".($i>1?"___":" "))."|__|\n";echo str_repeat("|__|__|\n",($i-1)/2);}?>
Notes:
- PHP was not built for code golfing
- I sure had FUN making this snippet
- It throws an error if argv is undefined
- Any help to short it is appreciated.
𝔼𝕊𝕄𝕚𝕟, 53 chars / 67 bytes
ï%2?` ⟮__⟯Ⅰ
⦃ï<2?⍞ :⍞Ⅰ⦄|Ⅰ|`:ï?⍘_ď7:⬯⦄
|Ⅰ|Ⅰ|`ď ï/2
This is quite similar to the Javascript ES6 answer, even though I found it independently. Explanation to come when I finish golfing.
Pyth, 55 bytes
K"|__|"IQ>7<*3%Q2r"3 7_"9?tQjb+XW%Q2J+KtKZd*/tQ2]J+*3dK
This is really quick and dirty, written on my phone. Will get to more golfing later.
C, 104 102 bytes
f(x){x?x%2?printf(" ____\n%3s|__|\n",x<2?"":"__"):puts("_______"):0;for(x/=2;x>0;x--)puts("|__|__|");}
Maybe I can use some printf trickery to improve this...
Apparently I can
Haskell, 101 bytes
Haskell has never been great for code golfing...
b="\n|__|__|"
h=" ____\n "
f 1=h++" |__|"
f 2="_______"++b
f 3=h++"__|__|"++b
f n=f(n-2)++b
f _=""
JavaScript ES6, 80 bytes
x=>(x%2?` ____
${x<2?" ":"__"}|__|`:x?"_______":"")+`
|__|__|`.repeat(x/2)
Uses the same technique as my Japt answer, and is surprisingly not much longer...