You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<div id="container"></div> |
|
|
<script> |
|
|
const G = 27; |
|
|
const W = 0; // 0..26 uses 3 ternary digits |
|
|
const container = document.getElementById("container"); |
|
|
|
|
|
let totalOnes = 0; // sum over rows i ≡ 1 (mod 3) |
|
|
|
|
|
for (let i = 0; i < G; i++) { |
|
|
const t = i.toString(3).padStart(W, "0"); // fixed width ternary |
|
|
const ones = (t.match(/1/g) || []).length; // # of 1 digits |
|
|
const bar1 = "🟢".repeat(ones); |
|
|
|
|
|
if (i % 3 === 1) totalOnes += ones; // rows 1,4,7,...,25 |
|
|
|
|
|
const div = document.createElement("div"); |
|
|
div.style.cssText="WHITE-SPACE:NOWRAP;LINE-HEIGHT:1;FONT-SIZE:VAR(--I);COLOR:RGBA(0,244,124,1.148125);TEXT-ALIGN:RIGHT"; |
|
|
div.textContent = t + "" + bar1; |
|
|
container.appendChild(div); |
|
|
} |
|
|
|
|
|
// show the 1s-sum for G=27, which is 15 |
|
|
const sumDiv = document.createElement("div"); |
|
|
sumDiv.style.cssText="WHITE-SPACE:NOWRAP;LINE-HEIGHT:1;FONT-SIZE:VAR(--I);COLOR:RGBA(0,244,124,1.148125);TEXT-ALIGN:RIGHT"; |
|
|
sumDiv.textContent = totalOnes + "🟢".repeat(totalOnes) + "⊚" ; |
|
|
container.appendChild(sumDiv); |
|
|
</script>
|
|
|
|