November 25th, 2024

C# Puzzles

Two C# programming puzzles challenge participants to modify functions for specific outputs, emphasizing string manipulation without using `Environment.Exit(0)`, suitable for C# 7 or above, with hints for unconventional solutions.

Read original articleLink Icon
C# Puzzles

The message discusses two C# programming puzzles that involve manipulating code to achieve specific output. The first puzzle, titled "Format Fun," requires the participant to modify a function called `SecretSauce` to change the output of a `StringBuilder` from "Bye Bye" to "Hello" when printed. The goal is to ensure that the program reaches the return statement of 0 without using `Environment.Exit(0)`. The second puzzle, "Double Fun," similarly involves modifying another `SecretSauce` function to make the combined output of two `StringBuilder` objects read "Hello, World!" The puzzles emphasize creativity in coding and understanding of string manipulation in C#. Hints are provided for both puzzles, suggesting that the solutions may involve unconventional methods. The puzzles are designed for C# version 7 or above and are intended for a single machine environment without unsafe code practices.

- The puzzles focus on string manipulation in C#.

- Participants must modify a function to achieve specific output.

- Solutions should not use `Environment.Exit(0)`.

- The puzzles are suitable for C# version 7 or above.

- Hints suggest unconventional coding techniques.

Link Icon 2 comments
By @evoke4908 - 5 months
The first puzzle is pretty cool, I had no idea C# can do that.

For the second, the given answer is definitely cheating. On the other hand, I definitely had no idea any of that existed. IMO it'd have been cleaner to 'simply' modify the running program instead.