function (countconsumed) {
countlet remaining = 91 - count;consumed;
function inner (count, width = 13) {
if (count <= 0) return false;
function repeat (count, string = ' ') {
return string.repeat(count);
}
const pattern = [
' |=| ',
' | | ',
' | | ',
' / \\ ',
'. .',
'|-----|',
'| |',
'|-----|',
'|_____|' ];
let clamped = Math.min(count, width);
let alignment = '\n' + repeat((13 - width) * 4);
let empty = alignment + repeat((width - clamped) * 8 + 2);
let shelf = alignment + repeat((width * 8) + 5, '#');
let bottles = pattern.map(row => empty + repeat(clamped, ' ' + row));
return inner(count - width, width - 1) + bottles.join('') + shelf;
}
return (countremaining) ? inner(countremaining).slice(6) : ':(';
}
function (count) {
count = 91 - count;
function inner (count, width = 13) {
if (count <= 0) return false;
function repeat (count, string = ' ') {
return string.repeat(count);
}
const pattern = [
' |=| ',
' | | ',
' | | ',
' / \\ ',
'. .',
'|-----|',
'| |',
'|-----|',
'|_____|' ];
let clamped = Math.min(count, width);
let alignment = '\n' + repeat((13 - width) * 4);
let empty = alignment + repeat((width - clamped) * 8 + 2);
let shelf = alignment + repeat((width * 8) + 5, '#');
let bottles = pattern.map(row => empty + repeat(clamped, ' ' + row));
return inner(count - width, width - 1) + bottles.join('') + shelf;
}
return (count) ? inner(count).slice(6) : ':(';
}
function (consumed) {
let remaining = 91 - consumed;
function inner (count, width = 13) {
if (count <= 0) return false;
function repeat (count, string = ' ') {
return string.repeat(count);
}
const pattern = [
' |=| ',
' | | ',
' | | ',
' / \\ ',
'. .',
'|-----|',
'| |',
'|-----|',
'|_____|' ];
let clamped = Math.min(count, width);
let alignment = '\n' + repeat((13 - width) * 4);
let empty = alignment + repeat((width - clamped) * 8 + 2);
let shelf = alignment + repeat((width * 8) + 5, '#');
let bottles = pattern.map(row => empty + repeat(clamped, ' ' + row));
return inner(count - width, width - 1) + bottles.join('') + shelf;
}
return (remaining) ? inner(remaining).slice(6) : ':(';
}
##JavaScript (ES6), 251251 256 bytes
Edit: Saved 2 bytes thanks to @dzaima.
Edit: Added 7 bytes to fix issue with parameter. :(
c=>(f=(c,w=13)=>c>0&&f(c-w,w-1)+(c=c<w?c:w,r=(n,s=' ')=>s.repeat(n),a='\n'+r(52-w*4),' |=| ,0 | | ,0 | | ,0 / \\ ,0. .,|0|-----|,||0| |,||0|-----|,|_____|'|0|_____|'.split(','0).map(x=>a+r((w-c)*8+2)+r(c,' '+x)).join('')+a+r(w*8+5,'#')),(c=91-c)?f(c).slice(6):':(')
function (count) {
count = 91 - count;
function inner (count, width = 13) {
if (count <= 0) return false;
function repeat (count, string = ' ') {
return string.repeat(count);
}
const pattern = [
' |=| ',
' | | ',
' | | ',
' / \\ ',
'. .',
'|-----|',
'| |',
'|-----|',
'|_____|' ];
let clamped = Math.min(count, width);
let alignment = '\n' + repeat((13 - width) * 4);
let empty = alignment + repeat((width - clamped) * 8 + 2);
let shelf = alignment + repeat((width * 8) + 5, '#');
let bottles = pattern.map(row => empty + repeat(clamped, ' ' + row));
return inner(count - width, width - 1) + bottles.join('') + shelf;
}
return (count) ? inner(count).slice(6) : ':(';
}
const golfed =
c=>(f=(c,w=13)=>c>0&&f(c-w,w-1)+(c=c<w?c:w,r=(n,s=' ')=>s.repeat(n),a='\n'+r(52-w*4),' |=| ,0 | | ,0 | | ,0 / \\ ,0. .,|0|-----|,||0| |,||0|-----|,|_____|'|0|_____|'.split(','0).map(x=>a+r((w-c)*8+2)+r(c,' '+x)).join('')+a+r(w*8+5,'#')),(c=91-c)?f(c).slice(6):':(')
console.log(golfed(091)); // :(
console.log(golfed(1972));
// |=| |=| |=| |=| |=| |=|
// | | | | | | | | | | | |
// | | | | | | | | | | | |
// / \ / \ / \ / \ / \ / \
// . . . . . . . . . . . .
// |-----| |-----| |-----| |-----| |-----| |-----|
// | | | | | | | | | | | |
// |-----| |-----| |-----| |-----| |-----| |-----|
// |_____| |_____| |_____| |_____| |_____| |_____|
// #####################################################################################################
// |=| |=| |=| |=| |=| |=| |=| |=| |=| |=| |=| |=| |=|
// | | | | | | | | | | | | | | | | | | | | | | | | | |
// | | | | | | | | | | | | | | | | | | | | | | | | | |
// / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
// . . . . . . . . . . . . . . . . . . . . . . . . . .
// |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----|
// | | | | | | | | | | | | | | | | | | | | | | | | | |
// |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----|
// |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____|
// #############################################################################################################
##JavaScript (ES6), 251 bytes
c=>(f=(c,w=13)=>c>0&&f(c-w,w-1)+(c=c<w?c:w,r=(n,s=' ')=>s.repeat(n),a='\n'+r(52-w*4),' |=| , | | , | | , / \\ ,. .,|-----|,| |,|-----|,|_____|'.split(',').map(x=>a+r((w-c)*8+2)+r(c,' '+x)).join('')+a+r(w*8+5,'#')),c?f(c).slice(6):':(')
function (count) {
function inner (count, width = 13) {
if (count <= 0) return false;
function repeat (count, string = ' ') {
return string.repeat(count);
}
const pattern = [
' |=| ',
' | | ',
' | | ',
' / \\ ',
'. .',
'|-----|',
'| |',
'|-----|',
'|_____|' ];
let clamped = Math.min(count, width);
let alignment = '\n' + repeat((13 - width) * 4);
let empty = alignment + repeat((width - clamped) * 8 + 2);
let shelf = alignment + repeat((width * 8) + 5, '#');
let bottles = pattern.map(row => empty + repeat(clamped, ' ' + row));
return inner(count - width, width - 1) + bottles.join('') + shelf;
}
return (count) ? inner(count).slice(6) : ':(';
}
const golfed =
c=>(f=(c,w=13)=>c>0&&f(c-w,w-1)+(c=c<w?c:w,r=(n,s=' ')=>s.repeat(n),a='\n'+r(52-w*4),' |=| , | | , | | , / \\ ,. .,|-----|,| |,|-----|,|_____|'.split(',').map(x=>a+r((w-c)*8+2)+r(c,' '+x)).join('')+a+r(w*8+5,'#')),c?f(c).slice(6):':(')
console.log(golfed(0)); // :(
console.log(golfed(19));
// |=| |=| |=| |=| |=| |=|
// | | | | | | | | | | | |
// | | | | | | | | | | | |
// / \ / \ / \ / \ / \ / \
// . . . . . . . . . . . .
// |-----| |-----| |-----| |-----| |-----| |-----|
// | | | | | | | | | | | |
// |-----| |-----| |-----| |-----| |-----| |-----|
// |_____| |_____| |_____| |_____| |_____| |_____|
// #####################################################################################################
// |=| |=| |=| |=| |=| |=| |=| |=| |=| |=| |=| |=| |=|
// | | | | | | | | | | | | | | | | | | | | | | | | | |
// | | | | | | | | | | | | | | | | | | | | | | | | | |
// / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
// . . . . . . . . . . . . . . . . . . . . . . . . . .
// |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----|
// | | | | | | | | | | | | | | | | | | | | | | | | | |
// |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----|
// |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____|
// #############################################################################################################
##JavaScript (ES6), 251 256 bytes
Edit: Saved 2 bytes thanks to @dzaima.
Edit: Added 7 bytes to fix issue with parameter. :(
c=>(f=(c,w=13)=>c>0&&f(c-w,w-1)+(c=c<w?c:w,r=(n,s=' ')=>s.repeat(n),a='\n'+r(52-w*4),' |=| 0 | | 0 | | 0 / \\ 0. .0|-----|0| |0|-----|0|_____|'.split(0).map(x=>a+r((w-c)*8+2)+r(c,' '+x)).join('')+a+r(w*8+5,'#')),(c=91-c)?f(c).slice(6):':(')
function (count) {
count = 91 - count;
function inner (count, width = 13) {
if (count <= 0) return false;
function repeat (count, string = ' ') {
return string.repeat(count);
}
const pattern = [
' |=| ',
' | | ',
' | | ',
' / \\ ',
'. .',
'|-----|',
'| |',
'|-----|',
'|_____|' ];
let clamped = Math.min(count, width);
let alignment = '\n' + repeat((13 - width) * 4);
let empty = alignment + repeat((width - clamped) * 8 + 2);
let shelf = alignment + repeat((width * 8) + 5, '#');
let bottles = pattern.map(row => empty + repeat(clamped, ' ' + row));
return inner(count - width, width - 1) + bottles.join('') + shelf;
}
return (count) ? inner(count).slice(6) : ':(';
}
const golfed =
c=>(f=(c,w=13)=>c>0&&f(c-w,w-1)+(c=c<w?c:w,r=(n,s=' ')=>s.repeat(n),a='\n'+r(52-w*4),' |=| 0 | | 0 | | 0 / \\ 0. .0|-----|0| |0|-----|0|_____|'.split(0).map(x=>a+r((w-c)*8+2)+r(c,' '+x)).join('')+a+r(w*8+5,'#')),(c=91-c)?f(c).slice(6):':(')
console.log(golfed(91)); // :(
console.log(golfed(72));
// |=| |=| |=| |=| |=| |=|
// | | | | | | | | | | | |
// | | | | | | | | | | | |
// / \ / \ / \ / \ / \ / \
// . . . . . . . . . . . .
// |-----| |-----| |-----| |-----| |-----| |-----|
// | | | | | | | | | | | |
// |-----| |-----| |-----| |-----| |-----| |-----|
// |_____| |_____| |_____| |_____| |_____| |_____|
// #####################################################################################################
// |=| |=| |=| |=| |=| |=| |=| |=| |=| |=| |=| |=| |=|
// | | | | | | | | | | | | | | | | | | | | | | | | | |
// | | | | | | | | | | | | | | | | | | | | | | | | | |
// / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
// . . . . . . . . . . . . . . . . . . . . . . . . . .
// |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----|
// | | | | | | | | | | | | | | | | | | | | | | | | | |
// |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----|
// |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____|
// #############################################################################################################
##JavaScript (ES6), 251 bytes
c=>(f=(c,w=13)=>c>0&&f(c-w,w-1)+(c=c<w?c:w,r=(n,s=' ')=>s.repeat(n),a='\n'+r(52-w*4),' |=| , | | , | | , / \\ ,. .,|-----|,| |,|-----|,|_____|'.split(',').map(x=>a+r((w-c)*8+2)+r(c,' '+x)).join('')+a+r(w*8+5,'#')),c?f(c).slice(6):':(')
Here's the (mostly) ungolfed version:
function (count) {
function inner (count, width = 13) {
if (count <= 0) return false;
function repeat (count, string = ' ') {
return string.repeat(count);
}
const pattern = [
' |=| ',
' | | ',
' | | ',
' / \\ ',
'. .',
'|-----|',
'| |',
'|-----|',
'|_____|' ];
let clamped = Math.min(count, width);
let alignment = '\n' + repeat((13 - width) * 4);
let empty = alignment + repeat((width - clamped) * 8 + 2);
let shelf = alignment + repeat((width * 8) + 5, '#');
let bottles = pattern.map(row => empty + repeat(clamped, ' ' + row));
return inner(count - width, width - 1) + bottles.join('') + shelf;
}
return (count) ? inner(count).slice(6) : ':(';
}
###Test code
const golfed =
c=>(f=(c,w=13)=>c>0&&f(c-w,w-1)+(c=c<w?c:w,r=(n,s=' ')=>s.repeat(n),a='\n'+r(52-w*4),' |=| , | | , | | , / \\ ,. .,|-----|,| |,|-----|,|_____|'.split(',').map(x=>a+r((w-c)*8+2)+r(c,' '+x)).join('')+a+r(w*8+5,'#')),c?f(c).slice(6):':(')
console.log(golfed(0)); // :(
console.log(golfed(19));
// |=| |=| |=| |=| |=| |=|
// | | | | | | | | | | | |
// | | | | | | | | | | | |
// / \ / \ / \ / \ / \ / \
// . . . . . . . . . . . .
// |-----| |-----| |-----| |-----| |-----| |-----|
// | | | | | | | | | | | |
// |-----| |-----| |-----| |-----| |-----| |-----|
// |_____| |_____| |_____| |_____| |_____| |_____|
// #####################################################################################################
// |=| |=| |=| |=| |=| |=| |=| |=| |=| |=| |=| |=| |=|
// | | | | | | | | | | | | | | | | | | | | | | | | | |
// | | | | | | | | | | | | | | | | | | | | | | | | | |
// / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
// . . . . . . . . . . . . . . . . . . . . . . . . . .
// |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----|
// | | | | | | | | | | | | | | | | | | | | | | | | | |
// |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----| |-----|
// |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____| |_____|
// #############################################################################################################