Skip to content

Instantly share code, notes, and snippets.

@andor44
Last active December 14, 2015 19:28
Show Gist options
  • Save andor44/5136621 to your computer and use it in GitHub Desktop.
Save andor44/5136621 to your computer and use it in GitHub Desktop.
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);}}
@andor44
Copy link
Author

andor44 commented Mar 11, 2013

javitva, igy már csak 274 karakter

@andor44
Copy link
Author

andor44 commented Mar 11, 2013

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

@andor44
Copy link
Author

andor44 commented Mar 11, 2013

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