Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
N

nrkn

@nrkn
About
Posts
6
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Coding Challenge Of The Day
    N nrkn

    Better:

    static int RomanToInt( string roman ) {
    return roman
    .ToLower()
    .Select(
    n =>
    new Dictionary {
    {'i', 1},
    {'v', 5},
    {'x', 10},
    {'l', 50},
    {'c', 100},
    {'d', 500},
    {'m', 1000},
    }[ n ]
    )
    .Aggregate(
    new[] {0, 0, 0},
    ( c, d ) =>
    new[] {
    c[ 0 ] + ( d > c[ 2 ] ? d - c[ 1 ] : c[ 1 ] ),
    d > c[ 2 ] ? 0 : d,
    d
    }
    )
    .Take( 2 )
    .Sum();
    }

    The Lounge c++ architecture

  • Coding Challenge Of The Day
    N nrkn

    Hideous C# one-liner* with whitespace added to ahahahaha enhance readability.

    static double RomanToInt( string roman ) {
    return (
    Enumerable.Range( 0, 3 )
    .Select(
    i =>
    ( i + 1 ) * 2 - 2
    )
    .Aggregate(
    roman.ToLower(),
    ( current, i ) =>
    current
    .Replace(
    "ivxlcdm".Substring( i, 2 ),
    new string( "ivxlcdm"[ i ], 4 )
    )
    .Replace(
    "ivxlcdm"[ i ].ToString() + "ivxlcdm"[ i + 2 ].ToString(),
    "ivxlcdm"[ i + 1 ].ToString() + new string( "ivxlcdm"[ i ], 4 )
    )
    )
    .Select(
    i =>
    "ivxlcdm".IndexOf( i )
    )
    .Select(
    x =>
    x % 2 == 0 ?
    Math.Pow( 10, x / 2 ) :
    Math.Pow( 10, ( x + 1 ) / 2 ) / 2
    )
    .Sum()
    );
    }

    *Not counting the function declaration - trivial to convert to a true a one-liner but you asked for a function

    The Lounge c++ architecture

  • Anyone used/using MonoTouch for ipad/iphone?
    N nrkn

    I thought you could use Visual Studio with MonoTouch too?

    The Lounge csharp ios dotnet winforms question

  • I donated to wikipedia
    N nrkn

    Great to know that there is such a great collection of helpful people here! My credit card number is 1234-5678-9012-3456 The expiration date is December 2012 The security number is 666 Thanks!

    The Lounge html css asp-net com sysadmin

  • I donated to wikipedia
    N nrkn

    I've tried to donate to Wikipedia a couple of times, but their system never accepts my credit card for some reason. Only place I've ever had trouble with it.

    The Lounge html css asp-net com sysadmin

  • Notepad Replacement
    N nrkn

    Notepad++

    The Lounge question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups