All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
8 8s (Posted on 2005-07-11) Difficulty: 3 of 5
How many ways can you find to make exactly 1000 with eight eights? You can only add, subtract, multiply, divide, use exponents and parentheses, and you can't use any number except 8.

See The Solution Submitted by Nat    
Rating: 3.8000 (5 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Computer generated solutions | Comment 15 of 24 |

Some of these are trivial variations of the others:

((8*8*8-8)/8)*(8+8)-8
((8+8)*8+8-88/8)*8
((8+8)*8-(8+8)/8)*8-8
((8+8)*8-(8+8+8)/8)*8
((8+8)*8-(88/8-8))*8
((8+8)*8-8/8)*8-(8+8)
((8+8)*8-8/8)*8-8-8
((8+8)*8-88/8+8)*8
((8+8)/8)*(8*8*8-8)-8
((8+8)/8+8)^((8+8+8)/8)
((8+8)/8+8)^(88/8-8)
((8+8/8)*888+8)/8
((8/8+8)*888+8)/8
((88-8)/8)^((8+8+8)/8)
((88-8)/8)^(88/8-8)
(8*(8+8)+8-88/8)*8
(8*(8+8)-(8+8)/8)*8-8
(8*(8+8)-(8+8+8)/8)*8
(8*(8+8)-(88/8-8))*8
(8*(8+8)-8/8)*8-(8+8)
(8*(8+8)-8/8)*8-8-8
(8*(8+8)-88/8+8)*8
(8*8*8-8)*(8+8)/8-8
(8*8*8-8)/(8/(8+8))-8
(8*8+8*8)*8-(8+8)-8
(8*8+8*8)*8-(8+8+8)
(8*8+8*8)*8-8-(8+8)
(8*8+8*8)*8-8-8-8
(8*8+8*8+8)*8-88
(8*8+8+8*8)*8-88
(8*8+88)^((88/8)/8)
(8*8+88)^(88/8*8)
(8*8-(8+8)/8)*(8+8)+8
(8*8-(8/8)^8)*(8+8)-8
(8*8-8^(8-8))*(8+8)-8
(8+(8+8)*8-88/8)*8
(8+(8+8)/8)^((8+8+8)/8)
(8+(8+8)/8)^(88/8-8)
(8+(8+8/8)*888)/8
(8+(8/8+8)*888)/8
(8+8)*(8*8*8-8)/8-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8)*(8*8-(8+8)/8)
8+(8+8-8/(8+8))*8*8
8+(8-(8/(8+8)-8))*8*8
8+(8-8/(8+8)+8)*8*8
8+8*(8+8-8/(8+8))*8
8+8*(8-(8/(8+8)-8))*8
8+8*(8-8/(8+8)+8)*8
8+8*8*(8+8-8/(8+8))
8+8*8*(8-(8/(8+8)-8))
8+8*8*(8-8/(8+8)+8)
8+8+8+88+888
8+8+8+888+88
8+8+88+8+888
8+8+88+888+8
8+8+888+8+88
8+8+888+88+8
8+88+8+8+888
8+88+8+888+8
8+88+888+8+8
8+888+8+8+88
8+888+8+88+8
8+888+88+8+8
8-((8+8)/8-8*8)*(8+8)
8-(8+8)*((8+8)/8-8*8)
8-(8/(8+8)-(8+8))*8*8
8-(8/(8+8)-8-8)*8*8
8-8*(8/(8+8)-(8+8))*8
8-8*(8/(8+8)-8-8)*8
8-8*8*(8/(8+8)-(8+8))
8-8*8*(8/(8+8)-8-8)
88+8+8+8+888
88+8+8+888+8
88+8+888+8+8
88+888+8+8+8
888+(8+8)*(8-8/8)
888+(8+8)*8-(8+8)
888+(8+8)*8-8-8
888+(8+888)/8
888+(8-8/8)*(8+8)
888+(888+8)/8
888+8*(8+8)-(8+8)
888+8*(8+8)-8-8
888+8+8+8+88
888+8+8+88+8
888+8+88+8+8
888+88+8+8+8
888-(8+8)*(8/8-8)
888-(8+8)+(8+8)*8
888-(8+8)+8*(8+8)
888-(8+8-(8+8)*8)
888-(8+8-8*(8+8))
888-(8-((8+8)*8-8))
888-(8-(8*(8+8)-8))
888-(8-(8+8)*8)-8
888-(8-(8+8)*8+8)
888-(8-8*(8+8))-8
888-(8-8*(8+8)+8)
888-(8/8-8)*(8+8)
888-8+(8+8)*8-8
888-8+8*(8+8)-8
888-8-(8-(8+8)*8)
888-8-(8-8*(8+8))
888-8-8+(8+8)*8
888-8-8+8*(8+8)

based on the following, which produces Reverse Polish Notation:

DEFLNG A-Z
DECLARE SUB try ()
CLEAR , , 25000
OPEN "8x8splus.txt" FOR OUTPUT AS #2
DIM SHARED noNums, no8s, noOps, stack#(30), lvl
DIM SHARED stackSize, f$

f$ = "8": noNums = 1: stack#(1) = 8: stackSize = 1: no8s = 1: noOps = 0

try

CLOSE

SUB try
 lvl = lvl + 1

 IF no8s < 8 THEN
   IF RIGHT$(f$, 1) = "8" THEN
     f$ = f$ + "8"
     stack#(stackSize) = 10 * stack#(stackSize) + 8
     no8s = no8s + 1
     try
     f$ = LEFT$(f$, LEN(f$) - 1)
     stack#(stackSize) = stack#(stackSize) 10
     no8s = no8s - 1
   END IF
   f$ = f$ + ",8"
   stackSize = stackSize + 1
   stack#(stackSize) = 8
   no8s = no8s + 1
   try
   f$ = LEFT$(f$, LEN(f$) - 2)
   stackSize = stackSize - 1
   no8s = no8s - 1
 END IF
 IF stackSize > 1 THEN
   h2# = stack#(stackSize)
   stackSize = stackSize - 1
   h1# = stack#(stackSize)
 
   stack#(stackSize) = h1# + h2#
   f$ = f$ + "+"
   try

   stack#(stackSize) = h1# - h2#
   MID$(f$, LEN(f$), 1) = "-"
   try

   IF h1# = 0 OR h2# = 0 THEN
    tst = 1
   ELSE
    tst = (LOG(ABS(h1#)) + LOG(ABS(h2#))) / LOG(10)
   END IF
   IF tst < 300 THEN
     stack#(stackSize) = 1# * h1# * h2#
     MID$(f$, LEN(f$), 1) = "*"
     try
   END IF

   IF h2# <> 0 THEN
     stack#(stackSize) = h1# / h2#
     MID$(f$, LEN(f$), 1) = "/"
     try
   END IF
 
   IF h1# = 0 THEN
     stack#(stackSize) = 0
     MID$(f$, LEN(f$), 1) = "^"
     try
   ELSE
     tst# = LOG(ABS(h1#)) * h2# / LOG(10)
     IF ABS(tst#) < 300 AND (h1# > 0 OR h2# = INT(h2#) AND ABS(h2#) < 1000000000000000#) THEN
       stack#(stackSize) = h1# ^ h2#
       MID$(f$, LEN(f$), 1) = "^"
       try
     END IF
   END IF
  
   stack#(stackSize) = h1#
   stackSize = stackSize + 1
   stack#(stackSize) = h2#
   f$ = LEFT$(f$, LEN(f$) - 1)
 ELSE
   IF no8s < 8 THEN
   ELSE
    IF INT(stack#(1) + .5) = 1000 THEN PRINT f$: PRINT #2, f$, stack#(1)
   END IF
 END IF
 lvl = lvl - 1
 EXIT SUB
END SUB


then weeding out by hand two that are really not 1000 but just round to 1000, and sending to the following program to convert RPN to algebraic notation:

DECLARE SUB checkParen (s$, ops$)
OPEN "8x8s.txt" FOR INPUT AS #1
OPEN "8X8SALG.TXT" FOR OUTPUT AS #2
DO
 LINE INPUT #1, l$
 stackLevel = 0
 bld$ = ""
 FOR i = 1 TO LEN(l$)
  c$ = MID$(l$, i, 1)
  ix = INSTR("0123456789", c$)
  IF ix THEN
   bld$ = bld$ + c$
   stkRaise = 1
  ELSE
   IF stkRaise THEN
    stackLevel = stackLevel + 1
    stack$(stackLevel) = bld$
    stkRaise = 0
    bld$ = ""
   END IF
   SELECT CASE c$
    CASE "+"
     stackLevel = stackLevel - 1
     stack$(stackLevel) = stack$(stackLevel + 1) + "+" + stack$(stackLevel)
    CASE "-"
     h2$ = stack$(stackLevel)
     checkParen h2$, "+-"
     stackLevel = stackLevel - 1
     h1$ = stack$(stackLevel)
     stack$(stackLevel) = h1$ + "-" + h2$
    CASE "*"
     h2$ = stack$(stackLevel)
     checkParen h2$, "+-"
     stackLevel = stackLevel - 1
     h1$ = stack$(stackLevel)
     checkParen h1$, "+-/"
     stack$(stackLevel) = h1$ + "*" + h2$
    CASE "/"
     h2$ = stack$(stackLevel)
     checkParen h2$, "+-/"
     stackLevel = stackLevel - 1
     h1$ = stack$(stackLevel)
     checkParen h1$, "+-/"
     stack$(stackLevel) = h1$ + "/" + h2$
    CASE "^"
     h2$ = stack$(stackLevel)
     checkParen h2$, "+-*/"
     stackLevel = stackLevel - 1
     h1$ = stack$(stackLevel)
     checkParen h1$, "+-*/"
     stack$(stackLevel) = h1$ + "^" + h2$
   END SELECT
  END IF
 NEXT
 IF stackLevel <> 1 THEN
      REM
 END IF
 PRINT l$, stack$(1): PRINT #2, l$, stack$(1)
LOOP UNTIL EOF(1)
CLOSE

SUB checkParen (s$, ops$)
 pLevel = 0
 flag = 0
 FOR i = 1 TO LEN(s$)
   SELECT CASE MID$(s$, i, 1)
     CASE "("
      pLevel = pLevel + 1
     CASE ")"
      pLevel = pLevel - 1
     CASE ELSE
      IF pLevel = 0 AND INSTR(ops$, MID$(s$, i, 1)) THEN flag = 1: EXIT FOR
   END SELECT
 NEXT i
 IF flag THEN s$ = "(" + s$ + ")"
END SUB


and then sorting the results and eliminating exact duplicates.

Edited on July 12, 2005, 7:30 pm
  Posted by Charlie on 2005-07-12 18:58:03

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information