Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
project euler 18
//most interesting so far using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { List<Row> rows = new List<Row>(); var s = Console.In.ReadToEnd(); foreach(var r in s.Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)) { List<int> row = new List<int>(); r.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(f => row.Add(Convert.ToInt32(f))); rows.Add(new Row(){ Numbers = row }); } while(rows.Count() > 1) { Row last = rows[rows.Count-1]; Row before_last = rows[rows.Count-2]; Row combined = new Row() { Numbers = new List<int>() }; for(int i=0; i<before_last.Numbers.Count; i++) { int max = -1; for(int j=i; j<i+2 && j<last.Numbers.Count; j++) { if(before_last.Numbers[i]+last.Numbers[j] > max) max = before_last.Numbers[i]+last.Numbers[j]; } combined.Numbers.Add(max); } rows.Remove(last); rows.Remove(before_last); rows.Add(combined); //combined.Numbers.ForEach(f => Console.Write(f+" ")); //Console.WriteLine(); } Console.WriteLine(rows[0].Numbers[0]); } } public class Row { public List<int> Numbers {get; set;} } }
run
|
edit
|
history
|
help
0
Sealed
string concat
Download a UTF-8 text file, and display the contents.
Reflection constructors
Watch Jurassic World Dominion Online Free
cSS
Length
Download a .NET assembly, and execute a static, parameterless method.
Error
group by