If my question needs any clarification, please ask in the comments. If your answer gives a solution handling this one, that's great. Those examples did not include the : operator, as I only want to manipulate ints, and this operator adds many verifications. I'm not looking for anything language-related, but for the record, I'm thinking of implementing it in Objective-C, as that's the language I'm most working with recently. If you take that in consideration in your answer, that's great. This can be done either after the expression is generated, or during its creation. with the beginning of the algorithm, or a general structure of it.Īlso note that I will have to evaluate those expressions. If you see a good way to start, I'd appreciate a lead in the right direction, e.g. I'd like to know which way you believe is the best to go, between the solutions I considered, and your own ideas. Using a crazy "for-type" loop (surely the worst).But still, I thought of a couple solutions: I can't say I tried those ideas, because I didn't really want to waste much time going in a direction that had no chance of working in the first place. I'm not even sure a single algorithm could give me the last two. But I'm having some trouble getting started with something that could create one of the hard and harder examples. Random ints separated by random operators, nothing crazy here. The easy and medium ones are pretty straight-forward. Here are some example expressions I want to generate randomly: 4 + 2 So, I decided to give it a shot and elaborate an algorithm, before coding it to test it. I have this idea running around in my head, to generate and evaluate random mathematical expressions.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |