1
1
Fork 0
exercism/jq/difference-of-squares/difference-of-squares.jq
Christina Sørensen e90bc0845c
feat(jq): difference of squares
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
2024-12-18 15:19:16 +01:00

8 lines
245 B
Text

([range(1;.input.number+1)]) as $n
| if .property == "squareOfSum"
then pow(($n|add);2)
elif .property == "sumOfSquares"
then $n|map(pow(.; 2))|add
elif .property == "differenceOfSquares"
then pow(($n|add);2) - ($n|map(pow(.; 2))|add)
end