using mathmatical symbols in cells

G

GO

I am trying to re-create a brain teaser from the newspaper on an excel spread
sheet. The aim is to have two rows and two columns of numbers interlaced and
the four mathmatical symbols used once each so that both the rows and columns
sum to the same amount.

e.g. (this is not solved!)

2 10
6 / 2 - 2
2 2
3 + 2 * 2
1 1

I would like to put mathmatical symbols in cells to form each equation, so
that I can change the symbol and both row and coloumn up-dates. Has anyone
done something like this?

Thanks.
 
G

Gary''s Student

Consider the following User Defined Function:

Function equa(r1 As Range, r2 As Range, r3 As Range) As Variant
v1 = r1.Value
v2 = r2.Value
v3 = r3.Value
equa = Evaluate(v1 & v2 & v3)
End Function

So if A1 contains 1
and B1 contains +
and C1 contains 2

then =equa(A1,B1,C1) will return 3

You can change the symbol in B1 to - or / or * or ^


User Defined Functions (UDFs) are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the UDF will be saved with it.

To remove the UDF:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To use the UDF from Excel:

=equa(A1,B1,C1)

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

or

http://www.cpearson.com/excel/WritingFunctionsInVBA.aspx
for specifics on UDFs
 
D

Dana DeLouis

Hi. I pulled up all "permutations" of "+-*/" and even "+-*/^" and did
not show a solution. Are you sure you copied the problem correctly?
- - -
Dana DeLouis
 
S

Spiky

Hi.  I pulled up all "permutations" of "+-*/" and even "+-*/^" and did
not show a solution.  Are you sure you copied the problem correctly?
- - -
Dana DeLouis

Are you sure, Dana? Left to right, then top to bottom: +/*-
=4
 
D

Dana DeLouis

Hi. Thanks. Maybe I don't understand the question.
I take it one replaces all of the + - * / that are listed with different
permutations.

{"2+2-1", "10*2/1", "6+2*2", "3-2/2"},
{"2+2-1", "10/2*1", "6+2/2", "3-2*2"},
{"2+2*1", "10-2/1", "6+2-2", "3*2/2"},
{"2+2*1", "10/2-1", "6+2/2", "3*2-2"}...
....etc

I didn't show any that were all equal numerically.
Even if duplicates were allowed, I didn't get an answer.
I'll try some more ideas.
Thanks. :>)
 
S

Spiky

Hi. Thanks.  Maybe I don't understand the question.
{"2+2*1", "10/2-1", "6+2/2", "3*2-2"}...

Maybe you should check this one again. Note this always goes in order
since it is a little brain teaser game, it doesn't follow the "*/
before +-" rule of algebra.
:)
 
D

Dana DeLouis

Oh! I see. The rows can total to a different value than the columns.
I thought both rows and columns had to total to the same value. My mistake.

{"2+2+1", "10/2*1", "6+2/2", "3+2*2"},
{"2+2+1", "10/2^1", "6+2/2", "3+2^2"},
{"2+2^1", "10/2-1", "6+2/2", "3^2-2"}

ect...
Dana DeLouis
 
S

Spiky

Oh!  I see.  The rows can total to a different value than the columns..
I thought both rows and columns had to total to the same value.  My mistake.

No, you had the premise correct, according to the OP's description.
Maybe you just missed a calc somewhere. As I said, the correct signs
are:

+ /
* -

2+2*1=4
10/2-1=4
6+2/2=4
3*2-2=4
 
D

Dana DeLouis

6+2/2=4

Hi. I saw that as one of the few "close" matches also, but my program
gave 6+1 = 7, and not 4. Did I do something wrong?
Thanks.
Dana
 
S

Spiky

 > 6+2/2=4

Hi.  I saw that as one of the few "close" matches also, but my program
gave 6+1 = 7, and not 4.  Did I do something wrong?
Thanks.
Dana

That's what I meant by NOT using the typical rule of * / before + -.
Excel or whatever system will follow this rule and do multiplication
first. But this is a paper brain teaser. You have to do it in the
order listed on the paper. If you are using a formula, maybe put
parentheses around the first calc to make sure it goes first.

I just did it in my head. I can break the rules, Excel can't. ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top