Make 1s using a bunch of 1s
score = 82 71 69 (34 ‘1’s + 23 ‘+’s + 12 parenthesis pairs)
$$\begin{multline*} 11111111111 = 1 + (1 + 1) \cdot {} \\ (1 + 1 + 1 + (1 + 1)^{(1 + 1)^{1 + 1 + 1}}(1 + ((1 + 1)(1 + 1 + 1))^{1 + 1 + 1})) \cdot {} \\ (1 + (1 + (1 + 1 + 1)^{1 + 1})^{1 + (1 + 1)^{1 + 1}}) \end{multline*}$$
Try it online!
Search program in Rust
This finds optimal solutions for up to about 8 digit numbers. Don’t try it on anything larger—it will eat all your memory.
I constructed the above solution by manually writing \$11111111111 = 1 + 111110 \cdot 100001\$ and searching for optimal solutions to \$111110\$ and \$100001\$.
use std::env;
#[derive(Clone, Debug)]
enum Op {
One,
Add(u32, u32),
Mul(u32, u32),
Pow(u32, u32),
}
fn show(ops: &[Option<Op>], z: u32, prec: u32) {
match ops[z as usize].as_ref().unwrap() {
Op::One => print!("1"),
Op::Add(x, y) => {
if prec > 0 {
print!("(");
}
show(ops, *x, 0);
print!(" + ");
show(ops, *y, 0);
if prec > 0 {
print!(")");
}
}
Op::Mul(x, y) => {
if prec > 1 {
print!("(");
}
show(ops, *x, 1);
show(ops, *y, 1);
if prec > 1 {
print!(")");
}
}
Op::Pow(x, y) => {
if prec > 2 {
print!("(");
}
show(ops, *x, 3);
print!("^{{");
show(ops, *y, 0);
print!("}}");
if prec > 2 {
print!(")");
}
}
}
}
fn main() {
for target in env::args().skip(1).map(|arg| arg.parse().unwrap()) {
let mut ops: Vec<Option<Op>> = vec![None; target as usize + 1];
let mut vs: Vec<Vec<u32>> = vec![];
while !ops[target as usize].is_some() {
let mut v: Vec<u32> = vec![];
let mut visit = |x, op| {
if let Some(x) = x {
if x <= target {
if ops[x as usize].is_none() {
ops[x as usize] = Some(op);
v.push(x);
}
}
}
};
let level = vs.len();
let score = level / 2;
match level % 2 {
0 => {
if score == 1 {
visit(Some(1), Op::One);
}
for i in 1..score.saturating_sub(1) {
let j = score - 1 - i;
for u in &vs[i * 2..i * 2 + 2] {
for v in &vs[j * 2..j * 2 + 2] {
for &x in u {
for &y in v {
visit(x.checked_pow(y), Op::Pow(x, y));
}
}
}
}
}
for i in 1..score {
let j = score - i;
for u in &vs[i * 2 - 1..i * 2 + 1] {
for v in &vs[j * 2 - 2..j * 2 + 1] {
for &x in u {
for &y in v {
visit(x.checked_mul(y), Op::Mul(x, y));
}
}
}
}
}
}
1 => {
for i in 1..score.saturating_sub(1) {
let j = score - 1 - i;
for u in &vs[i * 2..i * 2 + 2] {
for v in &vs[j * 2..j * 2 + 2] {
for &x in u {
for &y in v {
visit(x.checked_add(y), Op::Add(x, y));
}
}
}
}
}
}
_ => unreachable!(),
}
vs.push(v);
}
print!("{} = ", target);
show(&ops, target, 0);
println!();
}
}
Try it online!
By hand - 118 112 111 82
$$(1+(1+1)^{(1+1)^{1+1}}(1+(1+1)(1+(1+(1+1)^{1+1})^{1+1})^{1+1}))(1+(1+1+(1+1+1)^{1+1})(1+1+(((1+1)(1+1+1))^{1+1})^{1+1+1}))$$
Try it at Wolfram Alpha
This was found by working my way down from \$11111111111\$ looking for close divisibility considering factors which are close in construction to powers and is:
$$(((8(9^4)+(3(9^2))+8)((16+1)^2)+8)81+2)9+2$$
There are \$16\$ parentheses pairs, \$40\$ ones, and \$26\$ additions.
Previous @111
$$((1+1)(1+1+1)^{1+1})^{(1+1)^{1+1+1}}+((1+1)(1+1+1)^{1+1}(1+1+1+1+1)^{1+1})^{1+1+1}+((1+1+1)^{1+1+1})^{1+1+1}+((1+1)(1+1+1)^{1+1})^{1+1+1}+(1+1)((1+1+1)^{1+1}+1)$$
Try it at Wolfram Alpha
This is
$$18^8+450^3+(3^3)^3+18^3+20$$
Where:
\$18 = 2\times 9 = (1+1)(1+1+1)^{1+1}\$
\$8 = 2^3 = (1+1)^{1+1+1}\$
\$450 = 18\times 25 = (1+1)(1+1+1)^{1+1}(1+1+1+1+1)^{1+1}\$
\$20 = 2\times (9+1) = (1+1)((1+1+1)^{1+1}+1)\$
69 operations
$$1+(1+((1+1+1)^{1+1}+1)^{1+1+1+1+1})(1+1)\\ \cdot(1+1+1+(1+((1+1+1)(1+1))^{1+1+1})(1+1)^{(1+1)^{1+1+1}})$$
Try it online!
Verifier thanks to @AndersKaseorg
34 1
s, 24 +
s, 11 ()
s.
Decomposition, by layers:
- 11111111111 = 100001 * 111110 + 1
- 100001 = 10^5+1
- 111110 = 55555*2
- 55555 = 3 + 217*256
- 217 = 6^3+1
- 256 = 2^2^3
I wrote a program to brute-force this, but I'm still working on the program.