• FP Programmers Algorithmic Problems Thread
    33 replies, posted
[QUOTE=DeadKiller987;34620041]I can't do this one, so hopefully some of you find it hard: You get a number like 5132 and you need to make it into a valid equation like 5+1=3*2 You can't move the digits around, just add /*-+ and 1 = between them. Ignore the * and / priority over + and -. This needs to be done simply left to right. Examples: 2715534 2*7*1+5=5*3+4 12345678987654321 1*2+3*4-5*6-7+8+9=8*7+6-5-4-3*2*1 Good luck. I have no idea how to code the solution and the booklet I got it from doesn't tell me.[/QUOTE] What are the limitations on the characters?
[QUOTE=Darwin226;34676913]What are the limitations on the characters?[/QUOTE] Do you mean the /*-+=? There's only 1 = sign. Division and multiplication don't have priority over addition and subtraction. It has to be a valid equation. That's pretty much it.
[QUOTE=DeadKiller987;34678025]Do you mean the /*-+=? There's only 1 = sign. Division and multiplication don't have priority over addition and subtraction. It has to be a valid equation. That's pretty much it.[/QUOTE] Although making one that needs to handle parenthesis and order of operation would be much more awesome. Maybe even support for leaving out an operator to merge multiple digits into one bigger number. I remember solving such math problems in lower grades.
[QUOTE=DeadKiller987;34678025]Do you mean the /*-+=? There's only 1 = sign. Division and multiplication don't have priority over addition and subtraction. It has to be a valid equation. That's pretty much it.[/QUOTE] No, I mean what are the limitations on the number of digits. Also, what should 1/2 evaluate to?
Sorry, you need to Log In to post a reply to this thread.