|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
[numbers] Negation vs substraction
My brain is melting while trying to reduce^H^H^H^H^H^H remove redundancy from my script...
Can "-" be used as the negation operator, if I'm completely sure that that operation can be transformed into another one, which only uses "-" as the substractor? I mean, if my script was stupid enough to ignore the following solution: (a+b)*(c-d) but could output the following instead: (-a-b)*(d-c) could it be allright?? |
|
#2
|
|||
|
|||
|
[numbers] RE: Negation vs substraction
Posted: Friday, October 17 2003 03:36 AM
Quote Is this valid? -1-2-3+4+5+6 4+5+6-1-2-3 or 4+5+6+(-1-2-3) The first and third one are not correct, because you cannot use unary minus (-1). If they were 4-1-2-3+5+6 and 4+5+6-(1+2+3), you'd have: f1(a,b,c,d,e,f)=d-a-b-c+e+f f2(a,b,c,d,e,f)=d+e+f-a-b-c f3(a,b,c,d,e,f)=d+e+f-(a+b+c) f1()-f2()=0 for all a,b,c,d,e,f f1()-f3()=0 for all a,b,c,d,e,f So, they're all duplicates and you may output only one of them. -------- answer posted by xs0 |
![]() |
| Viewing: Codewalkers Forums > PHP Contests > Older Contests > [numbers] Negation vs substraction |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|