Published
Edited
May 19, 2021
Insert cell
md`# ShoSha`
Insert cell
randomHex = (count) => {
let hex = '';
for (let i = 0; i < count; i++){
const random = Math.random();
const bit = (random * 16) | 0;
hex += (bit).toString(16);
};
return hex;
};
Insert cell
function join(w, z){
let hex = '';
for (let i = 0; i < w.length; i++){
let t1 = parseInt(w[i],16);
let t2 = parseInt(z[i],16);
if (t1 == "f" && t2 == "1") {
hex += "0"
continue
}
if (t1 < t2) {
hex += ((t2-1)/2).toString(16)
} else {
hex += (t1+t2).toString(16)
}
};
return hex;
}
Insert cell
function split(w){
let hex1 = '';
let hex2 = '';
for (let i = 0; i < w.length; i++){
let t = parseInt(w[i],16);
let y = 0;
if (t === 0) {
hex1 += "f";
hex2 += "1";
continue;
}
if (t < 8) {
//if (t%2 == 0) y = 1;
hex1 += (t*2 - 1).toString(16);
hex2 += (t*2 + 1).toString(16);
} else {
if (t%2 == 0) {
hex1 += (t/2 +1).toString(16);
hex2 += (t/2 -1).toString(16);
} else {
hex1 += ((t + 1)/2).toString(16);
hex2 += ((t - 1)/2).toString(16);
}
}
};
return [hex1 , hex2];
}
Insert cell
function ssplit(slot, arr){
console.log(slot, arr)
let y = split(slot);
if (arr.length === 0) return y;
y.push(y[arr[0]], arr.slice(1))
return y;
}
Insert cell
v =split(x)
Insert cell
split("93579bdf3445566793579bdf3445566793579bdf3445566793579bdf34455667")
Insert cell
split("559d567857799bbd559d567857799bbd559d567857799bbd559d567857799bbd")
Insert cell
join(v[0],v[1])
Insert cell
x3
= "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
Insert cell
x = randomHex(64)
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