chore: moving csharp file to its project (#198)
parent
ef836c94d0
commit
2f47d5c828
|
@ -0,0 +1,362 @@
|
||||||
|
## 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
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Ww][Ii][Nn]32/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# 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
|
||||||
|
nunit-*.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/
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
ScaffoldingReadMe.txt
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*.json
|
||||||
|
coverage*.xml
|
||||||
|
coverage*.info
|
||||||
|
|
||||||
|
# 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
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# 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
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# 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
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).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/
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
FodyWeavers.xsd
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||||
|
// Use hover for the description of the existing attributes
|
||||||
|
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
|
||||||
|
"name": ".NET Core Launch (console)",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build",
|
||||||
|
// If you have changed target frameworks, make sure to update the program path.
|
||||||
|
"program": "${workspaceFolder}/test/bin/Debug/netcoreapp3.1/Algorithms.Tests.dll",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}/test",
|
||||||
|
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
|
||||||
|
"console": "internalConsole",
|
||||||
|
"stopAtEntry": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": ".NET Core Attach",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "attach",
|
||||||
|
"processId": "${command:pickProcess}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"build",
|
||||||
|
"${workspaceFolder}/test/Algorithms.Tests.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "publish",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"publish",
|
||||||
|
"${workspaceFolder}/test/Algorithms.Tests.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "watch",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"watch",
|
||||||
|
"run",
|
||||||
|
"${workspaceFolder}/test/Algorithms.Tests.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 15
|
||||||
|
VisualStudioVersion = 15.0.26124.0
|
||||||
|
MinimumVisualStudioVersion = 15.0.26124.0
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Algorithms", "src\Algorithms.csproj", "{EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Algorithms.Tests", "test\Algorithms.Tests.csproj", "{8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{EDD3C753-58A5-4844-81EA-3E9BD6A1D2F6}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{8E5D96D1-0618-4A33-9AF6-95D1D8F14E5A}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,9 @@
|
||||||
|
# C#
|
||||||
|
## Strings
|
||||||
|
- [Palindrome](src/Strings/palindrome.cs)
|
||||||
|
|
||||||
|
## Sorts
|
||||||
|
|
||||||
|
1. [Bubble Sort](src/Sorts/bubble-sort.cs)
|
||||||
|
2. [Insertion Sort](src/Sorts/insertion-sort.cs)
|
||||||
|
3. [Selection Sort](src/Sorts/selection-sort.cs)
|
|
@ -0,0 +1,7 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,31 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Algorithms.Sorts
|
||||||
|
{
|
||||||
|
public class BubbleSort
|
||||||
|
{
|
||||||
|
public static void Main()
|
||||||
|
{
|
||||||
|
int[] arr = { 800, 11, 50, 771, 649, 770, 240, 9 };
|
||||||
|
Sort(arr);
|
||||||
|
var result = string.Join(" ", arr);
|
||||||
|
Console.WriteLine(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Sort(int[] source)
|
||||||
|
{
|
||||||
|
for (int write = 0; write < source.Length; write++)
|
||||||
|
{
|
||||||
|
for (int sort = 0; sort < source.Length - 1; sort++)
|
||||||
|
{
|
||||||
|
if (source[sort] > source[sort + 1])
|
||||||
|
{
|
||||||
|
var temp = source[sort + 1];
|
||||||
|
source[sort + 1] = source[sort];
|
||||||
|
source[sort] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Algorithms.Sorts
|
||||||
|
{
|
||||||
|
public class InsertionSort
|
||||||
|
{
|
||||||
|
public static void Main()
|
||||||
|
{
|
||||||
|
int[] arr = { 800, 11, 50, 771, 649, 770, 240, 9 };
|
||||||
|
Sort(arr);
|
||||||
|
var result = string.Join(" ", arr);
|
||||||
|
Console.WriteLine(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Sort(int[] source)
|
||||||
|
{
|
||||||
|
int n = source.Length;
|
||||||
|
for (int i = 1; i < n; ++i)
|
||||||
|
{
|
||||||
|
int key = source[i];
|
||||||
|
int j = i - 1;
|
||||||
|
|
||||||
|
// Move elements of arr[0..i-1],
|
||||||
|
// that are greater than key,
|
||||||
|
// to one position ahead of
|
||||||
|
// their current position
|
||||||
|
while (j >= 0 && source[j] > key)
|
||||||
|
{
|
||||||
|
source[j + 1] = source[j];
|
||||||
|
j = j - 1;
|
||||||
|
}
|
||||||
|
source[j + 1] = key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Algorithms.Sorts
|
||||||
|
{
|
||||||
|
public class SelectionSort
|
||||||
|
{
|
||||||
|
public static void Main()
|
||||||
|
{
|
||||||
|
int[] arr = { 800, 11, 50, 771, 649, 770, 240, 9 };
|
||||||
|
Sort(arr);
|
||||||
|
var result = string.Join(" ", arr);
|
||||||
|
Console.WriteLine(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Sort(int[] source)
|
||||||
|
{
|
||||||
|
int n = source.Length;
|
||||||
|
|
||||||
|
// One by one move boundary of unsorted subarray
|
||||||
|
for (int i = 0; i < n - 1; i++)
|
||||||
|
{
|
||||||
|
// Find the minimum element in unsorted array
|
||||||
|
int min_idx = i;
|
||||||
|
for (int j = i + 1; j < n; j++)
|
||||||
|
{
|
||||||
|
if (source[j] < source[min_idx])
|
||||||
|
{
|
||||||
|
min_idx = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap the found minimum element with the first
|
||||||
|
// element
|
||||||
|
int temp = source[min_idx];
|
||||||
|
source[min_idx] = source[i];
|
||||||
|
source[i] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace Algorithms.Strings
|
||||||
|
{
|
||||||
|
public class Palindrome
|
||||||
|
{
|
||||||
|
public static void Main()
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
result = IsPalindrome("abba");
|
||||||
|
Console.WriteLine(result);
|
||||||
|
result = IsPalindrome("abbccbbA");
|
||||||
|
Console.WriteLine(result);
|
||||||
|
result = IsPalindrome("Mr. Owl ate my metal worm");
|
||||||
|
Console.WriteLine(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsPalindrome(string source)
|
||||||
|
{
|
||||||
|
source = source.ToLower();
|
||||||
|
source = Regex.Replace(source, @"[^0-9A-Za-z]", "");
|
||||||
|
string reverse = new string(Enumerable.Range(1, source.Length).Select(i => source[source.Length - i]).ToArray());
|
||||||
|
return reverse == source;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
|
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\src\Algorithms.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,17 @@
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace algorithms.CSharp.Test.Sorts
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
internal class BubbleSort
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void SortTheArray_ShouldGetExpectedString()
|
||||||
|
{
|
||||||
|
int[] array = { 800, 11, 50, 771, 649, 770, 240, 9 };
|
||||||
|
Algorithms.Sorts.BubbleSort.Sort(array);
|
||||||
|
var result = string.Join(" ", array);
|
||||||
|
Assert.AreEqual("9 11 50 240 649 770 771 800", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace algorithms.CSharp.Test.Sorts
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
internal class InsertionSort
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void SortTheArray_ShouldGetExpectedString()
|
||||||
|
{
|
||||||
|
int[] array = { 800, 11, 50, 771, 649, 770, 240, 9 };
|
||||||
|
Algorithms.Sorts.InsertionSort.Sort(array);
|
||||||
|
var result = string.Join(" ", array);
|
||||||
|
Assert.AreEqual("9 11 50 240 649 770 771 800", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace algorithms.CSharp.Test.Sorts
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
internal class SelectionSort
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void SortTheArray_ShouldGetExpectedString()
|
||||||
|
{
|
||||||
|
int[] array = { 800, 11, 50, 771, 649, 770, 240, 9 };
|
||||||
|
Algorithms.Sorts.SelectionSort.Sort(array);
|
||||||
|
var result = string.Join(" ", array);
|
||||||
|
Assert.AreEqual("9 11 50 240 649 770 771 800", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Algorithms.CSharp.Test.Strings
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
internal class Palindrome
|
||||||
|
{
|
||||||
|
[TestCase("abba", true)]
|
||||||
|
[TestCase("abbccbbA", true)]
|
||||||
|
[TestCase("Mr. Owl ate my metal worm", true)]
|
||||||
|
[TestCase("asdfgasdfg", false)]
|
||||||
|
public void PassString_ShouldGetExpectedResult(string text, bool expected)
|
||||||
|
{
|
||||||
|
var result = Algorithms.Strings.Palindrome.IsPalindrome(text);
|
||||||
|
Assert.AreEqual(expected, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,14 +15,6 @@
|
||||||
11. [Comb Sort](c-or-cpp/comb-sort.cpp)
|
11. [Comb Sort](c-or-cpp/comb-sort.cpp)
|
||||||
12. [3 Way Quick Sort](c-or-cpp/3way_quick_sort.cpp)
|
12. [3 Way Quick Sort](c-or-cpp/3way_quick_sort.cpp)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### C#
|
|
||||||
|
|
||||||
1. [Bubble Sort](csharp/bubble-sort.cs)
|
|
||||||
2. [Insertion Sort](csharp/insertion-sort.cs)
|
|
||||||
3. [Selection Sort](csharp/selection-sort.cs)
|
|
||||||
|
|
||||||
### Python
|
### Python
|
||||||
|
|
||||||
1. [Bubble Sort](python/bubble-sort.py)
|
1. [Bubble Sort](python/bubble-sort.py)
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
public class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
|
||||||
{
|
|
||||||
int[] arr = { 800, 11, 50, 771, 649, 770, 240, 9 };
|
|
||||||
Sort(arr);
|
|
||||||
var result = string.Join(" ", arr);
|
|
||||||
Console.WriteLine(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Sort(int[] source)
|
|
||||||
{
|
|
||||||
for (int write = 0; write < source.Length; write++)
|
|
||||||
{
|
|
||||||
for (int sort = 0; sort < source.Length - 1; sort++)
|
|
||||||
{
|
|
||||||
if (source[sort] > source[sort + 1])
|
|
||||||
{
|
|
||||||
var temp = source[sort + 1];
|
|
||||||
source[sort + 1] = source[sort];
|
|
||||||
source[sort] = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
public class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
|
||||||
{
|
|
||||||
int[] arr = { 800, 11, 50, 771, 649, 770, 240, 9 };
|
|
||||||
Sort(arr);
|
|
||||||
var result = string.Join(" ", arr);
|
|
||||||
Console.WriteLine(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Sort(int[] source)
|
|
||||||
{
|
|
||||||
int n = source.Length;
|
|
||||||
for (int i = 1; i < n; ++i)
|
|
||||||
{
|
|
||||||
int key = source[i];
|
|
||||||
int j = i - 1;
|
|
||||||
|
|
||||||
// Move elements of arr[0..i-1],
|
|
||||||
// that are greater than key,
|
|
||||||
// to one position ahead of
|
|
||||||
// their current position
|
|
||||||
while (j >= 0 && source[j] > key)
|
|
||||||
{
|
|
||||||
source[j + 1] = source[j];
|
|
||||||
j = j - 1;
|
|
||||||
}
|
|
||||||
source[j + 1] = key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
public class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
|
||||||
{
|
|
||||||
int[] arr = { 800, 11, 50, 771, 649, 770, 240, 9 };
|
|
||||||
Sort(arr);
|
|
||||||
var result = string.Join(" ", arr);
|
|
||||||
Console.WriteLine(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Sort(int[] source)
|
|
||||||
{
|
|
||||||
int n = source.Length;
|
|
||||||
|
|
||||||
// One by one move boundary of unsorted subarray
|
|
||||||
for (int i = 0; i < n - 1; i++)
|
|
||||||
{
|
|
||||||
// Find the minimum element in unsorted array
|
|
||||||
int min_idx = i;
|
|
||||||
for (int j = i + 1; j < n; j++)
|
|
||||||
{
|
|
||||||
if (source[j] < source[min_idx])
|
|
||||||
{
|
|
||||||
min_idx = j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Swap the found minimum element with the first
|
|
||||||
// element
|
|
||||||
int temp = source[min_idx];
|
|
||||||
source[min_idx] = source[i];
|
|
||||||
source[i] = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -9,11 +9,6 @@
|
||||||
5. [String Tokeniser](c-or-cpp/string-tokeniser.cpp)
|
5. [String Tokeniser](c-or-cpp/string-tokeniser.cpp)
|
||||||
6. [String Reversal](c-or-cpp/string-reverse.cpp)
|
6. [String Reversal](c-or-cpp/string-reverse.cpp)
|
||||||
7. [Permutation of String](c-or-cpp/Permutation-of-String.c)
|
7. [Permutation of String](c-or-cpp/Permutation-of-String.c)
|
||||||
|
|
||||||
### C#
|
|
||||||
|
|
||||||
1. [Palindrome Check](csharp/palindrome.cs)
|
|
||||||
|
|
||||||
### JavaScript
|
### JavaScript
|
||||||
|
|
||||||
1. [Palindrome Check](js/palindrome.js)
|
1. [Palindrome Check](js/palindrome.js)
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
public class Program
|
|
||||||
{
|
|
||||||
public static void Main()
|
|
||||||
{
|
|
||||||
bool result = false;
|
|
||||||
result = IsPalindrome("abba");
|
|
||||||
Console.WriteLine(result);
|
|
||||||
result = IsPalindrome("abbccbbA");
|
|
||||||
Console.WriteLine(result);
|
|
||||||
result = IsPalindrome("Mr. Owl ate my metal worm");
|
|
||||||
Console.WriteLine(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool IsPalindrome(string source) {
|
|
||||||
source = source.ToLower();
|
|
||||||
source = Regex.Replace(source, @"[^0-9A-Za-z]", "");
|
|
||||||
string reverse = new string(Enumerable.Range(1, source.Length).Select(i => source[source.Length - i]).ToArray());
|
|
||||||
return reverse == source;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue