Share your repls and programming experiences

← Back to all posts
Wait... it's all LINQ? [C# Challenge]
Techcraft7 (6)

Yes, it's a dead meme, but why not write a simple program using ONLY LINQ?

Here I created a simple program that replaces all of the vowels in a string with a specific character.

The rules for the challenge are as follows:

  • All methods must be ONE line (INCLUDES Main())
  • You can only use LINQ for control flow (no if, else, for, etc.) Ternary operators are also not allowed (condition ? a : b)
  • You may define extension methods (they also have to be one line)
  • Lambdas cannot be blocks (no () => {x; y; z; return w;})
  • No external libraries (Only use classes built into .NET)


For fun! But don't ever write actual code like this.

Explanation of my code

  1. Store the character, its index, and if it is a vowel in a tuple
  2. Create an array with 2 copies of the IEnumerable of tuples in a tuple
    3a. For the first copy of the tuples, only get the tuples that are vowels
    3b. For the second copy of the tuples, only get the tuples that are NOT vowels
  3. Combine the two IEnumerables
  4. Sort the IEnumerable by the index we store earlier
  5. Convert to an array
  6. Pass into new string()
  7. Return new string
Bunnytoes (147)

this is pretty cool, how could you make it do words?