Skip to main content
deleted 87 characters in body
Source Link
AnttiP
  • 7.9k
  • 15
  • 61

Python 3, 159 130130 125 bytes

f=lambda x,s={1},i=1,p=1,l=[]:i<7*x**x**x**x**xi<7**x**x**x and f(x,s^{i},1+i*(i in s),p*i,l+[s]*(sum(p//y for y in s)==x*p))or min(l,key=len)

Try it online!Try it online!

Bruteforces trough all Egyptian fractions, in order of maximum denominator. A limit of \$7x^{x^{x^{x^{x}}}}\$\$7^{x^{x^x}}\$ is used to stop the program. Then the shortest fraction is picked.

Now the elephant in the room is the upper bound \$7x^{x^{x^{x^{x}}}}\$\$7^{x^{x^x}}\$. This corresponds to the maximum denominator in an optimal solution. Let's see how this bound is obtained.

Let's first make an upper bound for the length of the Egyptian fraction. To construct the egyptian fraction for x, we first greedily pick unit fractions, until the next one would get us over x. For example, if x is 2, then we would do \$\frac{1}{1}+\frac{1}{2}+\frac{1}{3}\$, stopping before \$\frac{1}{4}\$, since that would result in a sum greater then 2. Note that this initial tail has length less than \$e^x\$.

Now we have \$2-\frac{1}{1}+\frac{1}{2}+\frac{1}{3}=\frac{1}{6}\$\$2-(\frac{1}{1}+\frac{1}{2}+\frac{1}{3})=\frac{1}{6}\$. Here we got lucky, and the difference is already a unit fraction. If it isn't, we can use the greedy algorithm to turn the difference into a unit fraction. The amount of fractions that the greedy algorithm introduces is at most the denominator of the difference. The denominator is less than the numerator which is less than \$e^x!<(e^x)^{e^x}=e^{xe^x}<x^{x^x}\$ for \$x\ge 4\$\$e^x!\$.

Finally, if we have an integer egyptian fraction of length l, the numerator can be at most l^l. To see why, note that the numerator of the last fraction can't be greater than the product of the other numerators.

Now we have the upper bound \$(x^{x^x})^{x^{x^x}}=x^{x^xx^{x^x}}<x^{x^{x^{x^{x}}}}\$\$(e^x!)^{e^x!}\$. when When \$x\ge 4\$. To fix the lower ones just multiply the power tower monstrosity with 7, for a final bound\$(e^x!)^{e^x!}<7^{x^{x^x}}\$. The seven takes care of values of \$7x^{x^{x^{x^{x}}}}\$\$x\$ less than 4.

This has to be the worst upper bound I've ever seen in my life. If someone can come up with a better bound, please tell me.Proof for \$(e^x!)^{e^x!}<x^{x^{x^x}}\$:

Edit: I think the lower bound can be improved to \$7x^{x^{x^{x}}}\$, I'll post proof tomorrow.\$(e^x!)^{e^x!}<((e^x)^{e^x})^{(e^x){e^x}}=(e^{xe^x})^{e^{xe^x}}=e^{xe^xe^{xe^x}}=e^{xe^{x+xe^x}}\$

\$x+xe^x< x^x\$

\$xe^{x+xe^x} < x^{x^x}\$

\$e^{xe^{x+xe^x}}<7^{x^{x^x}}\$

Python 3, 159 130 bytes

f=lambda x,s={1},i=1,p=1,l=[]:i<7*x**x**x**x**x and f(x,s^{i},1+i*(i in s),p*i,l+[s]*(sum(p//y for y in s)==x*p))or min(l,key=len)

Try it online!

Bruteforces trough all Egyptian fractions, in order of maximum denominator. A limit of \$7x^{x^{x^{x^{x}}}}\$ is used to stop the program. Then the shortest fraction is picked.

Now the elephant in the room is the upper bound \$7x^{x^{x^{x^{x}}}}\$. This corresponds to the maximum denominator in an optimal solution. Let's see how this bound is obtained.

Let's first make an upper bound for the length of the Egyptian fraction. To construct the egyptian fraction for x, we first greedily pick unit fractions, until the next one would get us over x. For example, if x is 2, then we would do \$\frac{1}{1}+\frac{1}{2}+\frac{1}{3}\$, stopping before \$\frac{1}{4}\$, since that would result in a sum greater then 2. Note that this initial tail has length less than \$e^x\$.

Now we have \$2-\frac{1}{1}+\frac{1}{2}+\frac{1}{3}=\frac{1}{6}\$. Here we got lucky, and the difference is already a unit fraction. If it isn't, we can use the greedy algorithm to turn the difference into a unit fraction. The amount of fractions that the greedy algorithm introduces is at most the denominator of the difference. The denominator is less than the numerator which is less than \$e^x!<(e^x)^{e^x}=e^{xe^x}<x^{x^x}\$ for \$x\ge 4\$.

Finally, if we have an integer egyptian fraction of length l, the numerator can be at most l^l. To see why, note that the numerator of the last fraction can't be greater than the product of the other numerators.

Now we have the upper bound \$(x^{x^x})^{x^{x^x}}=x^{x^xx^{x^x}}<x^{x^{x^{x^{x}}}}\$. when \$x\ge 4\$. To fix the lower ones just multiply the power tower monstrosity with 7, for a final bound of \$7x^{x^{x^{x^{x}}}}\$

This has to be the worst upper bound I've ever seen in my life. If someone can come up with a better bound, please tell me.

Edit: I think the lower bound can be improved to \$7x^{x^{x^{x}}}\$, I'll post proof tomorrow.

Python 3, 159 130 125 bytes

f=lambda x,s={1},i=1,p=1,l=[]:i<7**x**x**x and f(x,s^{i},1+i*(i in s),p*i,l+[s]*(sum(p//y for y in s)==x*p))or min(l,key=len)

Try it online!

Bruteforces trough all Egyptian fractions, in order of maximum denominator. A limit of \$7^{x^{x^x}}\$ is used to stop the program. Then the shortest fraction is picked.

Now the elephant in the room is the upper bound \$7^{x^{x^x}}\$. This corresponds to the maximum denominator in an optimal solution. Let's see how this bound is obtained.

Let's first make an upper bound for the length of the Egyptian fraction. To construct the egyptian fraction for x, we first greedily pick unit fractions, until the next one would get us over x. For example, if x is 2, then we would do \$\frac{1}{1}+\frac{1}{2}+\frac{1}{3}\$, stopping before \$\frac{1}{4}\$, since that would result in a sum greater then 2. Note that this initial tail has length less than \$e^x\$.

Now we have \$2-(\frac{1}{1}+\frac{1}{2}+\frac{1}{3})=\frac{1}{6}\$. Here we got lucky, and the difference is already a unit fraction. If it isn't, we can use the greedy algorithm to turn the difference into a unit fraction. The amount of fractions that the greedy algorithm introduces is at most the denominator of the difference. The denominator is less than the numerator which is less than \$e^x!\$.

Finally, if we have an integer egyptian fraction of length l, the numerator can be at most l^l. To see why, note that the numerator of the last fraction can't be greater than the product of the other numerators.

Now we have the upper bound \$(e^x!)^{e^x!}\$. When \$x\ge 4\$, \$(e^x!)^{e^x!}<7^{x^{x^x}}\$. The seven takes care of values of \$x\$ less than 4.

Proof for \$(e^x!)^{e^x!}<x^{x^{x^x}}\$:

\$(e^x!)^{e^x!}<((e^x)^{e^x})^{(e^x){e^x}}=(e^{xe^x})^{e^{xe^x}}=e^{xe^xe^{xe^x}}=e^{xe^{x+xe^x}}\$

\$x+xe^x< x^x\$

\$xe^{x+xe^x} < x^{x^x}\$

\$e^{xe^{x+xe^x}}<7^{x^{x^x}}\$

added 98 characters in body
Source Link
AnttiP
  • 7.9k
  • 15
  • 61

Python 3, 159 130 bytes

f=lambda x,s={1},i=1,p=1,l=[]:i<7*x**x**x**x**x and f(x,s^{i},1+i*(i in s),p*i,l+[s]*(sum(p//y for y in s)==x*p))or min(l,key=len)

Try it online!

Bruteforces trough all Egyptian fractions, in order of maximum denominator. A limit of \$7x^{x^{x^{x^{x}}}}\$ is used to stop the program. Then the shortest fraction is picked.

Now the elephant in the room is the upper bound \$7x^{x^{x^{x^{x}}}}\$. This corresponds to the maximum denominator in an optimal solution. Let's see how this bound is obtained.

Let's first make an upper bound for the length of the Egyptian fraction. To construct the egyptian fraction for x, we first greedily pick unit fractions, until the next one would get us over x. For example, if x is 2, then we would do \$\frac{1}{1}+\frac{1}{2}+\frac{1}{3}\$, stopping before \$\frac{1}{4}\$, since that would result in a sum greater then 2. Note that this initial tail has length less than \$e^x\$.

Now we have \$2-\frac{1}{1}+\frac{1}{2}+\frac{1}{3}=\frac{1}{6}\$. Here we got lucky, and the difference is already a unit fraction. If it isn't, we can use the greedy algorithm to turn the difference into a unit fraction. The amount of fractions that the greedy algorithm introduces is at most the denominator of the difference. The denominator is less than the numerator which is less than \$e^x!<(e^x)^{e^x}=e^{xe^x}<x^{x^x}\$ for \$x\ge 4\$.

Finally, if we have an integer egyptian fraction of length l, the numerator can be at most l^l. To see why, note that the numerator of the last fraction can't be greater than the product of the other numerators.

Now we have the upper bound \$(x^{x^x})^{x^{x^x}}=x^{x^xx^{x^x}}<x^{x^{x^{x^{x}}}}\$. when \$x\ge 4\$. To fix the lower ones just multiply the power tower monstrosity with 7, for a final bound of \$7x^{x^{x^{x^{x}}}}\$

This has to be the worst upper bound I've ever seen in my life. If someone can come up with a better bound, please tell me.

Edit: I think the lower bound can be improved to \$7x^{x^{x^{x}}}\$, I'll post proof tomorrow.

Python 3, 159 130 bytes

f=lambda x,s={1},i=1,p=1,l=[]:i<7*x**x**x**x**x and f(x,s^{i},1+i*(i in s),p*i,l+[s]*(sum(p//y for y in s)==x*p))or min(l,key=len)

Try it online!

Bruteforces trough all Egyptian fractions, in order of maximum denominator. A limit of \$7x^{x^{x^{x^{x}}}}\$ is used to stop the program. Then the shortest fraction is picked.

Now the elephant in the room is the upper bound \$7x^{x^{x^{x^{x}}}}\$. This corresponds to the maximum denominator in an optimal solution. Let's see how this bound is obtained.

Let's first make an upper bound for the length of the Egyptian fraction. To construct the egyptian fraction for x, we first greedily pick unit fractions, until the next one would get us over x. For example, if x is 2, then we would do \$\frac{1}{1}+\frac{1}{2}+\frac{1}{3}\$, stopping before \$\frac{1}{4}\$, since that would result in a sum greater then 2. Note that this initial tail has length less than \$e^x\$.

Now we have \$2-\frac{1}{1}+\frac{1}{2}+\frac{1}{3}=\frac{1}{6}\$. Here we got lucky, and the difference is already a unit fraction. If it isn't, we can use the greedy algorithm to turn the difference into a unit fraction. The amount of fractions that the greedy algorithm introduces is at most the denominator of the difference. The denominator is less than the numerator which is less than \$e^x!<(e^x)^{e^x}=e^{xe^x}<x^{x^x}\$ for \$x\ge 4\$.

Finally, if we have an integer egyptian fraction of length l, the numerator can be at most l^l. To see why, note that the numerator of the last fraction can't be greater than the product of the other numerators.

Now we have the upper bound \$(x^{x^x})^{x^{x^x}}=x^{x^xx^{x^x}}<x^{x^{x^{x^{x}}}}\$. when \$x\ge 4\$. To fix the lower ones just multiply the power tower monstrosity with 7, for a final bound of \$7x^{x^{x^{x^{x}}}}\$

This has to be the worst upper bound I've ever seen in my life. If someone can come up with a better bound, please tell me.

Python 3, 159 130 bytes

f=lambda x,s={1},i=1,p=1,l=[]:i<7*x**x**x**x**x and f(x,s^{i},1+i*(i in s),p*i,l+[s]*(sum(p//y for y in s)==x*p))or min(l,key=len)

Try it online!

Bruteforces trough all Egyptian fractions, in order of maximum denominator. A limit of \$7x^{x^{x^{x^{x}}}}\$ is used to stop the program. Then the shortest fraction is picked.

Now the elephant in the room is the upper bound \$7x^{x^{x^{x^{x}}}}\$. This corresponds to the maximum denominator in an optimal solution. Let's see how this bound is obtained.

Let's first make an upper bound for the length of the Egyptian fraction. To construct the egyptian fraction for x, we first greedily pick unit fractions, until the next one would get us over x. For example, if x is 2, then we would do \$\frac{1}{1}+\frac{1}{2}+\frac{1}{3}\$, stopping before \$\frac{1}{4}\$, since that would result in a sum greater then 2. Note that this initial tail has length less than \$e^x\$.

Now we have \$2-\frac{1}{1}+\frac{1}{2}+\frac{1}{3}=\frac{1}{6}\$. Here we got lucky, and the difference is already a unit fraction. If it isn't, we can use the greedy algorithm to turn the difference into a unit fraction. The amount of fractions that the greedy algorithm introduces is at most the denominator of the difference. The denominator is less than the numerator which is less than \$e^x!<(e^x)^{e^x}=e^{xe^x}<x^{x^x}\$ for \$x\ge 4\$.

Finally, if we have an integer egyptian fraction of length l, the numerator can be at most l^l. To see why, note that the numerator of the last fraction can't be greater than the product of the other numerators.

Now we have the upper bound \$(x^{x^x})^{x^{x^x}}=x^{x^xx^{x^x}}<x^{x^{x^{x^{x}}}}\$. when \$x\ge 4\$. To fix the lower ones just multiply the power tower monstrosity with 7, for a final bound of \$7x^{x^{x^{x^{x}}}}\$

This has to be the worst upper bound I've ever seen in my life. If someone can come up with a better bound, please tell me.

Edit: I think the lower bound can be improved to \$7x^{x^{x^{x}}}\$, I'll post proof tomorrow.

deleted 52 characters in body
Source Link
AnttiP
  • 7.9k
  • 15
  • 61

Python 3, 159 144130 bytes

lambda x:min(f(x),key=len)
f=lambda x,s={1},i=1,p=1,l=[]:i<7*x**x**x**x**x and f(x,s^{i},1+i*(i in s),p*i,l+[s]*(sum(p//y for y in s)==x*p))or min(l,key=len)

Try it online!Try it online!

Bruteforces trough all Egyptian fractions, in order of maximum denominator. A limit of \$7x^{x^{x^{x^{x}}}}\$ is used to stop the program. Then the shortest fraction is picked.

Now the elephant in the room is the upper bound \$7x^{x^{x^{x^{x}}}}\$. This corresponds to the maximum denominator in an optimal solution. Let's see how this bound is obtained.

Let's first make an upper bound for the length of the Egyptian fraction. To construct the egyptian fraction for x, we first greedily pick unit fractions, until the next one would get us over x. For example, if x is 2, then we would do \$\frac{1}{1}+\frac{1}{2}+\frac{1}{3}\$, stopping before \$\frac{1}{4}\$, since that would result in a sum greater then 2. Note that this initial tail has length less than \$e^x\$.

Now we have \$2-\frac{1}{1}+\frac{1}{2}+\frac{1}{3}=\frac{1}{6}\$. Here we got lucky, and the difference is already a unit fraction. If it isn't, we can use the greedy algorithm to turn the difference into a unit fraction. The amount of fractions that the greedy algorithm introduces is at most the denominator of the difference. The denominator is less than the numerator which is less than \$e^x!<(e^x)^{e^x}=e^{xe^x}<x^{x^x}\$ for \$x\ge 4\$.

Finally, if we have an integer egyptian fraction of length l, the numerator can be at most l^l. To see why, note that the numerator of the last fraction can't be greater than the product of the other numerators.

Now we have the upper bound \$(x^{x^x})^{x^{x^x}}=x^{x^xx^{x^x}}<x^{x^{x^{x^{x}}}}\$. when \$x\ge 4\$. To fix the lower ones just multiply the power tower monstrosity with 7, for a final bound of \$7x^{x^{x^{x^{x}}}}\$

This has to be the worst upper bound I've ever seen in my life. If someone can come up with a better bound, please tell me.

Python 3, 159 144 bytes

lambda x:min(f(x),key=len)
f=lambda x,s={1},i=1,p=1,l=[]:i<7*x**x**x**x**x and f(x,s^{i},1+i*(i in s),p*i,l+[s]*(sum(p//y for y in s)==x*p))or l

Try it online!

Bruteforces trough all Egyptian fractions, in order of maximum denominator. A limit of \$7x^{x^{x^{x^{x}}}}\$ is used to stop the program. Then the shortest fraction is picked.

Now the elephant in the room is the upper bound \$7x^{x^{x^{x^{x}}}}\$. This corresponds to the maximum denominator in an optimal solution. Let's see how this bound is obtained.

Let's first make an upper bound for the length of the Egyptian fraction. To construct the egyptian fraction for x, we first greedily pick unit fractions, until the next one would get us over x. For example, if x is 2, then we would do \$\frac{1}{1}+\frac{1}{2}+\frac{1}{3}\$, stopping before \$\frac{1}{4}\$, since that would result in a sum greater then 2. Note that this initial tail has length less than \$e^x\$.

Now we have \$2-\frac{1}{1}+\frac{1}{2}+\frac{1}{3}=\frac{1}{6}\$. Here we got lucky, and the difference is already a unit fraction. If it isn't, we can use the greedy algorithm to turn the difference into a unit fraction. The amount of fractions that the greedy algorithm introduces is at most the denominator of the difference. The denominator is less than the numerator which is less than \$e^x!<(e^x)^{e^x}=e^{xe^x}<x^{x^x}\$ for \$x\ge 4\$.

Finally, if we have an integer egyptian fraction of length l, the numerator can be at most l^l. To see why, note that the numerator of the last fraction can't be greater than the product of the other numerators.

Now we have the upper bound \$(x^{x^x})^{x^{x^x}}=x^{x^xx^{x^x}}<x^{x^{x^{x^{x}}}}\$. when \$x\ge 4\$. To fix the lower ones just multiply the power tower monstrosity with 7, for a final bound of \$7x^{x^{x^{x^{x}}}}\$

This has to be the worst upper bound I've ever seen in my life. If someone can come up with a better bound, please tell me.

Python 3, 159 130 bytes

f=lambda x,s={1},i=1,p=1,l=[]:i<7*x**x**x**x**x and f(x,s^{i},1+i*(i in s),p*i,l+[s]*(sum(p//y for y in s)==x*p))or min(l,key=len)

Try it online!

Bruteforces trough all Egyptian fractions, in order of maximum denominator. A limit of \$7x^{x^{x^{x^{x}}}}\$ is used to stop the program. Then the shortest fraction is picked.

Now the elephant in the room is the upper bound \$7x^{x^{x^{x^{x}}}}\$. This corresponds to the maximum denominator in an optimal solution. Let's see how this bound is obtained.

Let's first make an upper bound for the length of the Egyptian fraction. To construct the egyptian fraction for x, we first greedily pick unit fractions, until the next one would get us over x. For example, if x is 2, then we would do \$\frac{1}{1}+\frac{1}{2}+\frac{1}{3}\$, stopping before \$\frac{1}{4}\$, since that would result in a sum greater then 2. Note that this initial tail has length less than \$e^x\$.

Now we have \$2-\frac{1}{1}+\frac{1}{2}+\frac{1}{3}=\frac{1}{6}\$. Here we got lucky, and the difference is already a unit fraction. If it isn't, we can use the greedy algorithm to turn the difference into a unit fraction. The amount of fractions that the greedy algorithm introduces is at most the denominator of the difference. The denominator is less than the numerator which is less than \$e^x!<(e^x)^{e^x}=e^{xe^x}<x^{x^x}\$ for \$x\ge 4\$.

Finally, if we have an integer egyptian fraction of length l, the numerator can be at most l^l. To see why, note that the numerator of the last fraction can't be greater than the product of the other numerators.

Now we have the upper bound \$(x^{x^x})^{x^{x^x}}=x^{x^xx^{x^x}}<x^{x^{x^{x^{x}}}}\$. when \$x\ge 4\$. To fix the lower ones just multiply the power tower monstrosity with 7, for a final bound of \$7x^{x^{x^{x^{x}}}}\$

This has to be the worst upper bound I've ever seen in my life. If someone can come up with a better bound, please tell me.

deleted 2 characters in body
Source Link
AnttiP
  • 7.9k
  • 15
  • 61
Loading
Post Undeleted by AnttiP
added 1775 characters in body
Source Link
AnttiP
  • 7.9k
  • 15
  • 61
Loading
Post Deleted by AnttiP
Source Link
AnttiP
  • 7.9k
  • 15
  • 61
Loading