Recommended Answers
Jump to PostWell I've just done it for fun, was interesting. My code is probably messy but oh well!
Show us what you have done and we can help.
Jump to PostThinking about it, I believe this might be possible in a single statement. Bonus points if you can do it...
Jump to PostOf course we cannot forget to thank the teacher or whomever of hxn xfir for providing us, bored at work, with this now fun little competition.
I need to tidy my code up a bit and rethink my logic clearly!
Jump to PostI cheated slightly...But here's a one liner :)
using System; using System.Linq; namespace OneLineTest { class Program { static void Main(string[] args) { Enumerable.Range(1,5).Select(x => new string('1', x)).Concat(Enumerable.Range(1,4).Reverse().Select(x => new string('1', x))).Select(int.Parse).ToList().ForEach(y => Console.WriteLine("{0,9}", y*y)); Console.ReadKey(); } } }
It could probably be optimised and I …
Jump to PostOkay, so the
Enumerable.Range(start, count)
generates a sequence of numbers. When you do the select on this it will perform the lambda of the select for each number in the sequence. I'm not really that interested in the number that the Enumerable outputs, that's a means to an end. …
All 33 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.