Skip to main content
deleted 1125 characters in body
Source Link
Neil
  • 177.2k
  • 12
  • 74
  • 281

Charcoal, 4040 39 bytes

Nθ≔¹ηW¬№υθ«≦⊕η≔∨υ⟦⁰⟧ζ≔⟦⟧υF⊕θFζ⊞υ⁺λXκη»Iη

Try it online! Link is to verbose version of code. Outputs the nth value. Brute force, so times out on TIO for n=23 and similar higher values. Explanation:

Nθ

Input n.

≔¹η

Start searching for powers.

W¬№υθ«

Repeat until a one of the sums includes the input.

≦⊕η

Try the next power.

≔∨υ⟦⁰⟧ζ

Save the previous set of sums, or use a sum of zero for the first pass (this is needed to make the code output 2 for an input of zero instead of the 1 that an empty sum would imply.)

≔⟦⟧υ

Start a new set of sums.

F⊕θ

Loop over all of the integers up to and including n.

Fζ

Loop over all of the previous sums.

⊞υ⁺λXκη

Add the current power to the previous sum and save the result.

»Iη

Output the highest power needed.

I wasn't able to golf this much more efficient version below 41 bytes:

≔EN⊗¬ιθF…²χF⮌⌕Aθ⁰F⊙θ∧¬‹κXμι§θ⁻κXμι§≔θκιIθFN⊞υ⊗¬ιF…²χF⮌⌕Aυ⁰F⊙υΣ✂…υ⊕⁻κXμι±¹§≔υκιIυ

Try it online!Try it online! Link is to verbose version of code. Outputs the first n values. Explanation:

≔EN⊗¬ιθFN⊞υ⊗¬ι

Start with 0 having been found to have a value of 2 but none of the other values having been found yet.

F…²χ

Try from squares up to ninth powers.

F⮌⌕Aθ⁰F⮌⌕Aυ⁰

Loop over all of the values that haven't yet been found in reverse order, so the highest index is tested first.

F⊙θ∧¬‹κXμι§θ⁻κXμιF⊙υΣ✂…υ⊕⁻κXμι±¹

Subtract the powers of all the integers up to n from the current index and see if any of those valuevalues had previously been found. This is harder than it sounds as it's necessary to defeat Charcoal's cyclic indexing.

§≔θκι§≔υκι

If so then mark this value with the necessary power.

IθIυ

Output all of the values.

Charcoal, 40 bytes

Nθ≔¹ηW¬№υθ«≦⊕η≔∨υ⟦⁰⟧ζ≔⟦⟧υF⊕θFζ⊞υ⁺λXκη»Iη

Try it online! Link is to verbose version of code. Outputs the nth value. Brute force, so times out on TIO for n=23 and similar higher values. Explanation:

Nθ

Input n.

≔¹η

Start searching for powers.

W¬№υθ«

Repeat until a one of the sums includes the input.

≦⊕η

Try the next power.

≔∨υ⟦⁰⟧ζ

Save the previous set of sums, or use a sum of zero for the first pass (this is needed to make the code output 2 for an input of zero instead of the 1 that an empty sum would imply.)

≔⟦⟧υ

Start a new set of sums.

F⊕θ

Loop over all of the integers up to and including n.

Fζ

Loop over all of the previous sums.

⊞υ⁺λXκη

Add the current power to the previous sum and save the result.

»Iη

Output the highest power needed.

I wasn't able to golf this much more efficient version below 41 bytes:

≔EN⊗¬ιθF…²χF⮌⌕Aθ⁰F⊙θ∧¬‹κXμι§θ⁻κXμι§≔θκιIθ

Try it online! Link is to verbose version of code. Outputs the first n values. Explanation:

≔EN⊗¬ιθ

Start with 0 having been found to have a value of 2 but none of the other values having been found yet.

F…²χ

Try from squares up to ninth powers.

F⮌⌕Aθ⁰

Loop over all of the values that haven't yet been found in reverse order, so the highest index is tested first.

F⊙θ∧¬‹κXμι§θ⁻κXμι

Subtract the powers of all the integers up to n from the current index and see if any of those value had previously been found.

§≔θκι

If so then mark this value with the necessary power.

Iθ

Output all of the values.

Charcoal, 40 39 bytes

FN⊞υ⊗¬ιF…²χF⮌⌕Aυ⁰F⊙υΣ✂…υ⊕⁻κXμι±¹§≔υκιIυ

Try it online! Link is to verbose version of code. Outputs the first n values. Explanation:

FN⊞υ⊗¬ι

Start with 0 having been found to have a value of 2 but none of the other values having been found yet.

F…²χ

Try from squares up to ninth powers.

F⮌⌕Aυ⁰

Loop over all of the values that haven't yet been found in reverse order, so the highest index is tested first.

F⊙υΣ✂…υ⊕⁻κXμι±¹

Subtract the powers of all the integers up to n from the current index and see if any of those values had previously been found. This is harder than it sounds as it's necessary to defeat Charcoal's cyclic indexing.

§≔υκι

If so then mark this value with the necessary power.

Iυ

Output all of the values.

added 1092 characters in body
Source Link
Neil
  • 177.2k
  • 12
  • 74
  • 281

Charcoal, 40 bytes

Nθ≔¹ηW¬№υθ«≦⊕η≔∨υ⟦⁰⟧ζ≔⟦⟧υF⊕θFζ⊞υ⁺λXκη»Iη

Try it online! Link is to verbose version of code. Outputs the nth value. Brute force, so times out on TIO for n=23 and similar higher values. Explanation:

Nθ

Input n.

≔¹η

Start searching for powers.

W¬№υθ«

Repeat until a one of the sums includes the input.

≦⊕η

Try the next power.

≔∨υ⟦⁰⟧ζ

Save the previous set of sums, or use a sum of zero for the first pass (this is needed to make the code output 2 for an input of zero instead of the 1 that an empty sum would imply.)

≔⟦⟧υ

Start a new set of sums.

F⊕θ

Loop over all of the integers up to and including n.

Fζ

Loop over all of the previous sums.

⊞υ⁺λXκη

Add the current power to the previous sum and save the result.

»Iη

Output the highest power needed.

I wasn't able to golf this much more efficient version below 41 bytes:

≔EN⊗¬ιθF…²χF⮌⌕Aθ⁰F⊙θ∧¬‹κXμι§θ⁻κXμι§≔θκιIθ

Try it online! Link is to verbose version of code. Outputs the first n values. Explanation:

≔EN⊗¬ιθ

Start with 0 having been found to have a value of 2 but none of the other values having been found yet.

F…²χ

Try from squares up to ninth powers.

F⮌⌕Aθ⁰

Loop over all of the values that haven't yet been found in reverse order, so the highest index is tested first.

F⊙θ∧¬‹κXμι§θ⁻κXμι

Subtract the powers of all the integers up to n from the current index and see if any of those value had previously been found.

§≔θκι

If so then mark this value with the necessary power.

Iθ

Output all of the values.

Charcoal, 40 bytes

Nθ≔¹ηW¬№υθ«≦⊕η≔∨υ⟦⁰⟧ζ≔⟦⟧υF⊕θFζ⊞υ⁺λXκη»Iη

Try it online! Link is to verbose version of code. Outputs the nth value. Brute force, so times out on TIO for n=23 and similar higher values. Explanation:

Nθ

Input n.

≔¹η

Start searching for powers.

W¬№υθ«

Repeat until a one of the sums includes the input.

≦⊕η

Try the next power.

≔∨υ⟦⁰⟧ζ

Save the previous set of sums, or use a sum of zero for the first pass (this is needed to make the code output 2 for an input of zero instead of the 1 that an empty sum would imply.)

≔⟦⟧υ

Start a new set of sums.

F⊕θ

Loop over all of the integers up to and including n.

Fζ

Loop over all of the previous sums.

⊞υ⁺λXκη

Add the current power to the previous sum and save the result.

»Iη

Output the highest power needed.

Charcoal, 40 bytes

Nθ≔¹ηW¬№υθ«≦⊕η≔∨υ⟦⁰⟧ζ≔⟦⟧υF⊕θFζ⊞υ⁺λXκη»Iη

Try it online! Link is to verbose version of code. Outputs the nth value. Brute force, so times out on TIO for n=23 and similar higher values. Explanation:

Nθ

Input n.

≔¹η

Start searching for powers.

W¬№υθ«

Repeat until a one of the sums includes the input.

≦⊕η

Try the next power.

≔∨υ⟦⁰⟧ζ

Save the previous set of sums, or use a sum of zero for the first pass (this is needed to make the code output 2 for an input of zero instead of the 1 that an empty sum would imply.)

≔⟦⟧υ

Start a new set of sums.

F⊕θ

Loop over all of the integers up to and including n.

Fζ

Loop over all of the previous sums.

⊞υ⁺λXκη

Add the current power to the previous sum and save the result.

»Iη

Output the highest power needed.

I wasn't able to golf this much more efficient version below 41 bytes:

≔EN⊗¬ιθF…²χF⮌⌕Aθ⁰F⊙θ∧¬‹κXμι§θ⁻κXμι§≔θκιIθ

Try it online! Link is to verbose version of code. Outputs the first n values. Explanation:

≔EN⊗¬ιθ

Start with 0 having been found to have a value of 2 but none of the other values having been found yet.

F…²χ

Try from squares up to ninth powers.

F⮌⌕Aθ⁰

Loop over all of the values that haven't yet been found in reverse order, so the highest index is tested first.

F⊙θ∧¬‹κXμι§θ⁻κXμι

Subtract the powers of all the integers up to n from the current index and see if any of those value had previously been found.

§≔θκι

If so then mark this value with the necessary power.

Iθ

Output all of the values.

Source Link
Neil
  • 177.2k
  • 12
  • 74
  • 281

Charcoal, 40 bytes

Nθ≔¹ηW¬№υθ«≦⊕η≔∨υ⟦⁰⟧ζ≔⟦⟧υF⊕θFζ⊞υ⁺λXκη»Iη

Try it online! Link is to verbose version of code. Outputs the nth value. Brute force, so times out on TIO for n=23 and similar higher values. Explanation:

Nθ

Input n.

≔¹η

Start searching for powers.

W¬№υθ«

Repeat until a one of the sums includes the input.

≦⊕η

Try the next power.

≔∨υ⟦⁰⟧ζ

Save the previous set of sums, or use a sum of zero for the first pass (this is needed to make the code output 2 for an input of zero instead of the 1 that an empty sum would imply.)

≔⟦⟧υ

Start a new set of sums.

F⊕θ

Loop over all of the integers up to and including n.

Fζ

Loop over all of the previous sums.

⊞υ⁺λXκη

Add the current power to the previous sum and save the result.

»Iη

Output the highest power needed.