diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ce6fdd --- /dev/null +++ b/.gitignore @@ -0,0 +1,340 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- Backup*.rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb \ No newline at end of file diff --git a/ClassLibrary1.sln b/ClassLibrary1.sln new file mode 100644 index 0000000..c9bf342 --- /dev/null +++ b/ClassLibrary1.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29123.88 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{76EA34CC-4517-48CB-8AE2-5F9E6FE9D7BD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject1", "UnitTestProject1\UnitTestProject1.csproj", "{B8CBEE57-407C-427C-9BB3-E9CAFD0CCD14}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{56FD08E2-A5BB-4656-BF6D-F3E6D933264A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {76EA34CC-4517-48CB-8AE2-5F9E6FE9D7BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {76EA34CC-4517-48CB-8AE2-5F9E6FE9D7BD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {76EA34CC-4517-48CB-8AE2-5F9E6FE9D7BD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {76EA34CC-4517-48CB-8AE2-5F9E6FE9D7BD}.Release|Any CPU.Build.0 = Release|Any CPU + {B8CBEE57-407C-427C-9BB3-E9CAFD0CCD14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B8CBEE57-407C-427C-9BB3-E9CAFD0CCD14}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B8CBEE57-407C-427C-9BB3-E9CAFD0CCD14}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B8CBEE57-407C-427C-9BB3-E9CAFD0CCD14}.Release|Any CPU.Build.0 = Release|Any CPU + {56FD08E2-A5BB-4656-BF6D-F3E6D933264A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {56FD08E2-A5BB-4656-BF6D-F3E6D933264A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {56FD08E2-A5BB-4656-BF6D-F3E6D933264A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {56FD08E2-A5BB-4656-BF6D-F3E6D933264A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {30D52BE8-3591-4A8D-9CE4-E22439A9F287} + EndGlobalSection +EndGlobal diff --git a/ClassLibrary1/ClassLibrary1.csproj b/ClassLibrary1/ClassLibrary1.csproj new file mode 100644 index 0000000..9f5c4f4 --- /dev/null +++ b/ClassLibrary1/ClassLibrary1.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/ClassLibrary1/Generator.cs b/ClassLibrary1/Generator.cs new file mode 100644 index 0000000..ccbb58f --- /dev/null +++ b/ClassLibrary1/Generator.cs @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; + +namespace ClassLibrary1 +{ + public class Generator + { + public Dictionary values; + + public Generator() + { + values = new Dictionary() { + {'A', new Letter("A", 0, 5) }, + {'B', new Letter("B", 1, 5) }, + {'C', new Letter("C", 2, 5) }, + {'D', new Letter("D", 3, 5) }, + {'E', new Letter("E", 4, 5) }, + {'F', new Letter("F", 5, 5) }, + + {'G', new Letter("G", 0, 4) }, + {'H', new Letter("H", 1, 4) }, + {'I', new Letter("I", 2, 4) }, + {'J', new Letter("J", 3, 4) }, + {'K', new Letter("K", 4, 4) }, + {'L', new Letter("L", 5, 4) }, + + {'M', new Letter("M", 0, 3) }, + {'N', new Letter("N", 1, 3) }, + {'O', new Letter("O", 2, 3) }, + {'P', new Letter("P", 3, 3) }, + {'Q', new Letter("Q", 4, 3) }, + {'R', new Letter("R", 5, 3) }, + + {'S', new Letter("S", 0, 2) }, + {'T', new Letter("T", 1, 2) }, + {'U', new Letter("U", 2, 2) }, + {'V', new Letter("V", 3, 2) }, + {'W', new Letter("W", 4, 2) }, + {'X', new Letter("X", 5, 2) }, + + {'Y', new Letter("Y", 0, 1) }, + {'Z', new Letter("Z", 1, 1) }, + {'1', new Letter("1", 2, 1) }, + {'2', new Letter("2", 3, 1) }, + {'3', new Letter("3", 4, 1) }, + {'4', new Letter("4", 5, 1) }, + + {'5', new Letter("5", 0, 0) }, + {'6', new Letter("6", 1, 0) }, + {'7', new Letter("7", 2, 0) }, + {'8', new Letter("8", 3, 0) }, + {'9', new Letter("9", 4, 0) }, + {'0', new Letter("0", 5, 0) }, + }; + } + + public string generate(String title) + { + title = title.Trim().ToUpper(); + int currentX = 0; + int currentY = 5; + List outputArray = new List(); + + foreach(Char c in title.ToCharArray()) { + + if (c == ' ') + { + Debug.WriteLine("Looking for: ' '."); + outputArray.Add('S'); + } + else + { + Debug.WriteLine("Looking for: '" + c + "'."); + Letter _letter = values[c]; + char[] yOffets = getYoffset(_letter, currentY); + char[] xOffsets = getXoffset(_letter, currentX); + outputArray.AddRange(yOffets); + outputArray.AddRange(xOffsets); + outputArray.Add('#'); + + currentX = _letter.x; + currentY = _letter.y; + } + } + + return String.Join(",", outputArray); + } + + private char[] getXoffset(Letter letter, int currentX) + { + if (letter.x < currentX) + { + char[] c = new char[currentX - letter.x]; + for (int i = 0; i < currentX - letter.x; i++) + { + c[i] = 'L'; + } + return c; + } + else if (letter.x > currentX) + { + char[] c = new char[letter.x - currentX]; + for (int i = 0; i < letter.x - currentX; i++) + { + c[i] = 'R'; + } + return c; + } + else + { + // letter.x == currentX + return new char[0]; + } + } + + private char[] getYoffset(Letter letter, int currentY) + { + if (letter.y < currentY) + { + char[] c = new char[currentY - letter.y]; + for (int i = 0; i < currentY - letter.y; i++) + { + c[i] = 'D'; + } + return c; + } + else if (letter.y > currentY) + { + char[] c = new char[letter.y - currentY]; + for (int i = 0; i < letter.y - currentY; i++) + { + c[i] = 'U'; + } + return c; + } + else + { + // letter.y == currentY + return new char[0]; + } + } + } +} diff --git a/ClassLibrary1/Letter.cs b/ClassLibrary1/Letter.cs new file mode 100644 index 0000000..640756e --- /dev/null +++ b/ClassLibrary1/Letter.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ClassLibrary1 +{ + public class Letter + { + public Letter(String character, int x, int y) + { + this.character = character; + this.x = x; + this.y = y; + } + public string character { get; set; } + public int x { get; set; } + public int y { get; set; } + } +} diff --git a/ConsoleApp1/ConsoleApp1.csproj b/ConsoleApp1/ConsoleApp1.csproj new file mode 100644 index 0000000..35e77fc --- /dev/null +++ b/ConsoleApp1/ConsoleApp1.csproj @@ -0,0 +1,22 @@ + + + + Exe + netcoreapp2.1 + + + + + + + + + PreserveNewest + + + + + + + + diff --git a/ConsoleApp1/Program.cs b/ConsoleApp1/Program.cs new file mode 100644 index 0000000..ccf6c59 --- /dev/null +++ b/ConsoleApp1/Program.cs @@ -0,0 +1,22 @@ +using ClassLibrary1; +using System; +using System.Diagnostics; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + Debug.WriteLine("Reading input file from the application package"); + string[] lines = System.IO.File.ReadAllLines(@"input.txt"); + foreach (String line in lines) + { + Console.WriteLine("parsing " + line); + Generator generator = new Generator(); + String output = generator.generate(line); + Console.WriteLine(output); + } + } + } +} diff --git a/ConsoleApp1/input.txt b/ConsoleApp1/input.txt new file mode 100644 index 0000000..95dbd2d --- /dev/null +++ b/ConsoleApp1/input.txt @@ -0,0 +1,3 @@ +THE ORVILLE +STARTREK +FIREFLY \ No newline at end of file diff --git a/README.md b/README.md index 2c16e5c..bbb2d0b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ On Screen Keyboard ================== +To Run +----------- +Open the solution in Visual Studio and build. +Run the console app. It will use the input.txt file located in console application directory as input. +The DVR's show will be displayed on one line of the cmd window, followed by the output on the next line. + The Problem ----------- diff --git a/UnitTestProject1/Properties/AssemblyInfo.cs b/UnitTestProject1/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4db40bb --- /dev/null +++ b/UnitTestProject1/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("UnitTestProject1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("UnitTestProject1")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("b8cbee57-407c-427c-9bb3-e9cafd0ccd14")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/UnitTestProject1/UnitTest1.cs b/UnitTestProject1/UnitTest1.cs new file mode 100644 index 0000000..a617bf4 --- /dev/null +++ b/UnitTestProject1/UnitTest1.cs @@ -0,0 +1,17 @@ +using System; +using ClassLibrary1; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace UnitTestProject1 +{ + [TestClass] + public class UnitTest1 + { + [TestMethod] + public void TestMethod1() + { + Generator c = new Generator(); + Assert.AreEqual("D,R,R,#,D,D,L,#,S,U,U,U,R,#,D,D,R,R,R,#,L,L,L,#,D,R,R,#,U,U,U,L,#", c.generate("IT Crowd")); + } + } +} diff --git a/UnitTestProject1/UnitTestProject1.csproj b/UnitTestProject1/UnitTestProject1.csproj new file mode 100644 index 0000000..fd984a8 --- /dev/null +++ b/UnitTestProject1/UnitTestProject1.csproj @@ -0,0 +1,74 @@ + + + + + + Debug + AnyCPU + {B8CBEE57-407C-427C-9BB3-E9CAFD0CCD14} + Library + Properties + UnitTestProject1 + UnitTestProject1 + v4.7.2 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + + + + + + + + {76ea34cc-4517-48cb-8ae2-5f9e6fe9d7bd} + ClassLibrary1 + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/UnitTestProject1/packages.config b/UnitTestProject1/packages.config new file mode 100644 index 0000000..2f7c5a1 --- /dev/null +++ b/UnitTestProject1/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file