Author |
Topic: REMOVE PARENTHESES (Read 11047 times) |
|
arvindwu
Newbie
Gender:
Posts: 1
|
|
REMOVE PARENTHESES
« on: Nov 1st, 2008, 1:56am » |
Quote Modify
|
how to remove redundent parentheses (A+B) = A+B (A+(B*C) ) = A+B*C ((A+B)*C) = (A+B)*C A/(B+C) = A/(B+C)
|
|
IP Logged |
|
|
|
towr
wu::riddles Moderator Uberpuzzler
Some people are average, some are just mean.
Gender:
Posts: 13730
|
|
Re: REMOVE PARENTHESES
« Reply #1 on: Nov 1st, 2008, 4:13am » |
Quote Modify
|
Build a tree from the expression, and then use precedence rules: C\P + - * / +: _ r lr lr -: _ r lr lr *: _ _ _ r /: _ _ _ r e.g. If the parent node (P) has the operator *, then a child (C) with operator + needs to be enveloped in parentheses when it's either the left (l) or right (r) child. If the parent node (P) has the operator /, then a child (C) with operator * needs to be enveloped in parentheses only if it's the right (r) child, but not when it's the left (l).
|
« Last Edit: Nov 1st, 2008, 4:14am by towr » |
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
towr
wu::riddles Moderator Uberpuzzler
Some people are average, some are just mean.
Gender:
Posts: 13730
|
|
Re: REMOVE PARENTHESES
« Reply #2 on: Apr 5th, 2013, 6:21am » |
Quote Modify
|
I'm getting the distinct impression you're just spamming... I can't remember any of your posts contributing anything, it's all "I agree", "thanks", "I didn't know that".
|
|
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
Grimbal
wu::riddles Moderator Uberpuzzler
Gender:
Posts: 7527
|
|
Re: REMOVE PARENTHESES
« Reply #3 on: Apr 7th, 2013, 7:09am » |
Quote Modify
|
Me too. I even started to removed this kind of posts where there is no contribution to the subject. PS: oops, I was cleaning up this kind of messages and I accidentally deleted the message you were commenting on. For info, towr was replying to Mariko79 who just quoted towr's previous message and said something like "Thanks, buddy".
|
« Last Edit: Apr 7th, 2013, 8:56am by Grimbal » |
IP Logged |
|
|
|
|