0
APL (Dyalog Unicode), 20 bytesSBCS Anonymous prefix lambda. {s=+/c←⍵?s←⍵*2:c⋄∇⍵} Try it online! {…} "dfn"; ⍵ is argument ⍵*2 square the argument s← assign to s (for square) ⍵? find n random indices from 1…s without replacement c← assign to c (for candidate) +/ sum them s= compa...