8 lines
504 B
JavaScript
8 lines
504 B
JavaScript
|
nextline = (line)=>(line.split("").map((char, i, arr)=>([arr[i-1], arr[i], arr[i+1]]).map((char)=>(char ? char : ".")).join("")).map((str)=>(["^^.", ".^^", "..^", "^.."].indexOf(str) != -1)).map((trap)=>(trap ? "^" : ".")).join(""));
|
||
|
|
||
|
var lines = [".^^^^^.^^^..^^^^^...^.^..^^^.^^....^.^...^^^...^^^^..^...^...^^.^.^.......^..^^...^.^.^^..^^^^^...^."];
|
||
|
while(lines.length < 40){
|
||
|
lines.push(nextline(lines[lines.length - 1]));
|
||
|
}
|
||
|
console.log(lines.map((line)=>(line.replace(/\^/g, ""))).join("").length);
|