From 7b80a07525f4b7b5a3b2a4c806d550b200737169 Mon Sep 17 00:00:00 2001 From: Brandon Scott Date: Mon, 3 Jul 2017 16:19:37 -0500 Subject: [PATCH] Initial commit --- .gitattributes | 63 +++++++++++++++++++ .../P009-Palindrome-Number.sln | 22 +++++++ .../P009-Palindrome-Number/App.config | 6 ++ .../P009-Palindrome-Number.csproj | 53 ++++++++++++++++ .../P009-Palindrome-Number/Program.cs | 20 ++++++ .../Properties/AssemblyInfo.cs | 36 +++++++++++ .../P009-Palindrome-Number/Solution.cs | 31 +++++++++ 7 files changed, 231 insertions(+) create mode 100644 .gitattributes create mode 100644 P009-Palindrome-Number/P009-Palindrome-Number.sln create mode 100644 P009-Palindrome-Number/P009-Palindrome-Number/App.config create mode 100644 P009-Palindrome-Number/P009-Palindrome-Number/P009-Palindrome-Number.csproj create mode 100644 P009-Palindrome-Number/P009-Palindrome-Number/Program.cs create mode 100644 P009-Palindrome-Number/P009-Palindrome-Number/Properties/AssemblyInfo.cs create mode 100644 P009-Palindrome-Number/P009-Palindrome-Number/Solution.cs 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/P009-Palindrome-Number/P009-Palindrome-Number.sln b/P009-Palindrome-Number/P009-Palindrome-Number.sln new file mode 100644 index 0000000..33aaf96 --- /dev/null +++ b/P009-Palindrome-Number/P009-Palindrome-Number.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "P009-Palindrome-Number", "P009-Palindrome-Number\P009-Palindrome-Number.csproj", "{32C231FA-7FDC-44F1-AC2E-123E0F4D3701}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {32C231FA-7FDC-44F1-AC2E-123E0F4D3701}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {32C231FA-7FDC-44F1-AC2E-123E0F4D3701}.Debug|Any CPU.Build.0 = Debug|Any CPU + {32C231FA-7FDC-44F1-AC2E-123E0F4D3701}.Release|Any CPU.ActiveCfg = Release|Any CPU + {32C231FA-7FDC-44F1-AC2E-123E0F4D3701}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/P009-Palindrome-Number/P009-Palindrome-Number/App.config b/P009-Palindrome-Number/P009-Palindrome-Number/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/P009-Palindrome-Number/P009-Palindrome-Number/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/P009-Palindrome-Number/P009-Palindrome-Number/P009-Palindrome-Number.csproj b/P009-Palindrome-Number/P009-Palindrome-Number/P009-Palindrome-Number.csproj new file mode 100644 index 0000000..cc85d14 --- /dev/null +++ b/P009-Palindrome-Number/P009-Palindrome-Number/P009-Palindrome-Number.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {32C231FA-7FDC-44F1-AC2E-123E0F4D3701} + Exe + P009_Palindrome_Number + P009-Palindrome-Number + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/P009-Palindrome-Number/P009-Palindrome-Number/Program.cs b/P009-Palindrome-Number/P009-Palindrome-Number/Program.cs new file mode 100644 index 0000000..980a0b5 --- /dev/null +++ b/P009-Palindrome-Number/P009-Palindrome-Number/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace P009_Palindrome_Number +{ + class Program + { + static void Main(string[] args) + { + var solution = new Solution(); + Console.WriteLine(solution.IsPalindrome(123)); + Console.WriteLine(solution.IsPalindrome(123321)); + Console.WriteLine(solution.IsPalindrome(int.MaxValue)); + Console.ReadLine(); + } + } +} diff --git a/P009-Palindrome-Number/P009-Palindrome-Number/Properties/AssemblyInfo.cs b/P009-Palindrome-Number/P009-Palindrome-Number/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2ca5839 --- /dev/null +++ b/P009-Palindrome-Number/P009-Palindrome-Number/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("P009-Palindrome-Number")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Xeon Productions")] +[assembly: AssemblyProduct("P009-Palindrome-Number")] +[assembly: AssemblyCopyright("Copyright © Xeon Productions 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("32c231fa-7fdc-44f1-ac2e-123e0f4d3701")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/P009-Palindrome-Number/P009-Palindrome-Number/Solution.cs b/P009-Palindrome-Number/P009-Palindrome-Number/Solution.cs new file mode 100644 index 0000000..7a051fb --- /dev/null +++ b/P009-Palindrome-Number/P009-Palindrome-Number/Solution.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace P009_Palindrome_Number +{ + class Solution + { + /** + * 11507 / 11507 test cases passed. + * Status: Accepted + * Runtime: 122 ms + */ + public bool IsPalindrome(int x) + { + if (x < 0) + return false; + + int y = x, reversed = 0; + while (x > 0) + { + reversed = reversed * 10 + x % 10; + x = x / 10; + } + + return y == reversed; + } + } +}