0
   

puzzle

 
 
mah1
 
Reply Tue 5 Jun, 2012 06:00 am
Suppose you are given (1) a natural number N; (2) a set of natural num-
bers S = {n1; n2; : : : }; (3) a set of arithmetic operators, say +; -;*; =
(with the usual meaning of addition, multiplication, substraction, di-
vision). Your job is to construct an arithmetic expression R built from
the given operators and using each of the numbers in S exactly once,
with R = N.
(a) Explain in general how you could solve that problem.
(b) Solve the speci c instance: N = 24, S = {1; 3; 4; 6}
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 1,474 • Replies: 1
No top replies

 
markr
 
  1  
Reply Tue 5 Jun, 2012 01:42 pm
@mah1,
I've actually done this. You'll need parentheses in the arithmetic expression. You could generate every possible string that looks like n.n.n.n, where . is any operator, but for each of those you 'd have to generate all possible parenthetical groupings. Per a suggestion from someone in another forum, I generated all of the possible postfix representations and wrote a postfix evaluator.

A postfix solution to part b is:
6 1 3 4 / - /
0 Replies
 
 

Related Topics

Amount of Time - Question by Randy Dandy
please help - Question by johnconar
please help to solve this - Question by johnconar
Viz tie break question, hard sums. - Question by izzythepush
trigonometry - Question by anurag131
Econometrics F-Test - Question by alanm99
Discrete Structures And Combinatorics - Question by AnnSmith123
 
  1. Forums
  2. » puzzle
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 05/15/2024 at 04:29:47