Re: Algorithms



jt wrote:
Richard Reynolds wrote:

that Roman numeral one looks like a pretty horrible algorithm at first glance, why don't you try to come up with a more elegant one for some practice? Look for general rules and exceptions to start with.

Funny, I thought it was pretty clever myself, better than anything I could come up with on my own. I was thinking about an array based solution but couldn't come up with the algorithm...


There are two things I don't like about that algorithm:

1. Too many magic constants. That is partly a fault of the coding style.
The constants could have been made more meaningful.

2. Repeated code that differs only in a few constants.

Patricia
.



Relevant Pages

  • Re: Algorithms
    ... why don't you try to come up with a more elegant one for some practice? ... Look for general rules and exceptions to start with. ...
    (comp.lang.java.help)
  • Java needs "goto" (was Re: hi)
    ... This typically occurs because the reserved word "goto" isn't implemented. ... I do agree with your view that infinite loops that depend on exceptions are a bad practice. ...
    (comp.lang.java.programmer)
  • Re: Fortran Error Reporting Requirements (Was: GFORTRAN PROBLEM WITH SAVE STATEMENT)
    ... Some users claim there's a low cost to exceptions, ... there's no difference between theory and practice; ...
    (comp.lang.fortran)
  • Re: internarrage historical context
    ... am curios whether that practice was common before the Holocaust. ... Still, there were exceptions. ...
    (soc.culture.jewish.moderated)
  • Re: programming best practices
    ... >>> boolean return value. ... >> values in a language that has exceptions. ... >> elegant way of handling errors and also often code will be shorter ... I'd be curious how an exception equivalent behavior with continuations ...
    (comp.lang.ruby)