Skip to main content
added 141 characters in body
Source Link
gggg
  • 2k
  • 11
  • 9

Julia 1.0, 5965 bytes

g(a,b,s=x->sort!x=sort(abs.(diff(push!(x,x[1]))),z=s)
g(a),b,z=!a./s(!b))=all(z.≈z[1])

Like GammaFunction's answer I'm abusing input inRevised to not abuse the "any input structure" to repeat one pointstatement, as people seemed down on that. Found extra golfing, so it's only 1 byte longer. The input is two vectors of complex numbers, with. ! is a helper function that appends the first point inelement to the end of each repeatedinput list and returns the result, then takes the difference ob subsequent elements, elementwise absolute value, and sorts. Then we calculate the ratios of the sorted lengths of the sides and check that they are all approximately equal. It costs the same number of bytes to compare square side lengths (replace abs with abs2 and by ==).

Try it online!Try it online!

Julia 1.0, 59 bytes

g(a,b,s=x->sort(abs.(diff(x))),z=s(a)./s(b))=all(z.≈z[1])

Like GammaFunction's answer I'm abusing input in "any structure" to repeat one point. The input is two vectors of complex numbers, with the first point in each repeated. Then we calculate the ratios of the sorted lengths of the sides and check that they are all approximately equal. It costs the same number of bytes to compare square side lengths (replace abs with abs2 and by ==).

Try it online!

Julia 1.0, 65 bytes

!x=sort(abs.(diff(push!(x,x[1]))))
g(a,b,z=!a./!b)=all(z.≈z[1])

Revised to not abuse the "any input structure" statement, as people seemed down on that. Found extra golfing, so it's only 1 byte longer. The input is two vectors of complex numbers. ! is a helper function that appends the first element to the end of each input list and returns the result, then takes the difference ob subsequent elements, elementwise absolute value, and sorts. Then calculate the ratios of the sorted lengths of the sides and check that they are all approximately equal. It costs the same number of bytes to compare square side lengths (replace abs with abs2 and by ==).

Try it online!

Source Link
gggg
  • 2k
  • 11
  • 9

Julia 1.0, 59 bytes

g(a,b,s=x->sort(abs.(diff(x))),z=s(a)./s(b))=all(z.≈z[1])

Like GammaFunction's answer I'm abusing input in "any structure" to repeat one point. The input is two vectors of complex numbers, with the first point in each repeated. Then we calculate the ratios of the sorted lengths of the sides and check that they are all approximately equal. It costs the same number of bytes to compare square side lengths (replace abs with abs2 and by ==).

Try it online!