Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved Best travel #2

Merged
merged 2 commits into from
Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed Best travel/.vs/Best travel/v16/.suo
Binary file not shown.
91 changes: 0 additions & 91 deletions Best travel/Best travel/Program.cs

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

8 changes: 0 additions & 8 deletions Best travel/Best travel/obj/project.nuget.cache

This file was deleted.

28 changes: 0 additions & 28 deletions Best travel/README.md

This file was deleted.

Binary file not shown.
Binary file not shown.
25 changes: 25 additions & 0 deletions Decode the Morse code/Decode the Morse code.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31424.327
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decode the Morse code", "Decode the Morse code\Decode the Morse code.csproj", "{21083589-1024-454A-A488-9BE545675638}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{21083589-1024-454A-A488-9BE545675638}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21083589-1024-454A-A488-9BE545675638}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21083589-1024-454A-A488-9BE545675638}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21083589-1024-454A-A488-9BE545675638}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {974D8CAE-774E-4D80-BB4D-26F683C70924}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>Decode_the_Morse_code</RootNamespace>
</PropertyGroup>

</Project>
47 changes: 47 additions & 0 deletions Decode the Morse code/Decode the Morse code/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace Decode_the_Morse_code
{
class MorseCodeDecoder
{
public static string Decode(string morseCode)
{
string trimmed = morseCode.Trim(new char[] { ' ' });

List<string> letters = new List<string>(); //was just string. But this "SOS" decode as 1 sym
string result = "";

Regex letterRgx = new Regex(@"([.|-])+");
Regex spaceRgx = new Regex(@"[ | ]+");

MatchCollection letterMatches = letterRgx.Matches(trimmed);
MatchCollection spaceMatches = spaceRgx.Matches(trimmed);

foreach (Match letMatch in letterMatches)
{
letters.Add(MorseCode.Get(letMatch.Value));
}

Console.WriteLine("letters=" + letters);

int ind = 0;
foreach (Match spMatch in spaceMatches)
{
result += letters[ind];
if (spMatch.Value == " ") result += " ";
Console.WriteLine(result + $" {ind} + |{spMatch.Value}|");
ind++;
}
Console.WriteLine();
for (; ind < letters.Count; ind++)
{
result += letters[ind];
Console.WriteLine(result);
}

return result;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("Decode the Morse code")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Decode the Morse code")]
[assembly: System.Reflection.AssemblyTitleAttribute("Decode the Morse code")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Создано классом WriteCodeFragment MSBuild.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2f9f97db79114d0771bfa9da1da76738415251ab
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"format": 1,
"restore": {
"C:\\Users\\WHOAMI\\Desktop\\Codewars\\Decode the Morse code\\Decode the Morse code\\Decode the Morse code.csproj": {}
},
"projects": {
"C:\\Users\\WHOAMI\\Desktop\\Codewars\\Decode the Morse code\\Decode the Morse code\\Decode the Morse code.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\WHOAMI\\Desktop\\Codewars\\Decode the Morse code\\Decode the Morse code\\Decode the Morse code.csproj",
"projectName": "Decode the Morse code",
"projectPath": "C:\\Users\\WHOAMI\\Desktop\\Codewars\\Decode the Morse code\\Decode the Morse code\\Decode the Morse code.csproj",
"packagesPath": "C:\\Users\\WHOAMI\\.nuget\\packages\\",
"outputPath": "C:\\Users\\WHOAMI\\Desktop\\Codewars\\Decode the Morse code\\Decode the Morse code\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\"
],
"configFilePaths": [
"C:\\Users\\WHOAMI\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Xamarin.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp3.1"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.1": {
"targetAlias": "netcoreapp3.1",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"targetAlias": "netcoreapp3.1",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.301\\RuntimeIdentifierGraph.json"
}
}
}
}
}
Loading