#Java 10, (削除) 100 (削除ここまで) 106 bytes
Java 10, (削除) 100 (削除ここまで) 106 bytes
b->{var s="";int i=0,j;for(var c:b){if(c)for(s+="\n",j=i;j-->0;)s+=0;else++i;s+=1;}return s.substring(1);}
Takes an array of booleans and returns a String (0s are empty, 1s are filled). Try it online here.
Thanks to Olivier Grégoire for helping me golf it a bit more and alerting me to the fact that my output format was not up to the spec.
Ungolfed version:
b -> { // lambda taking an array of booleans as argument
var s = ""; // the output String
int i = 0, // the number of "empty" characters to output
j; // iterator variable for outputting the "empty" characters
for(var c : b) { // iterate over the boolean array (the binary digits)
if(c) // if it's a '1'
for(s += "\n", // output a newline
j = i; j-- > 0;) s += 0; // output the "empty" characters
else // if it's a '0'
++i; // move one to the right on the next line
s += 1; // output the "filled" character
}
return s.substring(1); // output the constructed String, minus the leading newline
}
#Java 10, (削除) 100 (削除ここまで) 106 bytes
b->{var s="";int i=0,j;for(var c:b){if(c)for(s+="\n",j=i;j-->0;)s+=0;else++i;s+=1;}return s.substring(1);}
Takes an array of booleans and returns a String (0s are empty, 1s are filled). Try it online here.
Thanks to Olivier Grégoire for helping me golf it a bit more and alerting me to the fact that my output format was not up to the spec.
Ungolfed version:
b -> { // lambda taking an array of booleans as argument
var s = ""; // the output String
int i = 0, // the number of "empty" characters to output
j; // iterator variable for outputting the "empty" characters
for(var c : b) { // iterate over the boolean array (the binary digits)
if(c) // if it's a '1'
for(s += "\n", // output a newline
j = i; j-- > 0;) s += 0; // output the "empty" characters
else // if it's a '0'
++i; // move one to the right on the next line
s += 1; // output the "filled" character
}
return s.substring(1); // output the constructed String, minus the leading newline
}
Java 10, (削除) 100 (削除ここまで) 106 bytes
b->{var s="";int i=0,j;for(var c:b){if(c)for(s+="\n",j=i;j-->0;)s+=0;else++i;s+=1;}return s.substring(1);}
Takes an array of booleans and returns a String (0s are empty, 1s are filled). Try it online here.
Thanks to Olivier Grégoire for helping me golf it a bit more and alerting me to the fact that my output format was not up to the spec.
Ungolfed version:
b -> { // lambda taking an array of booleans as argument
var s = ""; // the output String
int i = 0, // the number of "empty" characters to output
j; // iterator variable for outputting the "empty" characters
for(var c : b) { // iterate over the boolean array (the binary digits)
if(c) // if it's a '1'
for(s += "\n", // output a newline
j = i; j-- > 0;) s += 0; // output the "empty" characters
else // if it's a '0'
++i; // move one to the right on the next line
s += 1; // output the "filled" character
}
return s.substring(1); // output the constructed String, minus the leading newline
}
#Java 10, (削除) 100 (削除ここまで) 106 bytes
b->{var s="";int i=0,j;for(var c:b){if(c)for(s+="\n",j=i;j-->0;)s+=0;else++i;s+=1;}return s.substring(1);}
Takes an array of booleans and returns a String (0s are empty, 1s are filled). Try it online here.
Thanks to Olivier Grégoire for helping me golf it a bit more and alerting me to the fact that my output format was not up to the spec.
Ungolfed version:
b -> { // lambda taking an array of booleans as argument
var s = ""; // the output String
int i = 0, // the number of "empty" characters to output
j; // iterator variable for outputting the "empty" characters
for(var c : b) { // iterate over the boolean array (the binary digits)
if(c) // if it's a '1'
for(s += "\n", // output a newline
j=i;j = i; j-->0; > 0;) s+=0;s += 0; // output the "empty" characters
else // if it's a '0'
++i; // move one to the right on the next line
s+=1;s += 1; // output the "filled" character
}
return s.substring(1); // output the constructed String, minus the leading newline
}
#Java 10, (削除) 100 (削除ここまで) 106 bytes
b->{var s="";int i=0,j;for(var c:b){if(c)for(s+="\n",j=i;j-->0;)s+=0;else++i;s+=1;}return s.substring(1);}
Takes an array of booleans and returns a String (0s are empty, 1s are filled). Try it online here.
Thanks to Olivier Grégoire for helping me golf it a bit more and alerting me to the fact that my output format was not up to the spec.
Ungolfed version:
b -> { // lambda taking an array of booleans as argument
var s = ""; // the output String
int i = 0, // the number of "empty" characters to output
j; // iterator variable for outputting the "empty" characters
for(var c : b) { // iterate over the boolean array (the binary digits)
if(c) // if it's a '1'
for(s += "\n", // output a newline
j=i; j-->0;) s+=0; // output the "empty" characters
else // if it's a '0'
++i; // move one to the right on the next line
s+=1; // output the "filled" character
}
return s.substring(1); // output the constructed String, minus the leading newline
}
#Java 10, (削除) 100 (削除ここまで) 106 bytes
b->{var s="";int i=0,j;for(var c:b){if(c)for(s+="\n",j=i;j-->0;)s+=0;else++i;s+=1;}return s.substring(1);}
Takes an array of booleans and returns a String (0s are empty, 1s are filled). Try it online here.
Thanks to Olivier Grégoire for helping me golf it a bit more and alerting me to the fact that my output format was not up to the spec.
Ungolfed version:
b -> { // lambda taking an array of booleans as argument
var s = ""; // the output String
int i = 0, // the number of "empty" characters to output
j; // iterator variable for outputting the "empty" characters
for(var c : b) { // iterate over the boolean array (the binary digits)
if(c) // if it's a '1'
for(s += "\n", // output a newline
j = i; j-- > 0;) s += 0; // output the "empty" characters
else // if it's a '0'
++i; // move one to the right on the next line
s += 1; // output the "filled" character
}
return s.substring(1); // output the constructed String, minus the leading newline
}
#Java 10, 100(削除) 100 (削除ここまで) 106 bytes
b->{var s="";int i=0,j;for(var c:b){if(c){s+="\n";forfor(s+="\n",j=i;j-->0;)s+=0;s+=1;}else{i++;s+=1;s+=0;else++i;s+=1;}return s;s.substring(1);}
Takes an array of booleans and returns a String (0s are empty, 1s are filled). Try it online here here.
Thanks to Olivier Grégoire for helping me golf it a bit more and alerting me to the fact that my output format was not up to the spec.
Ungolfed version:
b -> { // lambda taking an array of booleans as argument
var s = ""; // the output String
int i = 0, // the number of "empty" characters to output
j; // iterator variable for outputting the "empty" characters
for(var c : b) { // iterate over the boolean array (the binary digits)
if(c) { // if it's a '1'
for(s += "\n";"\n", // output a newline
for(j = i;j=i; j-- > 0; >0;) s+=0; // output the "empty" characters
s += 0;
s+=1; // output the "filled" character
} else { // if it's a '0'
i++;++i; // move one to the right on the next line
s+=1; // output the "filled" character
}
return s;s.substring(1); // output the constructed String, minus the leading newline
}
#Java 10, 100 bytes
b->{var s="";int i=0,j;for(var c:b)if(c){s+="\n";for(j=i;j-->0;)s+=0;s+=1;}else{i++;s+=1;}return s;}
Takes an array of booleans and returns a String (0s are empty, 1s are filled). Try it online here.
Ungolfed version:
b -> { // lambda taking an array of booleans as argument
var s = ""; // the output String
int i = 0, // the number of "empty" characters to output
j; // iterator variable for outputting the "empty" characters
for(var c : b) // iterate over the boolean array (the binary digits)
if(c) { // if it's a '1'
s += "\n"; // output a newline
for(j = i; j-- > 0; ) // output the "empty" characters
s += 0;
s+=1; // output the "filled" character
} else { // if it's a '0'
i++; // move one to the right on the next line
s+=1; // output the "filled" character
}
return s; // output the constructed String
}
#Java 10, (削除) 100 (削除ここまで) 106 bytes
b->{var s="";int i=0,j;for(var c:b){if(c)for(s+="\n",j=i;j-->0;)s+=0;else++i;s+=1;}return s.substring(1);}
Takes an array of booleans and returns a String (0s are empty, 1s are filled). Try it online here.
Thanks to Olivier Grégoire for helping me golf it a bit more and alerting me to the fact that my output format was not up to the spec.
Ungolfed version:
b -> { // lambda taking an array of booleans as argument
var s = ""; // the output String
int i = 0, // the number of "empty" characters to output
j; // iterator variable for outputting the "empty" characters
for(var c : b) { // iterate over the boolean array (the binary digits)
if(c) // if it's a '1'
for(s += "\n", // output a newline
j=i; j-->0;) s+=0; // output the "empty" characters
else // if it's a '0'
++i; // move one to the right on the next line
s+=1; // output the "filled" character
}
return s.substring(1); // output the constructed String, minus the leading newline
}