Public
Edited
Dec 7, 2022
Insert cell
Insert cell
Insert cell
ABC = ["A", "B", "C"]
Insert cell
XYZ = [..."XYZ"]

Insert cell
rpc= ABC.map((d,i)=> ({
Insert cell
RPC = ["Rock", "Paper", "Scissors"]
Insert cell
ai = d3.index(ABC.map((d, i)=> ({"value":XYZ[(i+1)%3], "beats":d, "text": RPC[(i+1)%3] + " beats " + RPC[i]}) ), d=> d.beats)
Insert cell
ai.get("A")
Insert cell
-1 % 3

Insert cell
scores=d3.index(d3.cross([0,1 ,2] ,[0, 1 ,2]).map((d, i)=> ({
"text": `${RPC[d[0]]} ${d[0]==d[1]?"ties":(d[1]+1)%3==d[0]?"beats":"loses to"} ${RPC[d[1]]}`,
l: ABC[d[0]],
r: XYZ[d[1]],
"key": `${ABC[d[0]]} ${XYZ[d[1]]}`,
"scoreR": (d[0]==d[1]? 3 :(d[0]+1)%3==d[1]? 6 : 0) + 1 + d[1],
"scoreL": (d[0]==d[1]?3:(d[1]+1)%3==d[0]?6:0) + 1 + d[0]})), d=> d.key)
Insert cell
result = d3.sum( input.split("\n"), d=> scores.get(d).scoreR)
Insert cell
Insert cell
partbResult=d3.sum(input.split("\n"), d=> { partBIndex.get(d[0]).get(d[2]).scoreR})

Insert cell
out = {var c = 0; input.split("\n").forEach(d=>{c += partBIndex.get(d[0]).get(d[2]).scoreR;}); return c;}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more