Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Latest commit

 

History

History

Wire Ends

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

This is a challenge developed for the C# discord server.
Want to Participate? Join the C# discord:

Wire Ends

You are writing a software that allows users to design electrical circuits. You need to add a feature that will count the number of loose wire ends in the current design. The wire layout data is currently stored in a string with the characters , , , , , , , , , , , , and \n. The \n character represents the end of the current horizontal dimension, the ' ' character represents a coordinate with no wires, and the rest ║ ╠ ╩ ╦ ═ ╬ ╣ ╚ ╝ ╔ ╗ represent various wire configurations.

Sample input

string input =
    "╔══╗\n" +
    "║╚╝║\n" +
    "║╔╗║\n" +
    "╚══╝";
// contains 4 disconnected wire ends
string input =
    "║╔╗║\n" +
    "║║║║\n" +
    "║║║║\n" +
    "╚╝╚╝";
// contains 2 disconnected wire ends
string input =
    " ╔╗\n" +
    "╔╝╚═╗\n" +
    "╚╗  ╚═╗\n" +
    " ╚════╝";
// contains 0 disconnected wire ends

Quick start

public int CountWireEnds(string s)
{
    string chars = "║╠╩╦═╬╣╚╝╔╗ \n";

    // -----------------------
    // complete challenge here
    // -----------------------
}

Unit tests are included here: WireEndsTests.cs

Challenge Yourself

After you successfully complete the challenge, consider challenging yourself further...

  • golf: minimize the source code for the solution as much as possible while keeping it fully functional
  • optimization: optimize your solution as much as possible using Benchmark.NET

Feedback

If you have any feedback on this challenge, please open an issue on this repository, mention this challenge, and ping the contributor(s) of this challenge.

Contributor(s)

Source

This was an original challege. :)


Discord meta data. Do not edit. This is used for GitHub => Discord linking.

Name Wire Ends Challenge
Description You are writing a software that allows users to design electrical circuits. You need to add a feature that will count the number of loose wire ends in the current design. The wire layout data is currently stored in a `string` with the characters ` `, `║`, `╠`, `╩`, `╦`, `═`, `╬`, `╣`, `╚`, `╝`, `╔`, `╗`, and `\n`. The `\n` character represents the end of the current horizontal dimension, the `' '` character represents a coordinate with no wires, and the rest `║ ╠ ╩ ╦ ═ ╬ ╣ ╚ ╝ ╔ ╗` represent various wire configurations.
Sample
string input =
"╔══╗\n" +
"║╚╝║\n" +
"║╔╗║\n" +
"╚══╝";
// contains 4 disconnected wire ends
string input =
    "║╔╗║\n" +
    "║║║║\n" +
    "║║║║\n" +
    "╚╝╚╝";
// contains 2 disconnected wire ends
Contributed by 438382611929366537
Self link https://github.com/discord-csharp/challenges/tree/main/src/Wire%20Ends