Published
Edited
Apr 19, 2021
1 fork
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
poem1 = [["we", "salt", "our", "sea", "warmer"],
["make", "senseless", "Pacific", "weather", "systems"],
["our", "systematic", "order", "into", "chaos"],
["life", "spoiling", "birth", "what", "theory"],
["random", "synapses", "children", "we", "intended"]];
Insert cell
poem2 = [["we", "are", "cheap", "kings"],
["land", "we", "rule", "our"],
["and", "sound", "commands", "color"],
["create", "myths", "we", "believe"]];
Insert cell
poem3 = [["changing", "mindset", "palace"],
["your", "sniffling", "allergies"],
["symptoms", "will", "kill"]];
Insert cell
poem4 = [["forget", "your", "homework", "once", "again"],
["how", "then", "so", "you", "remember"],
["to", "end", "lovely,", "forget", "no one"],
["be", "broken", "as", "you", "lost"],
["brave", "features", "all", "fail", "eventually"]];
Insert cell
Insert cell
Insert cell
function toPoem(text, poem) {
let output = "";
if (text.length < 1) {
output = toPoem("something", poem);
return output;
}
output = poem[0][0]
let binary = toBinary(text);
let row = 0; let col = 0;
let rowMax = poem.length; let colMax = poem[0].length;
for (var i = 0; i < binary.length; i++) {
if (binary[i] === "0") {
row++;
} else {
col++;
}
if (row > rowMax - 1 || col > colMax - 1) {
output += "<br>"
}
row = row % rowMax;
col = col % colMax;
output += " " + poem[row][col];
}
return output;
}
Insert cell
function toTitle(userInput) {
if (userInput === "") {
return "something";
}
return userInput;
}
Insert cell
function toBinary(text) {
let output = "";
let lowText = text.toLowerCase();
for (var i = 0; i < lowText.length; i++) {
output += text[i].charCodeAt(0).toString(2).substring(3,8);
// if (letterMap5.has(lowText[i])) {
// output += letterMap5.get(text.toLowerCase()[i]);
// }
}
return output;
}
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more