Warning: session_start(): open(/var/lib/php/sessions/sess_kra9fhp3533gl4a0qdp90lrf5k, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
scope renderLineCompedSingleLevels.
sS renderLineCompedSingleLevels(LineCompedSingle lc) {
int n = lcLength(lc);
// each byte is the character's "color"
// (0 for empty, 1 for color one, 2 for color two)
L rows = new AutoCreateList<>(() -> new byte[n]);
S text = uncompressLineCompedSingle(lc);
fill(lc, rows, 0, 0, lc.main, 1);
printVars(+rows);
ret lines(map(rows, row -> {
StringBuilder buf = new(n);
for i to n: {
char c = text.charAt(i);
buf.append(c);
if (i < n-1)
buf.append(row[i] != 0 && row[i+1] != 0 && row[i] != row[i+1]
? '|' : ' ');
}
ret str(buf);
}));
}
// returns new x
static int #fill(LineCompedSingle lc, L rows, int x, int y, L symbols, int color) {
printVars_str fill(+x, +y, +symbols, +color);
for (int idx : symbols) {
if (idx < l(lc.literals)) {
rows.get(y)[x++] = (byte) color;
} else {
int newX = fill(lc, rows, x, y+1, intPairToList(lc.getPair(idx)), color);
while (x < newX) rows.get(y)[x++] = (byte) color;
color = 3-color;
}
}
ret x;
}
end scope