• Katy Gaga (unregistered) in reply to Nagesh
    Nagesh:
    Nagesh (fake):
    Roman numeral system is being flawed system. The West can be thanking Indian for invention of modurn numerals.

    Fake nagesh has stole words from my key-board. It is "modern numbers", you idiot.

    Also Alegbra invented here.

    Also, keyboard isn't hyphenated.

  • vereor (unregistered) in reply to the beholder
    the beholder:
    the beholder:
    Nobody commented yet, but this new-hire MUST have typed Every. Single. Number. In roman numbers.

    That's not exactly an easy thing to do unless there's a feature in Excel that I'm not aware of.

    +1 for dedication -100 for stupidity

    There is such a function indeed. He just lost that hard-earned +1

    Give him +1 for figuring out how to do that in Excel (unless it's automatic, where you type "I" in the first box and all other values increment by dragging).

  • (cs) in reply to tundog

    Tokenize on (IV, IX, I, XL, XC, X, CD, CM, C, M), map to (4, 9, 1, 40, 90, 10, 400, 900, 100, 1000), and sum.

    Actual code is left as an exercise for the reader.

  • (cs) in reply to tundog
    tundog:
    Clearly this problem is screaming for a Perl REGEX!
    Why even use a regex? Larry Wall's corollary to Rule 34 states that "If it exists, there is a perl module for it."
    #!/usr/bin/perl
    use Roman;
    $roman = roman($arabic);
    There you go.

    Of course EMACS users would just use M-x roman-numerals-mode, but that's another story.

  • (cs)

    What the hell is it with people and having to return "error codes" from everything? THIS ISN'T VB6. There are sophisticated error handling in modern languages, you don't need to return ints or bools all over the place.

  • Jay (unregistered) in reply to Anon
    Anon:
    TRWTF is this assignment, since there is no single standard for Roman numerals.

    You must be a barrel of laughs in a requirements meeting.

    Customer: We need to display the number of days between any two given dates.

    Anon: That's impossible. Some months have a different number of days from other months. And the number of days in each month can change: What about leap year? And historically, countries switched from the Julian to the Gregorian calendars at different times.

    Surely the obvious reply is: "The problem is not trivially simple" and/or "The problem as stated has some ambiguitites" is not the same as "The problem is impossible". In this case, we would either agree up front on our definition of how Roman numerals are to be parsed, or if we really wanted to be thorough, we could include some setting or parameter to specify which variation we want. This is hardly a ground-breaking idea. We regularly deal with different date and number formats. Why not different Roman numeral formats?

  • Cap'n Spanky (unregistered) in reply to briverymouse
    Roman Enumeration:
    PedanticCurmudgeon:
    iToad:
    Mere mortals such as us are simply not qualified to tell the difference between god-mode Haskell and WTF Haskell.
    Some would say that there is no difference.
    The average Haskell WTF is something about a guy who, during an interview, forgot to make his Monad an Applicative. Can you imagine such foolishness? Also, missing a perfectly good opportunity to use a zipWith or a liftM is cause for certain derision.
    I heard that Hitler was a monad.
  • (cs) in reply to Meep
    Meep:
    PedanticCurmudgeon:
    Peyote `Simon` Joints:
    One line in Haskell.
    I think you're bluffing. Code or it didn't happen.

    rom 'I' = 1 rom 'V' = 5 rom 'X' = 10 ...

    All of which can be translated into a single case statement, rom x = case x of { 'I' -> 1; 'V' -> 5; 'X' -> 10 ... }

    Since a string is simply a list of characters:

    raw_decode nums = map rom nums

    Or as a comprehension: raw_decode nums = [ rom num | num <- nums ]

    So raw_decode "IXX" yields [1, 10, 10]

    Next we want to group up all the IX type cases. Our numerals should always be in descending order, except for those cases, so we can simply group using the < operator.

    rollup_prefixes raw = groupBy (<) raw

    That gives us a list of lists that may be one or two elements long, by our invariants.

    sub_prefix [ num ] = num sub_prefix [ pre num ] = num - pre

    Or as a case statement:

    sub_prefix roll = case roll of { [ num ] -> num; [ pre num ] -> num - pre; }

    And we then map that out:

    sub_prefixes rolled_up = map sub_prefix rolled_up

    Then we simply sum the result:

    final subbed = sum subbed

    Put it all together:

    rom2num roman = sum [ case roll of { [ num ] -> num; [ pre num ] -> num - pre; } | roll <- groupBy (<) [ case num of { 'I' -> 1; 'V' -> 2; ... } | letter <- roman ] ]

    Actually, I was hoping for something in point-free style, but this works too.

  • (cs) in reply to the beholder
    the beholder:
    Nobody commented yet, but this new-hire MUST have typed Every. Single. Number. In roman numbers.
    Uh, yeah. Nobody's commented on this because it's implicitly stated right in the article:
    // // Snipped LOTS of "code" here //
    This is, in fact, the entire focus of the WTFery of his solution.
  • (cs) in reply to briverymouse
    briverymouse:
    PedanticCurmudgeon:
    iToad:
    Mere mortals such as us are simply not qualified to tell the difference between god-mode Haskell and WTF Haskell.
    Some would say that there is no difference.

    The average Haskell WTF is something about a guy who, during an interview, forgot to make his Monad an Applicative. Can you imagine such foolishness? Also, missing a perfectly good opportunity to use a zipWith or a liftM is cause for certain derision.

    Actually, I'd be more inclined to laugh at someone who did:

    upcaseLine = do
      str <- getLine
      return $ map toUpper str
    instead of:
    upcaseLine = fmap (map toUpper) getLine
    
  • link87 (unregistered) in reply to Cap'n Spanky
    Roman Enumeration:
    I heard that Hitler was a monad.
    The important question remains: was Hitler also a burrito?
  • qbolec (unregistered) in reply to the beholder
    the beholder:
    Nobody commented yet, but this new-hire MUST have typed Every. Single. Number. In roman numbers.

    That's not exactly an easy thing to do unless there's a feature in Excel that I'm not aware of.

    +1 for dedication -100 for stupidity

    I bet he did not write it by hand. Instead he generated code using already implemented function:

    public string num2rom(string n)
    {
        if (n == "1") return "I";
        if (n == "2") return "II";
        if (n == "3") return "III";
        if (n == "4") return "IV";
        if (n == "5") return "V";
        if (n == "6") return "VI";
        if (n == "7") return "VII";
        if (n == "8") return "VIII";
        if (n == "9") return "IX";
        //
        // Snipped LOTS of "code" here
        //
        if (n == "2008") return "MMVIII";
        if (n == "2009") return "MMIX";
        if (n == "2010") return "MMX";
        if (n == "2011") return "MMXI";
        return "E";
    }
    

    ...and to those curious: I did not write the above function by hand neither -- I used his rom2num to generate mine.

  • (cs) in reply to Nagesh
    Nagesh:
    Roman numeral system is being flawed system. The West can be thanking Indian for invention of modurn numerals.

    ...last time i checked the "modern numerals" were called "arabic" ;)

  • qbolec (unregistered)

    As the author of the article wisely suggested with the comment about >>lots of "code"<<, the real WTF is not separating code and data apropriately.

    The data as this should be stored in an editable database relation:

    CREATE TABLE num_rom(
      num TEXT PRIMARY KEY,
      rom TEXT UNIQUE KEY
    );
    

    and then accessed with a simple SQL query:

    SELECT rom 
    FROM num_rom
    WHERE num = :num
    

    Of course in a real life application would add a caching proxy layer, and/or store the database in a ROM (as the name of the function suggests).

  • behold me! (unregistered) in reply to Zylon
    Zylon:
    the beholder:
    Nobody commented yet, but this new-hire MUST have typed Every. Single. Number. In roman numbers.
    Uh, yeah. Nobody's commented on this because it's implicitly stated right in the article:
    // // Snipped LOTS of "code" here //
    This is, in fact, the entire focus of the WTFery of his solution.
    YHBT YHL FOAD
  • RJ (unregistered) in reply to Zolo
    Zolo:
    r = { "I" : 1, "V" : 5, "X" : 10, "L" : 50, "C" : 100, "D" : 500, "M" : 1000 }

    No real magic going on b/c this is "Haskell". It'd be 1 line of perl or any language w/ recursion. The string as a hash key helps ... which supports that it'd be 1 line in perl too.

  • jgibson (unregistered)
    <?php function roman2dec($strRoman) { $intSum = 0; $arrStrRoman = str_split(strtoupper($strRoman)); $arrErrors = array(); $arrRomanValues = array('I' => 1,'V' => 5,'X' => 10,'L' => 50,'C' => 100,'D' => 500,'M' => 1000); for($i = 0; $i < strlen($strRoman); $i++) { if(array_key_exists($arrStrRoman[$i], $arrRomanValues)) { if($i != (strlen($strRoman) - 1) && strlen($strRoman) != 1) { if($arrRomanValues[$arrStrRoman[$i]] >= $arrRomanValues[$arrStrRoman[$i + 1]]) { $intSum += $arrRomanValues[$arrStrRoman[$i]]; }else{ $intSum += ($arrRomanValues[$arrStrRoman[$i + 1]] - $arrRomanValues[$arrStrRoman[$i]]); $i++; } }else{ $intSum += $arrRomanValues[$arrStrRoman[$i]]; } }else{ $arrErrors[$i] = $arrStrRoman[$i] . ' is an invalid Roman Numeral'; } } if(count($arrErrors) > 0) { return $arrErrors; } return $intSum; } //not outputting errors right now, just values echo roman2dec('MDCCCCX'); //1910 echo '
    '; echo roman2dec('MMVI'); //2006 echo '
    '; echo roman2dec('MCMLIV'); //1954 echo '
    '; echo roman2dec('MCMXC'); //1990 echo '
    '; echo roman2dec('IV'); //4 echo '
    '; echo roman2dec('V'); //5 echo '
    '; echo roman2dec('MCMXLIV'); //1944 echo '
    '; echo roman2dec(''); //0 echo '
    ';
  • (cs) in reply to RJ
    RJ:
    Zolo:
    r = { "I" : 1, "V" : 5, "X" : 10, "L" : 50, "C" : 100, "D" : 500, "M" : 1000 }

    No real magic going on b/c this is "Haskell". It'd be 1 line of perl or any language w/ recursion. The string as a hash key helps ... which supports that it'd be 1 line in perl too.

    "Haskell", officially the new name for Python.

  • the beholder (unregistered) in reply to CarnivorousHippie
    CarnivorousHippie:
    Tokenize on (IV, IX, I, XL, XC, X, CD, CM, C, M), map to (4, 9, 1, 40, 90, 10, 400, 900, 100, 1000), and sum.

    Actual code is left as an exercise for the reader.

    I really like your approach, but what's wrong with V, L and D?

  • (cs)

    Somewhat serious followup: Give me a regex that will match only movie titles that end in Roman numerals. Take into account that sometimes there will be a secondary title, as in "Death Warriors IV: the Deaths Continue".

    I tried to do this a few years ago on IMDb to figure out what the highest numbered "sequel" was. Ran into the problem that "mi", "di", "xi" and others are actual words in some languages.

  • Bob C. Cock (unregistered) in reply to P. Almonius

    prmivm

    FTFY

  • the beholder (unregistered) in reply to vereor
    vereor:
    the beholder:
    the beholder:
    Nobody commented yet, but this new-hire MUST have typed Every. Single. Number. In roman numbers.

    That's not exactly an easy thing to do unless there's a feature in Excel that I'm not aware of.

    +I for dedication -C for stupidity (FTFM)

    There is such a function indeed. He just lost that hard-earned +I

    Give him +I for figuring out how to do that in Excel (unless it's automatic, where you type "I" in the first box and all other values increment by dragging).

    It isn't (at least in my version), but all it takes is stumbling on a function named ROMAN after pressing equals. Hardly worth +I

  • Nagesh (unregistered) in reply to SEMI-HYBRID code
    SEMI-HYBRID code:
    Nagesh:
    Roman numeral system is being flawed system. The West can be thanking Indian for invention of modurn numerals.

    ...last time i checked the "modern numerals" were called "arabic" ;)

    It is being irony-like turm "American English."

  • Anon (unregistered) in reply to Jay
    Jay:
    Anon: That's impossible.

    Nobody said it was impossible. Do you always put words in other people's mouths so you can argue with them?

  • Nagesh (unregistered) in reply to Nagesh
    Nagesh:
    SEMI-HYBRID code:
    Nagesh:
    Roman numeral system is being flawed system. The West can be thanking Indian for invention of modurn numerals.

    ...last time i checked the "modern numerals" were called "arabic" ;)

    It is being irony-like turm "American English."
    Also, Times new Roman font developd by Germans.

  • Not provided. (unregistered) in reply to Loren Pechtel

    Nah, first he wrote a decimal to roman converter.

  • Anon (unregistered) in reply to SEMI-HYBRID code
    SEMI-HYBRID code:
    Nagesh:
    Roman numeral system is being flawed system. The West can be thanking Indian for invention of modurn numerals.

    ...last time i checked the "modern numerals" were called "arabic" ;)

    Ouch! You just tried to correct [fake] Nagesh when he is actually correct.

    While they are often called "Arabic" numerals, they are more correctly called "Indo-Arabic" numerals. In the west we call them Arabic numerals because we learnt them from Arabs who, in turn, learnt them from the Indians.

  • Brendan (unregistered) in reply to Meep
    Meep:
    rom 'I' = 1 rom 'V' = 5 rom 'X' = 10 ...

    All of which can be translated into a single case statement, rom x = case x of { 'I' -> 1; 'V' -> 5; 'X' -> 10 ... }

    Since a string is simply a list of characters:

    raw_decode nums = map rom nums

    Or as a comprehension: raw_decode nums = [ rom num | num <- nums ]

    So raw_decode "IXX" yields [1, 10, 10]

    Next we want to group up all the IX type cases. Our numerals should always be in descending order, except for those cases, so we can simply group using the < operator.

    rollup_prefixes raw = groupBy (<) raw

    That gives us a list of lists that may be one or two elements long, by our invariants.

    sub_prefix [ num ] = num sub_prefix [ pre num ] = num - pre

    Or as a case statement:

    sub_prefix roll = case roll of { [ num ] -> num; [ pre num ] -> num - pre; }

    And we then map that out:

    sub_prefixes rolled_up = map sub_prefix rolled_up

    Then we simply sum the result:

    final subbed = sum subbed

    Put it all together:

    rom2num roman = sum [ case roll of { [ num ] -> num; [ pre num ] -> num - pre; } | roll <- groupBy (<) [ case num of { 'I' -> 1; 'V' -> 2; ... } | letter <- roman ] ]

    That's about 25 lines of code (including the comments that are necessary to make Haskell readable). It would've been less typing in something like COBOL (and probably faster too, as there's no need to depend on the misuse of recursion)!

  • (cs) in reply to RandomGuy42
    RandomGuy42:
    if(r=="III") return "Pentium";
    FTFY
  • qbolec (unregistered)

    replace: "IV" => "4", "IX" => "9", "IL" => "49", "IC" => "99", "ID" => "499", "IM" => "999", //"VL","VC","VD","VM" not supported, use XLV instead... "XL" => "4", "XC" => "9", "XD" => "49", "XM" => "99", //"LD","LM" "VI" => "6", "VII" => "7", "VIII" => "8", "I" => "1", "II" => "2", "III" => "3", "V" => "5", "X" => "1", "L" => "5", "C" => "1", "D" => "5", "M" => "1",

  • Nagesh (unregistered) in reply to Anon
    Anon:
    SEMI-HYBRID code:
    Nagesh:
    Roman numeral system is being flawed system. The West can be thanking Indian for invention of modurn numerals.

    ...last time i checked the "modern numerals" were called "arabic" ;)

    Ouch! You just tried to correct [fake] Nagesh when he is actually correct.

    While they are often called "Arabic" numerals, they are more correctly called "Indo-Arabic" numerals. In the west we call them Arabic numerals because we learnt them from Arabs who, in turn, learnt them from the Indians.

    He who corects fool is not rewarded for his truble. He who corects wise man receves gift beter than golds.
  • (cs) in reply to Toodle
    Toodle:
    Code fail on IIX
    IIX is not a valid roman numeral.

    And, in Haskell, you can return the error indicator just by using the Maybe type (in a new programming language, currently codenamed "Ibtlfmm", the you can use the successor type which is the same as Haskell's Maybe just with a different name)

    The average Haskell WTF is something about a guy who, during an interview, forgot to make his Monad an Applicative.
    I often complain about same things too

    Addendum (2012-04-02 15:45): (MMMIM is a non-standard, but valid, roman numeral; IIX, however, is not even valid.)

  • Yoh (unregistered) in reply to zzo38

    That code in question did in fact fail on IX though. As will most of the examples people have shared.

  • (cs) in reply to Yoh
    Yoh:
    That code in question did in fact fail on IX though. As will most of the examples people have shared.
    My interpreter pattern suggestion would not fail.

    example here... http://www.dofactory.com/Patterns/PatternInterpreter.aspx

    This pattern also works out well for creating a sounddex generator.

  • (cs)

    TRWTF is that Roman numerals are still used in certain contexts. How fucking shit-for-brains stupid is that.

  • (cs) in reply to link87
    link87:
    Roman Enumeration:
    I heard that Hitler was a monad.
    The important question remains: was Hitler also a burrito?
    NO HITLER WAS NOT A BURRITO. Burritos are delicious and awesome. Hitler was not delicious or awesome. Do not ruin burritos for me!
  • iToad (unregistered)

    There was actually a serious (maybe) proposal to add Roman numerals to Python, but it got rejected:

    PEP 313

    Too bad. I wanted to see whether I could calculate the square root of pi, using only Roman Numerals.

  • jgibson (unregistered) in reply to Yoh

    mine certainly did not fail on IX

  • lunchTime (unregistered)

    Here's my (crummy) stab at it: (Now with input validation)

    #!~/bin/perl
    use 5.010;
    while ( <DATA> ) {
    	chomp; say 0 and next unless length;
    	
    	(/\b
    		(M+|(?=[CDXLVI]))
    		(C{1,4}|CD|DC{0,4}|CM|(?=[XLVI])|(?<=M))
    		(X{1,4}|XL|LX{0,4}|XC|(?=[VI])|(?<=[MCD]))
    		(I{1,4}|IV|VI{0,4}|IX|(?<=[MCDLX]))
    	\b/x) ? do { my $n; $n+={''=>0,I=>1,IV=>4,V=>5,IX=>9,X=>10,XL=>40,L=>50,XC=>90,C=>100,CD=>400,D=>500,CM=>900,M=>1000}->{uc $_} foreach split /(IV|IX|XL|XC|CD|CM|I|V|X|L|C|D|M)\s*/; say $n;}: say "[$_] does not appear to be a valid Roman numeral";
    }
    __DATA__
    
    MM
    VIIX
    VIIII
    IV
    IX
    IL
    IC
    ID
    IM
    VL
    VC
    VD
    VM
    XLV
    XL
    XC
    XD
    XM
    LD
    LM
    VI
    VII
    VIII
    I
    II
    III
    V
    X
    L
    C
    D
    M
    

    PRINTS:

    0
    2000
    [VIIX] does not appear to be a valid Roman numeral
    9
    4
    9
    [IL] does not appear to be a valid Roman numeral
    [IC] does not appear to be a valid Roman numeral
    [ID] does not appear to be a valid Roman numeral
    [IM] does not appear to be a valid Roman numeral
    [VL] does not appear to be a valid Roman numeral
    [VC] does not appear to be a valid Roman numeral
    [VD] does not appear to be a valid Roman numeral
    [VM] does not appear to be a valid Roman numeral
    45
    40
    90
    [XD] does not appear to be a valid Roman numeral
    [XM] does not appear to be a valid Roman numeral
    [LD] does not appear to be a valid Roman numeral
    [LM] does not appear to be a valid Roman numeral
    6
    7
    8
    1
    2
    3
    5
    10
    50
    100
    500
    1000
    
  • (cs) in reply to iToad
    iToad:
    There was actually a serious (maybe) proposal to add Roman numerals to Python, but it got rejected:

    PEP 313

    Too bad. I wanted to see whether I could calculate the square root of pi, using only Roman Numerals.

    This will get you started CD/CXXVII = PI

  • radarbob (unregistered) in reply to Ol' Bob
    Ol' Bob:
    Nagesh:
    Nagesh (fake):
    Roman numeral system is being flawed system. The West can be thanking Indian for invention of modurn numerals.

    Fake nagesh has stole words from my key-board. It is "modern numbers", you idiot.

    Also Alegbra invented here.

    Who's this Aleg chick? And what're you doin' inventin' underwear for her?

    Don't laf. There is such a thing as Feminist Algebra. Yes, it's moronic, but is a real-life kolluge kourse.

  • radarbob (unregistered) in reply to Nagesh
    Nagesh:
    Anon:
    SEMI-HYBRID code:
    Nagesh:
    Roman numeral system is being flawed system. The West can be thanking Indian for invention of modurn numerals.

    ...last time i checked the "modern numerals" were called "arabic" ;)

    Ouch! You just tried to correct [fake] Nagesh when he is actually correct.

    While they are often called "Arabic" numerals, they are more correctly called "Indo-Arabic" numerals. In the west we call them Arabic numerals because we learnt them from Arabs who, in turn, learnt them from the Indians.

    He who corects fool is not rewarded for his truble. He who corects wise man receves gift beter than golds.

    BFD. The copyright expired centuries ago. And, as we say in non-static, loosely typed societies (a little computer language lingo as societal commentary there), "yeah? so what have you done for me lately?"

  • Romanes eunt domus (unregistered)

    I guess his solution to the first exercise was this:

    printf( "99 bottles of beer on the wall, 99 bottles of beer.\nTake one down and pass it around, 98 bottles of beer on the wall.\n" "98 bottles of beer on the wall, 98 bottles of beer.\nTake one down and pass it around, 97 bottles of beer on the wall.\n" "97 bottles of beer on the wall, 97 bottles of beer.\nTake one down and pass it around, 96 bottles of beer on the wall.\n" "96 bottles of beer on the wall, 96 bottles of beer.\nTake one down and pass it around, 95 bottles of beer on the wall.\n" "95 bottles of beer on the wall, 95 bottles of beer.\nTake one down and pass it around, 94 bottles of beer on the wall.\n" "94 bottles of beer on the wall, 94 bottles of beer.\nTake one down and pass it around, 93 bottles of beer on the wall.\n" /* SNIP 92 lines */ "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n" "1 bottle of beer on the wall, 1 bottle of beer.\nTake one down and pass it around, no more bottles of beer on the wall.\n" "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n");

  • (cs) in reply to KattMan
    KattMan:
    iToad:
    There was actually a serious (maybe) proposal to add Roman numerals to Python, but it got rejected:

    PEP 313

    Too bad. I wanted to see whether I could calculate the square root of pi, using only Roman Numerals.

    This will get you started CD/CXXVII = PI

    I. P is not a roman numeral. II. Roman numerals didn't have decimal points. III. The longer roman numerals get the more digits near the beginning get changed until you just have a bunch of M's to count your thousands with. Thats why it (should have) died with the romans.

  • (cs) in reply to Romanes eunt domus
    Romanes eunt domus:
    I guess his solution to the first exercise was this:

    printf( "99 bottles of beer on the wall, 99 bottles of beer.\nTake one down and pass it around, 98 bottles of beer on the wall.\n" "98 bottles of beer on the wall, 98 bottles of beer.\nTake one down and pass it around, 97 bottles of beer

    Really? In this thread?

    Why not:

    Romanes eunt domus:
    I guess his solution to the first exercise was this:

    printf( "XCIX bottles of beer on the wall, XCIX bottles of beer.\nTake one down and pass it around, XCVIII bottles of beer on the wall.\n" "XCVIII bottles of beer on the wall, XCVIII bottles of beer.\nTake one down and pass it around, XCVII bottles of beer on the wall.\n" etc.

  • geoffrey, MCP, PMP (unregistered)

    The company's hiring practices alone could be its own article.

  • (cs) in reply to radarbob
    radarbob:
    Ol' Bob:
    Nagesh:
    Nagesh (fake):
    Roman numeral system is being flawed system. The West can be thanking Indian for invention of modurn numerals.

    Fake nagesh has stole words from my key-board. It is "modern numbers", you idiot.

    Also Alegbra invented here.

    Who's this Aleg chick? And what're you doin' inventin' underwear for her?

    Don't laf. There is such a thing as Feminist Algebra. Yes, it's moronic, but is a real-life kolluge kourse.

    Bleedinell. You ain't wrong:

    http://www.sydneyline.com/Gross%20and%20Levitt%20review.htm

    "There was actually a paper read at a 1993 meeting of the Mathematical Association of America entitled 'Toward a Feminist Algebra' by Maryanne Campbell (a literary critic) and Randall K. Campbell-Wright (a mathematician).

    Part of the paper was a call for an end to what it claimed were sexist stereotypes in college algebra textbooks. They disapproved of problems which used examples of a girl and her boyfriend running towards each other because this portrayed heterosexual involvement. On the other hand, they recommended approval of problems about Sue and Debbie, 'a couple financing their $70,000 home'. They wanted algebra problems to present female heroes, to analyse sex differences and to affirm women's experiences.

    Taking to heart the absurd shibboleth of contemporary literary theory that all language is metaphor, Campbell and Campbell-Wright set out to prove that metaphor plays a central role in the language of mathematics. They do not demonstrate this through the obviously rather difficult cases of symbolic statements and formulae. Instead they offer verbal examples culled from textbooks -- 'manipulate an algebraic expression', 'attack a problem', 'exploit a theorem' -- as evidence that mathematics is a nest of aggression, violence, domination and sexism.

    From this they derive postmodern literary dogma such as: 'Mathematics is portrayed as a woman whose nature desires to be the conquered Other.' They want the whole field of mathematics reappraised so that its imagined failings can be rectified and it can become a discipline fit for women to enter. Gross and Levitt, however, are more perceptive about their motives.

    'The purpose of the carefully tailored feminist language and imagery is not primarily to build the self-confidence of women students, but rather to convert problems and examples into parables of feminist rectitude. It is, at bottom, not different from an imaginary Christian fundamentalist pedagogy requiring that all mathematics problems illustrate biblical episodes and preach evangelical sermons.'

    ... and then I must point you towards this:

    http://stonetelling.com/issue1-sep2010/johnson-towards-a-feminist-algebra.html

    ... enjoy, you buggers.

  • Fred (unregistered) in reply to Matt Westwood
    Matt Westwood:
    ...(snip 2MiB)...

    a nest of aggression, violence, domination and sexism

    But that's what everybody wants! So what's their point?

  • (cs) in reply to the beholder
    the beholder:
    CarnivorousHippie:
    Tokenize on (IV, IX, I, XL, XC, X, CD, CM, C, M), map to (4, 9, 1, 40, 90, 10, 400, 900, 100, 1000), and sum.

    Actual code is left as an exercise for the reader.

    I really like your approach, but what's wrong with V, L and D?

    Ummm, oops.

    Public Function CalcRoman(strRN As String) As Long
        If Len(strRN) = 0 Then
            CalcRoman = 0
        ElseIf InStr(1, "iv,ix,xl,xc,cd,cm", Left(strRN, 2)) > 0 Then
            CalcRoman = Split("4,9,40,90,400,900", ",")((InStr(1, "iv,ix,xl,xc,cd,cm", Left(strRN, 2)) - 1) / 3) _
                + CalcRoman(Mid(strRN, 3))
        Else
            CalcRoman = Split("1,5,10,50,100,500,1000", ",")(InStr(1, "ivxlcdm", Left(strRN, 1)) - 1) _
                + CalcRoman(Mid(strRN, 2))
        End If
    End Function
    

    No error checking and lots of WTFery, but that's the general idea.

  • Eric (unregistered)

    Probably not "the" way to do it in c#, but it works... [code] private enum RomanNumerals { I = 1, V = 5, X = 10, L = 50, C = 100, M = 1000 }

        private int ConvertRomanToNumeric(string RomanNumeral)
        {
            // MCMLXXIIX = 1978
    
            List<char> Numerals = RomanNumeral.ToList<char>();
    
            int ConvertedNumber = 0;
            int currentNumber = 0;
            int currentMax = 0;
    
            Numerals.Reverse();
    
            foreach (char Numeral in Numerals)
            {
                RomanNumerals num = (RomanNumerals)Enum.Parse(typeof(RomanNumerals), Numeral.ToString());
                currentNumber = (int)num;
    
                if (currentNumber >= currentMax)
                {
                    ConvertedNumber += currentNumber;
                    currentMax = currentNumber;
                }
                else
                {
                    ConvertedNumber -= currentNumber;
                }
            }
            return ConvertedNumber;
        }
    

    [/code/

Leave a comment on “Roman Enumeration”

Log In or post as a guest

Replying to comment #:

« Return to Article