Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Comma-quibbling/C-sharp/comma-quibbling.cs
Normal file
33
Task/Comma-quibbling/C-sharp/comma-quibbling.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace CommaQuibbling
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
#region Static Members
|
||||
private static string Quibble(string[] input)
|
||||
{
|
||||
return
|
||||
String.Format("{{{0}}}",
|
||||
String.Join("",
|
||||
input.Reverse().Zip(
|
||||
new [] { "", " and " }.Concat(Enumerable.Repeat(", ", int.MaxValue)),
|
||||
(x, y) => x + y).Reverse()));
|
||||
}
|
||||
|
||||
|
||||
private static void Main()
|
||||
{
|
||||
Console.WriteLine( Quibble( new string[] {} ) );
|
||||
Console.WriteLine( Quibble( new[] {"ABC"} ) );
|
||||
Console.WriteLine( Quibble( new[] {"ABC", "DEF"} ) );
|
||||
Console.WriteLine( Quibble( new[] {"ABC", "DEF", "G", "H"} ) );
|
||||
|
||||
Console.WriteLine( "< Press Any Key >" );
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue