Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

deleted 35 characters in body
Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 37
  • 92

Jelly, (削除) 25 (削除ここまで) (削除) 24 (削除ここまで) (削除) 22 (削除ここまで) (削除) 21 (削除ここまで) 20(削除) 20 (削除ここまで) 18 bytes

ZμṂrṀ)Œpμ3_2ドル§1⁄2ṀĊ«/r»/Œpμ3_2§1⁄2ṀĊ,)Ṃ

Try it online! Thanks to @Dennis for saving 2 bytes.

I'm sure there was a distance builtin in Jelly, but can't seem to find it... :</s> Turns out 2§1⁄2 is as short as ÆḊ€.Try it online!

Explanation

«/r»/Œpμ3_2§1⁄2ṀĊ,)Ṃ Main link. Arg: points
 e.g. [[1,4],[3,2],[3,1]]
«/ Find minimums by coordinate
 e.g. [1,1]
 »/ Find maximums by coordinate
 e.g. [3,4]
 r Inclusive ranges by coordinate
 e.g. [[1,2,3],[1,2,3,4]]
 Œp Cartesian product of the x and y ranges
 e.g. [[1,1],[1,2],[1,3],[1,4],...,[3,4]]
 μ Chain, arg: center
 e.g. [1,3]
 3 Get the original points
 e.g. [[1,4],[3,2],[3,1]]
 _ Subtract the center from each
 e.g. [[0,1],[2,-1],[2,-2]]
 2 Square each number
 e.g. [[0,1],[4,1],[4,4]]
 § Sum each sublist
 e.g. [1,5,8]
 1⁄2 Square root of each number
 e.g. [1,2.24,2.83]
 Ṁ Find the maximum
 e.g. 2.83
 Ċ Round up
 e.g. 3
 , Pair with the center point
 e.g. [3,[1,3]]
 ) Do the above for all points
 e.g. [[3,[1,1]],[3,[1,2]],[3,[1,3]],...,[3,[3,4]]]
 Ṃ Find the lexicographically smallest pair
 e.g. [3,[1,1]]

Jelly, (削除) 25 (削除ここまで) (削除) 24 (削除ここまで) (削除) 22 (削除ここまで) (削除) 21 (削除ここまで) 20 bytes

ZμṂrṀ)Œpμ3_2ドル§1⁄2ṀĊ,)Ṃ

Try it online!

I'm sure there was a distance builtin in Jelly, but can't seem to find it... :</s> Turns out 2§1⁄2 is as short as ÆḊ€.

Jelly, (削除) 25 (削除ここまで) (削除) 24 (削除ここまで) (削除) 22 (削除ここまで) (削除) 21 (削除ここまで) (削除) 20 (削除ここまで) 18 bytes

«/r»/Œpμ3_2§1⁄2ṀĊ,)Ṃ

Thanks to @Dennis for saving 2 bytes.

Try it online!

Explanation

«/r»/Œpμ3_2§1⁄2ṀĊ,)Ṃ Main link. Arg: points
 e.g. [[1,4],[3,2],[3,1]]
«/ Find minimums by coordinate
 e.g. [1,1]
 »/ Find maximums by coordinate
 e.g. [3,4]
 r Inclusive ranges by coordinate
 e.g. [[1,2,3],[1,2,3,4]]
 Œp Cartesian product of the x and y ranges
 e.g. [[1,1],[1,2],[1,3],[1,4],...,[3,4]]
 μ Chain, arg: center
 e.g. [1,3]
 3 Get the original points
 e.g. [[1,4],[3,2],[3,1]]
 _ Subtract the center from each
 e.g. [[0,1],[2,-1],[2,-2]]
 2 Square each number
 e.g. [[0,1],[4,1],[4,4]]
 § Sum each sublist
 e.g. [1,5,8]
 1⁄2 Square root of each number
 e.g. [1,2.24,2.83]
 Ṁ Find the maximum
 e.g. 2.83
 Ċ Round up
 e.g. 3
 , Pair with the center point
 e.g. [3,[1,3]]
 ) Do the above for all points
 e.g. [[3,[1,1]],[3,[1,2]],[3,[1,3]],...,[3,[3,4]]]
 Ṃ Find the lexicographically smallest pair
 e.g. [3,[1,1]]
deleted 35 characters in body
Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 37
  • 92

Jelly, (削除) 25 (削除ここまで) (削除) 24 (削除ここまで) (削除) 22 (削除ここまで) (削除) 21 (削除ここまで) 20 bytes

ZμṂrṀ)Œpμ3_2ドル§1⁄2ṀĊ,)Ṃ

Thanks to @EriktheOutgolfer for letting me know about ), saving 1 byte.

Try it online!

I'm sure there was a distance builtin in Jelly, but can't seem to find it... :</s> Turns out 2§1⁄2 is as short as ÆḊ€.

Also, the structure needs work.

Jelly, (削除) 25 (削除ここまで) (削除) 24 (削除ここまで) (削除) 22 (削除ここまで) (削除) 21 (削除ここまで) 20 bytes

ZμṂrṀ)Œpμ3_2ドル§1⁄2ṀĊ,)Ṃ

Thanks to @EriktheOutgolfer for letting me know about ), saving 1 byte.

Try it online!

I'm sure there was a distance builtin in Jelly, but can't seem to find it... :</s> Turns out 2§1⁄2 is as short as ÆḊ€.

Also, the structure needs work.

Jelly, (削除) 25 (削除ここまで) (削除) 24 (削除ここまで) (削除) 22 (削除ここまで) (削除) 21 (削除ここまで) 20 bytes

ZμṂrṀ)Œpμ3_2ドル§1⁄2ṀĊ,)Ṃ

Thanks to @EriktheOutgolfer for letting me know about ), saving 1 byte.

Try it online!

I'm sure there was a distance builtin in Jelly, but can't seem to find it... :</s> Turns out 2§1⁄2 is as short as ÆḊ€.

added 2 characters in body
Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 37
  • 92

Jelly, (削除) 25 (削除ここまで) (削除) 24 (削除ここまで) (削除) 22 (削除ここまで) 21(削除) 21 (削除ここまで) 20 bytes

3_2ドル§1⁄2ṀĊ,
ZμṂrṀ)ŒpÇ€ṂŒpμ3_2ドル§1⁄2ṀĊ,)Ṃ

Thanks to @EriktheOutgolfer for letting me know about ), saving 1 byte.

Try it online! Try it online!

I'm sure there was a distance builtin in Jelly, but can't seem to find it... :</s> Turns out 2§1⁄2 is as short as ÆḊ€.

Also, the structure needs work.

Jelly, (削除) 25 (削除ここまで) (削除) 24 (削除ここまで) (削除) 22 (削除ここまで) 21 bytes

3_2ドル§1⁄2ṀĊ,
ZμṂrṀ)ŒpÇ€Ṃ

Thanks to @EriktheOutgolfer for letting me know about ), saving 1 byte.

Try it online!

I'm sure there was a distance builtin in Jelly, but can't seem to find it... :</s> Turns out 2§1⁄2 is as short as ÆḊ€.

Also, the structure needs work.

Jelly, (削除) 25 (削除ここまで) (削除) 24 (削除ここまで) (削除) 22 (削除ここまで) (削除) 21 (削除ここまで) 20 bytes

ZμṂrṀ)Œpμ3_2ドル§1⁄2ṀĊ,)Ṃ

Thanks to @EriktheOutgolfer for letting me know about ), saving 1 byte.

Try it online!

I'm sure there was a distance builtin in Jelly, but can't seem to find it... :</s> Turns out 2§1⁄2 is as short as ÆḊ€.

Also, the structure needs work.

added 48 characters in body
Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 37
  • 92
Loading
added 48 characters in body
Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 37
  • 92
Loading
Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 37
  • 92
Loading

AltStyle によって変換されたページ (->オリジナル) /