Dynamically created operators
Posted
by Gero
on Stack Overflow
See other posts from Stack Overflow
or by Gero
Published on 2008-09-20T19:43:18Z
Indexed on
2010/04/07
2:33 UTC
Read the original article
Hit count: 372
I created a program using dev-cpp and wxwidgets which solves a puzzle.
The user must fill the operations blocks and the results blocks, and the program will solve it.
Im solving it using bruteforce, i generate all non repeated 9 length number combinations using a recursive algorithm. It does it pretty fast.
Up to here all is great!
But the problem is when my program operates depending the character on the blocks. Its extremely slow (it never gets the answer), because of the chars comparation against +, -, *, etc. Im doing a CASE.
Is there some way or some programming language wich allows dinamic creation of operators? So i can define the operator ROW1COL2 to be a +, and the same way to all other operations.
I leave a screenshot of the app, so its easier to understand how the puzzle works.
http://www.imageshare.web.id/images/9gg5cev8vyokp8rhlot9.png
PD: The algorithm works, i tryed it with a trivial puzzle, and solved it in a second.
© Stack Overflow or respective owner