tag:blogger.com,1999:blog-889604442512373664.post1647163629050832404..comments2023-10-31T08:28:52.391-07:00Comments on Computer Programming and Magic: The Gathering: A Million Details - Part 2Forgehttp://www.blogger.com/profile/15838286606081721333noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-889604442512373664.post-80413720828796040602009-04-24T11:36:00.000-07:002009-04-24T11:36:00.000-07:00I would have written the code to remove the symbol...I would have written the code to remove the symbol characters one at a time (counting each one), leaving the numeric by itself, then it's a simple Val(string) statement.Unknownhttps://www.blogger.com/profile/15178010996656985441noreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-64764535286988632592009-04-23T11:54:00.000-07:002009-04-23T11:54:00.000-07:00"A Million Details" is literal. I guess any compu..."A Million Details" is literal. I guess any computer program has to do a million things right in order to work. And just like a car engine, a million things can go wrong.<br /><br />The code doesn't work with "10". I fixed it by adding an "if" somewhere (I forget where). It just goes to show you that parsing (reading from text) is hard.Forgehttps://www.blogger.com/profile/15838286606081721333noreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-4167016333107916312009-04-22T18:26:00.000-07:002009-04-22T18:26:00.000-07:00Not counting the IndexOutOfBounds exception that g...Not counting the IndexOutOfBounds exception that grendel mentions might happen, all the examples will have a trailing space.<br /><br />This goes to show that the title "A Million Details" is literal, not figurative.rising fruitionhttps://www.blogger.com/profile/15416969205173300778noreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-10236753520461129332009-04-22T07:51:00.000-07:002009-04-22T07:51:00.000-07:00I did not execute the code in a test, but you are ...I did not execute the code in a test, but you are probably getting an IndexOutOfBoundsException on "10". You while statement attempts to find the first non-digit. In the case of "10" you do not and you are not testing for the end of the string.<br /><br />How does this routine handle hybrid symbols? I still think using a pattern matcher is a better mechanism but it depends on your output needs i.e. string vs array of strings.grendelhttp://billchristian.wordpress.comnoreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-4812234134290253762009-04-22T00:46:00.000-07:002009-04-22T00:46:00.000-07:00Just have it concat any numbers it encounters, the...Just have it concat any numbers it encounters, then cast to int - or whatever your program uses internally.<br />Numbers normally only appear in this order anyway: (X[0-9]WUBRG)<br /> A better solution that is more future-proof would be for the program to encapsulate each single mana payment in braces (like this: {10}{g}{g}). This allows cards such as the reaper king: <br />http://magiccards.info/shm/en/260.htmlAnonymousnoreply@blogger.com