Created
December 20, 2016 10:32
-
-
Save robbestad/ec7ae48baceab828e90c2758abee1132 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
namespace ConsoleApplication | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
var bestProduct = 0L; | |
for (var i = 0; i < 0x1 << 10; i++) | |
{ | |
var left = long.Parse("0" + string.Join("", Enumerable.Range(0, 10).Where(x => (i & (0x1 << x)) > 0).OrderByDescending(x => x))); | |
var right = long.Parse("0" + string.Join("", Enumerable.Range(0, 10).Where(x => (i & (0x1 << x)) == 0).OrderByDescending(x => x))); | |
if (left*right > bestProduct) | |
{ | |
bestProduct = left*right; | |
} | |
} | |
Console.WriteLine(bestProduct); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment