Last active
December 14, 2015 19:28
-
-
Save andor44/5136621 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.Linq;class p{static void Main(){System.IO.File.ReadAllLines("a.txt").Select(x=>x.Substring(0,x.TakeWhile(y=>y==' ').Count())+x.TrimStart(' ').Split(' ').Where(y=>y!="").Aggregate("",(y,w)=>(y+=w+" ")).TrimEnd(' ')).ToList().ForEach(System.Console.WriteLine);}} |
using System.Linq;class p{static void Main(){System.IO.File.ReadAllLines("a.txt").Select(w=>w.Split(' ').TakeWhile(x=>x=="").Concat(w.Split(' ').Where(x=>x!="")).Aggregate("",(x,y)=>x+=y+" ").TrimEnd(' ')).ToList().ForEach(System.Console.WriteLine)}}
mégrövidebb változat, csak 251 karakter
using System.Linq;class p{static void Main(){System.IO.File.ReadAllLines("a.txt").Select(w=>w.Split(' ').TakeWhile(x=>x=="").Concat(w.Split(' ').Where(x=>x!="")).Aggregate((x,y)=>x+=" "+y)).ToList().ForEach(System.Console.WriteLine);}}
legrövidebb változat, 236 karakter
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
javitva, igy már csak 274 karakter