Skip to main content
added 66 characters in body
Source Link
Kevin Cruijssen
  • 131.5k
  • 13
  • 144
  • 384

05AB1E, 8 8 6 bytes

Åœ2ùŲPàÝãnOIå

Try it online Bugfixed and -2 bytes thanks to @Mr.Xcoder, making it now similar as @emanresuA's Vyxal answer and @cairdCoinheringaahing's Jelly answer.

Try it online or verify the smaller test casesverify the smaller test cases.

Explanation:

Åœ Ý       # Get all lists ofPush positivea integerslist thatin sumthe torange the[0, (implicit) inputinput]
  ã      # OnlyCreate keepall thepossible pairs
    Ų    # Check for each number whetherwith it'sthe acartesian squareproduct
    n  P   # Product: check forSquare each pair if both are truthyinteger
      O    # (the empty list will also result in truthy forSum n=0each andinner n=1)pair
       à  # Max: checkCheck if any in thethis list is truthy
contains the input
        # (after which the result is output implicitly)

05AB1E, 8 bytes

Åœ2ùŲPà

Try it online or verify the smaller test cases.

Explanation:

Ŝ        # Get all lists of positive integers that sum to the (implicit) input
        # Only keep the pairs
    Ų    # Check for each number whether it's a square
      P   # Product: check for each pair if both are truthy
          # (the empty list will also result in truthy for n=0 and n=1)
       à  # Max: check if any in the list is truthy
          # (after which the result is output implicitly)

05AB1E, 8 6 bytes

ÝãnOIå

Bugfixed and -2 bytes thanks to @Mr.Xcoder, making it now similar as @emanresuA's Vyxal answer and @cairdCoinheringaahing's Jelly answer.

Try it online or verify the smaller test cases.

Explanation:

Ý       # Push a list in the range [0, (implicit) input]
 ã      # Create all possible pairs with the cartesian product
  n     # Square each integer
   O    # Sum each inner pair
      # Check if this list contains the input
        # (after which the result is output implicitly)
Source Link
Kevin Cruijssen
  • 131.5k
  • 13
  • 144
  • 384

05AB1E, 8 bytes

Åœ2ùŲPà

Try it online or verify the smaller test cases.

Explanation:

Ŝ        # Get all lists of positive integers that sum to the (implicit) input
  2ù      # Only keep the pairs
    Ų    # Check for each number whether it's a square
      P   # Product: check for each pair if both are truthy
          # (the empty list will also result in truthy for n=0 and n=1)
       à  # Max: check if any in the list is truthy
          # (after which the result is output implicitly)