Skip to main content
deleted 35 characters in body
Source Link
nicael
  • 4.8k
  • 24
  • 43

#JavaScript, 128 125 123123 114 bytes

n=>{r='';for(i=0;i<n;i++)r+='/\\';r+='\n';for\\';for(j=0;j<2*n-1;j++){r+=j%2r+='\n'+(j%2?'':'\\';for'\\');for(i=n-j/2;i>0;i--)r+='/ ';r+='\n''}return r}

De-golf (also converted to ES5) + demo:

function c(n) {
    r = '';
    for (i = 0; i < n; i++) r += '/\\';
    r += '\n';
    for (j = 0; j < 2 * n - 1; j++) {
        r += '\n' + (j % 2 ? '' : '\\';'\\');
        for (i = n - j / 2; i > 0; i--) r += '/ ';
        r += '\n''
    }
    return r
}

alert(c(prompt()));

#JavaScript, 128 125 123 bytes

n=>{r='';for(i=0;i<n;i++)r+='/\\';r+='\n';for(j=0;j<2*n-1;j++){r+=j%2?'':'\\';for(i=n-j/2;i>0;i--)r+='/ ';r+='\n'}return r}

De-golf (also converted to ES5) + demo:

function c(n) {
    r = '';
    for (i = 0; i < n; i++) r += '/\\';
    r += '\n';
    for (j = 0; j < 2 * n - 1; j++) {
        r += j % 2 ? '' : '\\';
        for (i = n - j / 2; i > 0; i--) r += '/ ';
        r += '\n'
    }
    return r
}

alert(c(prompt()));

#JavaScript, 128 125 123 114 bytes

n=>{r='';for(i=0;i<n;i++)r+='/\\';for(j=0;j<2*n-1;j++){r+='\n'+(j%2?'':'\\');for(i=n-j/2;i>0;i--)r+='/ '}return r}

De-golf (also converted to ES5) + demo:

function c(n) {
    r = '';
    for (i = 0; i < n; i++) r += '/\\';
    for (j = 0; j < 2 * n - 1; j++) {
        r += '\n' + (j % 2 ? '' : '\\');
        for (i = n - j / 2; i > 0; i--) r += '/ '
    }
    return r
}

alert(c(prompt()));

added 5 characters in body
Source Link
nicael
  • 4.8k
  • 24
  • 43

#JavaScript, 128 125125 123 bytes

n=>{r='';for(i=0;i<n;i++)r+='/\\';r+='\n';for(j=0;j<2*n-1;j++){r+=j%2<1r+=j%2?'\\''':'';for'\\';for(i=n-j/2;i>0;i--)r+='/ ';r+='\n'}return r}

De-golf (also converted to ES5) + demo:

function c(n) {
    r = '';
    for (i = 0; i < n; i++) r += '/\\';
    r += '\n';
    for (j = 0; j < 2 * n - 1; j++) {
        r += j % 2 < 1 ? '\\''' : '';'\\';
        for (i = n - j / 2; i > 0; i--) r += '/ ';
        r += '\n'
    }
    return r
}

alert(c(prompt()));

#JavaScript, 128 125 bytes

n=>{r='';for(i=0;i<n;i++)r+='/\\';r+='\n';for(j=0;j<2*n-1;j++){r+=j%2<1?'\\':'';for(i=n-j/2;i>0;i--)r+='/ ';r+='\n'}return r}

De-golf (also converted to ES5) + demo:

function c(n) {
    r = '';
    for (i = 0; i < n; i++) r += '/\\';
    r += '\n';
    for (j = 0; j < 2 * n - 1; j++) {
        r += j % 2 < 1 ? '\\' : '';
        for (i = n - j / 2; i > 0; i--) r += '/ ';
        r += '\n'
    }
    return r
}

alert(c(prompt()));

#JavaScript, 128 125 123 bytes

n=>{r='';for(i=0;i<n;i++)r+='/\\';r+='\n';for(j=0;j<2*n-1;j++){r+=j%2?'':'\\';for(i=n-j/2;i>0;i--)r+='/ ';r+='\n'}return r}

De-golf (also converted to ES5) + demo:

function c(n) {
    r = '';
    for (i = 0; i < n; i++) r += '/\\';
    r += '\n';
    for (j = 0; j < 2 * n - 1; j++) {
        r += j % 2 ? '' : '\\';
        for (i = n - j / 2; i > 0; i--) r += '/ ';
        r += '\n'
    }
    return r
}

alert(c(prompt()));

added 4 characters in body
Source Link
nicael
  • 4.8k
  • 24
  • 43

#JavaScript, 128128 125 bytes

n=>{r='';for(i=0;i<n;i++)r+='/\\';r+='\n';for(j=0;j<nj=0;j<2*n-0.5;j+=0.51;j++){r+=j*2%2<1r+=j%2<1?'\\':'';for(i=n-j;i>0;ij/2;i>0;i--)r+='/ ';r+='\n'}return r}

De-golf (also converted to ES5) + demo:

function c(n) {
    r = '';
    for (i = 0; i < n; i++) r += '/\\';
    r += '\n';
    for (j = 0; j < n2 -* 0.5;n j- +=1; 0.5j++) {
        r += j * 2 % 2 < 1 ? '\\' : '';
        for (i = n - j;j / 2; i > 0; i--) r += '/ ';
        r += '\n'
    }
    return r;r
}

alert(c(prompt()));

#JavaScript, 128 bytes

n=>{r='';for(i=0;i<n;i++)r+='/\\';r+='\n';for(j=0;j<n-0.5;j+=0.5){r+=j*2%2<1?'\\':'';for(i=n-j;i>0;i--)r+='/ ';r+='\n'}return r}

De-golf (also converted to ES5) + demo:

function c(n) {
    r = '';
    for (i = 0; i < n; i++) r += '/\\';
    r += '\n';
    for (j = 0; j < n - 0.5; j += 0.5) {
        r += j * 2 % 2 < 1 ? '\\' : '';
        for (i = n - j; i > 0; i--) r += '/ ';
        r += '\n'
    }
    return r;
}

alert(c(prompt()));

#JavaScript, 128 125 bytes

n=>{r='';for(i=0;i<n;i++)r+='/\\';r+='\n';for(j=0;j<2*n-1;j++){r+=j%2<1?'\\':'';for(i=n-j/2;i>0;i--)r+='/ ';r+='\n'}return r}

De-golf (also converted to ES5) + demo:

function c(n) {
    r = '';
    for (i = 0; i < n; i++) r += '/\\';
    r += '\n';
    for (j = 0; j < 2 * n - 1; j++) {
        r += j % 2 < 1 ? '\\' : '';
        for (i = n - j / 2; i > 0; i--) r += '/ ';
        r += '\n'
    }
    return r
}

alert(c(prompt()));

Source Link
nicael
  • 4.8k
  • 24
  • 43
Loading