Page 1 of 1

Code is being modified when I post it

Posted: Tue Mar 25, 2008 12:27 pm
by perito
I solved problem 15 using Java coding and I posted my code, and I was reviewing it to compare it with other answers and my code was modified...
it seems its remove consecutive [][] which mean 2-dimensional array in Java
I removed the [ CODE ] tags but it still did the same thing :S
this is my original code

*************************************
if (i==1) path[j]=i;
else if (i==paths/2) path[j]=2*path[j][i-1];
else path[j]= path[j][i-1] + path[j-1];
finalPath=j;
}
}
for(int i=1;i<43;i++)
routes+=path[finalPath];
*************************************

this is what its changing to

*************************************
if (i==1) path[j]=i;
else if (i==paths/2) path[j]=2*path[j][i-1];
else path[j]= path[j][i-1] + path[j-1];
finalPath=j;
}
}
for(int i=1;i<43;i++)
routes+=path[finalPath];
*************************************

Re: Code is being modified when I post it

Posted: Tue Mar 25, 2008 12:51 pm
by euler
The problem is that is being interpreted as a BBCode for italics. Other variables to watch out for are = bold, [r] = red, [g] = green. You can see all the custom tags here: http://projecteuler.net/forum_tags.htm.

Re: Code is being modified when I post it

Posted: Tue Mar 25, 2008 3:25 pm
by perito
can I turn it off somehow?
or should I never use the varaible i again :?

Re: Code is being modified when I post it

Posted: Tue Mar 25, 2008 3:29 pm
by daniel.is.fischer
You could choose other variables for array indexing (e.g. replace all open-bracket-i-close-bracket with [i1] or ) or include spaces [ i ]. Probably the former is preferable.

Re: Code is being modified when I post it

Posted: Tue Mar 25, 2008 3:39 pm
by euler
This does all raise the more general question, Do we need formatting tags at all? Should I remove the tags: , , [r], and [g], or should I replace them with something more explicit, like, [italic], [bold], [red], [green]?

After all, the main purpose of that forum is to discuss the method and, when necessary, post code. So do we need to italicise or embolden at all? I can see the benefits of these, and I know members have previously used red and green in their expositions. If we did change them to the more specific tag names I could do a database wide search and replace on the old tags so that those posts still view correctly.

Re: Code is being modified when I post it

Posted: Tue Mar 25, 2008 3:46 pm
by Tommy137
Isn't it possible to turn them off in between

Code: Select all

-tags?

Re: Code is being modified when I post it

Posted: Tue Mar 25, 2008 3:48 pm
by daniel.is.fischer
I think having a means for adding emphasis is good. Make that [italics] by all means, 'italics' is very unlikely to be an array index 8-)

Re: Code is being modified when I post it

Posted: Tue Mar 25, 2008 4:25 pm
by euler
That was a nightmare! I've fixed the problem. hk reminded me that I solved this problem once before, but could I remember? Talk about re-inventing the wheel... it was only after I figured out the problem that it all came back to me. Typical!

Anyway, the good news is that all formatting tags no longer render as formatting tags between the [ code ] tags and will appear as they are typed.