Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,22 @@
|
|||
command sparklines listOfNums
|
||||
local utfbase=0x2581
|
||||
local tStats, utfp, tmin,tmax,trange
|
||||
put listOfNums into tStats
|
||||
replace ", " with space in tStats
|
||||
replace space with comma in tStats
|
||||
put min(tStats) into tmin
|
||||
put max(tStats) into tmax
|
||||
put tmax - tmin into trange
|
||||
put "Min:" && tmin && tab into plot
|
||||
put "Max:" && tmax && tab after plot
|
||||
put "Range:" && trange && tab after plot
|
||||
put "Mean" && average(tStats) && tab after plot
|
||||
put "Stdev:" && standardDeviation(tStats) && tab after plot
|
||||
put "Variance:" && variance(tStats) && return after plot
|
||||
|
||||
repeat for each item i in tStats
|
||||
put (round(i - tmin/trange * 7)) + utfbase into utfp
|
||||
put numToCodepoint(utfp) after plot
|
||||
end repeat
|
||||
put plot
|
||||
end sparklines
|
||||
18
Task/Sparkline-in-unicode/Nim/sparkline-in-unicode.nim
Normal file
18
Task/Sparkline-in-unicode/Nim/sparkline-in-unicode.nim
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import rdstdin, strutils, unicode
|
||||
|
||||
const bar = [9601, 9602, 9603, 9604, 9605, 9606, 9607, 9608]
|
||||
const barcount = float(bar.high)
|
||||
|
||||
while True:
|
||||
let
|
||||
line = readLineFromStdin "Numbers please separated by space/commas: "
|
||||
numbers = line.split({' ',','}).map(parseFloat)
|
||||
mn = min(numbers)
|
||||
mx = max(numbers)
|
||||
extent = mx - mn
|
||||
var sparkline = ""
|
||||
for n in numbers:
|
||||
let i = int((n-mn) / extent * barcount)
|
||||
sparkline.add($TRune(bar[i]))
|
||||
echo "min: ", mn.formatFloat(precision = 0), "; max: ", mx.formatFloat(precision = 0)
|
||||
echo sparkline
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
var bar = @('▁'..'█');
|
||||
loop {
|
||||
print 'Numbers, please, separated by space/commas: ';
|
||||
var numbers = read(String).trim.split(/[\s,]+/).map{.to_n};
|
||||
var (min, max) = numbers.minmax;
|
||||
say "min: %5f; max: %5f"%(min, max);
|
||||
var div = ((max - min) / bar.end);
|
||||
say (min == max ? bar.last*numbers.len : numbers.map{|num| bar[(num - min) / div]}.join);
|
||||
}
|
||||
9
Task/Sparkline-in-unicode/jq/sparkline-in-unicode.jq
Normal file
9
Task/Sparkline-in-unicode/jq/sparkline-in-unicode.jq
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
def sparkline:
|
||||
min as $min
|
||||
| ( (max - $min) / 7 ) as $div
|
||||
| map( 9601 + (. - $min) * $div )
|
||||
| implode ;
|
||||
|
||||
def string2array:
|
||||
def tidy: select( length > 0 );
|
||||
[split(" ") | .[] | split(",") | .[] | tidy | tonumber];
|
||||
Loading…
Add table
Add a link
Reference in a new issue