diff --git a/.gitignore b/.gitignore index 74941b9..d0f9f16 100644 --- a/.gitignore +++ b/.gitignore @@ -1,336 +1,40 @@ -## 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 -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -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/ -**/Properties/launchSettings.json - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.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 - -# 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 -.cr/ - -# 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/ -.user -.filters -#This is mine and this is now -.bin/ -.obj/ -.Properties/ \ No newline at end of file +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Another things (VS) +**/.vs +*.vcxproj.user +**/Debug +**/bin +**/obj +*/packages \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 855f34f..344fe4b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ -image: Visual Studio 2017 +image: Visual Studio 2019 before_build: - - nuget restore semester2/6.1/HW6T2.sln + - nuget restore semester4/TestAttempt2/TestAttempt2.sln build: - project: semester2/2.3/2.3.sln + project: semester4/TestAttempt2/TestAttempt2.sln diff --git a/semester4/HomeworkOne/HomeworkOne.Tests/ListOfPows.Tests.fs b/semester4/HomeworkOne/HomeworkOne.Tests/ListOfPows.Tests.fs new file mode 100644 index 0000000..42b90c6 --- /dev/null +++ b/semester4/HomeworkOne/HomeworkOne.Tests/ListOfPows.Tests.fs @@ -0,0 +1,12 @@ +module ListOfPows.Tests + +open NUnit.Framework +open ListOfPows + +[] +let listOfPowsTest () = + Assert.AreEqual([], listOfPows 2 1) + Assert.AreEqual([2], listOfPows 1 1) + Assert.AreEqual([], listOfPows -2 -1) + Assert.AreEqual([1; 2; 4], listOfPows 0 2) + Assert.AreEqual([16; 32; 64; 128; 256; 512; 1024; 2048; 4096], listOfPows 4 12) \ No newline at end of file diff --git a/semester4/TestAttempt2/TestAttempt2.Tests/Pallindrome.Tests.fs b/semester4/TestAttempt2/TestAttempt2.Tests/Pallindrome.Tests.fs new file mode 100644 index 0000000..8e8c96a --- /dev/null +++ b/semester4/TestAttempt2/TestAttempt2.Tests/Pallindrome.Tests.fs @@ -0,0 +1,8 @@ +module Pallindrome.Tests + +open NUnit.Framework +open MaxPallindrome + +[] +let MaxPalindromeTest () = + Assert.AreEqual(906609, getMaxPallindromeOfThreeDigits()) diff --git a/semester4/TestAttempt2/TestAttempt2.Tests/Program.fs b/semester4/TestAttempt2/TestAttempt2.Tests/Program.fs new file mode 100644 index 0000000..0695f84 --- /dev/null +++ b/semester4/TestAttempt2/TestAttempt2.Tests/Program.fs @@ -0,0 +1 @@ +module Program = let [] main _ = 0 diff --git a/semester4/TestAttempt2/TestAttempt2.Tests/Queue.Tests.fs b/semester4/TestAttempt2/TestAttempt2.Tests/Queue.Tests.fs new file mode 100644 index 0000000..2990d81 --- /dev/null +++ b/semester4/TestAttempt2/TestAttempt2.Tests/Queue.Tests.fs @@ -0,0 +1,23 @@ +module TestAttempt2.Tests + +open NUnit.Framework +open ThreadSafeQueue + +[] +let QueueEmptyTest () = + let queue = new ThreadSafeQueue() + Assert.True(queue.Empty) + +[] +let QueueNotEmptyTest () = + let queue = new ThreadSafeQueue() + queue.Enqueue(6) + Assert.False(queue.Empty) + +[] +let QueueRegularTest () = + let queue = new ThreadSafeQueue() + queue.Enqueue(6) + queue.Enqueue(5) + Assert.AreEqual(6, queue.Dequeue()) + Assert.AreEqual(5, queue.Dequeue()) \ No newline at end of file diff --git a/semester4/TestAttempt2/TestAttempt2.Tests/TestAttempt2.Tests.fsproj b/semester4/TestAttempt2/TestAttempt2.Tests/TestAttempt2.Tests.fsproj new file mode 100644 index 0000000..8d82581 --- /dev/null +++ b/semester4/TestAttempt2/TestAttempt2.Tests/TestAttempt2.Tests.fsproj @@ -0,0 +1,26 @@ + + + + netcoreapp3.1 + + false + false + + + + + + + + + + + + + + + + + + + diff --git a/semester4/TestAttempt2/TestAttempt2.sln b/semester4/TestAttempt2/TestAttempt2.sln new file mode 100644 index 0000000..0cb3e57 --- /dev/null +++ b/semester4/TestAttempt2/TestAttempt2.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29926.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "TestAttempt2", "TestAttempt2\TestAttempt2.fsproj", "{FC7536C3-441A-4F2E-B49D-490A03BC8692}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "TestAttempt2.Tests", "TestAttempt2.Tests\TestAttempt2.Tests.fsproj", "{C40E5733-06FC-4830-97AF-AD66693CFCFF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FC7536C3-441A-4F2E-B49D-490A03BC8692}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FC7536C3-441A-4F2E-B49D-490A03BC8692}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FC7536C3-441A-4F2E-B49D-490A03BC8692}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FC7536C3-441A-4F2E-B49D-490A03BC8692}.Release|Any CPU.Build.0 = Release|Any CPU + {C40E5733-06FC-4830-97AF-AD66693CFCFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C40E5733-06FC-4830-97AF-AD66693CFCFF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C40E5733-06FC-4830-97AF-AD66693CFCFF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C40E5733-06FC-4830-97AF-AD66693CFCFF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {13475835-0C94-498B-B746-52E57D4B9E35} + EndGlobalSection +EndGlobal diff --git a/semester4/TestAttempt2/TestAttempt2/MaxPallindrome.fs b/semester4/TestAttempt2/TestAttempt2/MaxPallindrome.fs new file mode 100644 index 0000000..8116b3a --- /dev/null +++ b/semester4/TestAttempt2/TestAttempt2/MaxPallindrome.fs @@ -0,0 +1,17 @@ +module MaxPallindrome + +///Проверяет, является ли введенное число палиндромом +let numberIsPallindrome (number : int) = + let stringNumber = number.ToString() + let listOfChars = Seq.toList(stringNumber) + List.rev(listOfChars) = listOfChars + +///Удобная запись всех трезначных чисел +let allThreeDigits = [100 .. 999] + +///Возвращает максимальный палиндром полученный перемножением двух трезначных чисел +let getMaxPallindromeOfThreeDigits () = + allThreeDigits + |> List.collect (fun x -> List.map (fun y -> y * x) allThreeDigits) + |> List.filter numberIsPallindrome + |> List.max \ No newline at end of file diff --git a/semester4/TestAttempt2/TestAttempt2/Program.fs b/semester4/TestAttempt2/TestAttempt2/Program.fs new file mode 100644 index 0000000..3dfeaa7 --- /dev/null +++ b/semester4/TestAttempt2/TestAttempt2/Program.fs @@ -0,0 +1,4 @@ +[] +let main argv = + printfn "Hello World from F#!" + 0 // return an integer exit code diff --git a/semester4/TestAttempt2/TestAttempt2/TestAttempt2.fsproj b/semester4/TestAttempt2/TestAttempt2/TestAttempt2.fsproj new file mode 100644 index 0000000..b898c82 --- /dev/null +++ b/semester4/TestAttempt2/TestAttempt2/TestAttempt2.fsproj @@ -0,0 +1,14 @@ + + + + Exe + netcoreapp3.1 + + + + + + + + + diff --git a/semester4/TestAttempt2/TestAttempt2/ThreadSafeQueue.fs b/semester4/TestAttempt2/TestAttempt2/ThreadSafeQueue.fs new file mode 100644 index 0000000..dfe7216 --- /dev/null +++ b/semester4/TestAttempt2/TestAttempt2/ThreadSafeQueue.fs @@ -0,0 +1,37 @@ +module ThreadSafeQueue + +type ThreadSafeQueue<'T>() = + let mutable queue : List<'T> = [] + + ///Возращает первый элемент, не забирая его из очереди + member this.Head = + let rec headHelper () = + match queue with + | value :: _-> + value + |[] -> headHelper() + + lock queue (fun () -> + headHelper() + ) + + /// Добавляет элемент в очередь + member this.Enqueue value = + lock queue (fun () -> + queue <- queue @ [value] ) + + ///Забирает элемент из очереди + member this.Dequeue() = + let rec dequeueHelper () = + match queue with + | value :: newQueue-> + queue <- newQueue + value + |[] -> dequeueHelper() + + lock queue (fun () -> + dequeueHelper() + ) + + /// Пустая ли очередь + member this.Empty = queue.IsEmpty \ No newline at end of file