Created
September 1, 2022 14:54
-
-
Save jexp/dfa6dfd4dd96cf6e8accd80fe537533e to your computer and use it in GitHub Desktop.
bar chart cypher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with [x in range(1,10) | rand()] as values | |
return values as result; | |
/* | |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |
| result | | |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |
| [0.659425004010523, 0.8694425986764492, 0.9257514428672218, 0.953247608626841, 0.19473427486287131, 0.41928993743169174, 0.9691737560680762, 0.564805684330218, 0.5061905379193724, 0.5653656414569036] | | |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |
*/ | |
unwind [x in range(1,10) | rand()] as v | |
return v, reduce(s="", y in range(0,19) | s+ | |
case when v > y/20.0 then '#' else ' ' end) as bar; | |
/* | |
+----------------------------------------------+ | |
| value | bar | | |
+----------------------------------------------+ | |
| 0.4556240123200369 | "########## " | | |
| 0.31488577832940867 | "####### " | | |
| 0.89626141986851 | "################## " | | |
| 0.45881776861132495 | "########## " | | |
| 0.695017128058231 | "############## " | | |
| 0.24169506341186697 | "##### " | | |
| 0.4807423723371933 | "########## " | | |
| 0.819440068907669 | "################# " | | |
| 0.23682585067593875 | "##### " | | |
| 0.5383774837238443 | "########### " | | |
+----------------------------------------------+ | |
*/ | |
unwind [x in range(1,10) | rand()] as v | |
with collect([y in range(0,19) | v > y/20.0]) as data | |
unwind range(19,0,-1) as y | |
return reduce(s="", idx in range(0,size(data)-1) | s + | |
case when data[idx][y] then '#' else ' ' end) as bar | |
; | |
/* | |
+--------------+ | |
| bar | | |
+--------------+ | |
| " " | | |
| "# # " | | |
| "## # " | | |
| "## # " | | |
| "#### " | | |
| "#### " | | |
| "#### " | | |
| "#### " | | |
| "#### #" | | |
| "#### #" | | |
| "#### #" | | |
| "#### #" | | |
| "##### ##" | | |
| "##### # ##" | | |
| "##### # ##" | | |
| "####### ##" | | |
| "####### ##" | | |
| "##########" | | |
| "##########" | | |
| "##########" | | |
+--------------+ | |
*/ | |
unwind [x in range(1,10) | rand()] as v | |
with collect([y in range(19,0,-1) | case when v > y/20.0 then '#' else ' ' end]+ | |
split(toString(v),"")[0..5]) as data | |
unwind range(0,24) as y | |
return reduce(s="", idx in range(0,size(data)-1) | s+data[idx][y]) as bar | |
; | |
/* | |
+--------------+ | |
| bar | | |
+--------------+ | |
| " " | | |
| " " | | |
| " # " | | |
| " # " | | |
| " # " | | |
| " # " | | |
| " # " | | |
| " # " | | |
| " # # " | | |
| " # # # " | | |
| " # # # " | | |
| " # # # " | | |
| "## # # " | | |
| "## # ### " | | |
| "## # ### " | | |
| "##### ### " | | |
| "######### " | | |
| "######### " | | |
| "##########" | | |
| "##########" | | |
| "0000000000" | | |
| ".........." | | |
| "3523218350" | | |
| "7231395376" | | |
| "5758082741" | | |
+--------------+ | |
*/ | |
unwind range(1,10) as _ with rand() as v | |
return v, apoc.text.rpad(apoc.text.repeat('#',toInteger(v*20)),20) as bar; | |
/* | |
+-----------------------------------------------+ | |
| v | bar | | |
+-----------------------------------------------+ | |
| 0.6533018814316877 | "############# " | | |
| 0.01609387557705766 | " " | | |
| 0.08625393508659407 | "# " | | |
| 0.3864163365190795 | "####### " | | |
| 0.8794593095022677 | "################# " | | |
| 0.7253620314094377 | "############## " | | |
| 0.8648569548079992 | "################# " | | |
| 0.407484868897514 | "######## " | | |
| 0.9614132753895293 | "################### " | | |
| 0.045589687668017964 | " " | | |
+-----------------------------------------------+ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment