![]() |
|
[.NET] String Equation Solver - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] String Equation Solver (/showthread.php?tid=5564285) |
String Equation Solver - Lucasheer - Mar 1, 2017 I wanted to post something on this website, and this is just something I made awhile back. You pass an equation to it as a string (ex: "5+-5*3-(2+2*(-422+2)*5)-51/-2", and it returns 4213.5 😉 image : htt p://i.imgur.co m/z0wbGTT.png code : htt p://pastebin.co m/4v11L7AH It is perfectly accurate, however, it is kinda inefficient. I was 15 when I coded this, well still 15, but ill be 16 tomorrow! So my birthday revolution is making more efficient code 😁 Its original purpose was for project that takes scratch.mit games/applications, and converts them into .jar and .apk executables. However, Java has string equation solving, and its a ton faster 🤣 If I had to do this again, I'd probably tackle it with a token system method, much like RPM calculators, instead of parsing strings. Have fun with the code though, and skype me at LucasHeer715, if you need any help. Sorry it wouldn't let me post picture or code, because of my amount of posts :'( * - hfTP54 - Mar 2, 2017 happy birthday :D just random text here * - Barret - Mar 2, 2017 Ahh, i like these lil things. i can help you make it perfect if you want. i got the perfect methods i wrote to do so. * - Ninja - Mar 3, 2017 ![]() Code: http://pastebin.com/4v11L7AH Anyways I suggest you do a more OOP approach, make a parser to parse the equation into segments (PEMDAS) and then solve them and use recursion to parse them again, etc. * - Lucasheer - Mar 3, 2017 I will probably go with that type of approach on my next try. I am happy with the accuracy of my equation solver, but I am not happy with the speed. It solves over 1000 times slower than compiled .net.. Thanks for uploading the pic and pastebin though! :) |