Compare commits

...

5 Commits

Author SHA1 Message Date
Ben Harris 4b5c81d217 start csharp/rational-numbers 2021-11-11 01:52:44 -05:00
Ben Harris 6d1fe2efa8 finish crystal/bob 2021-11-11 01:51:04 -05:00
Ben Harris d62c26bb8a add .net gitignore 2021-11-11 00:24:18 -05:00
Ben Harris 6184560fbf hyper-optimized-telemetry 2021-11-10 15:19:52 -05:00
Ben Harris 588f26458c create solution and update all to .net 6 2021-11-10 15:09:57 -05:00
70 changed files with 2074 additions and 84 deletions

454
.gitignore vendored Normal file
View File

@ -0,0 +1,454 @@
## 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/
# Tye
.tye/
# 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
##
## Visual studio for Mac
##
# globs
Makefile.in
*.userprefs
*.usertasks
config.make
config.status
aclocal.m4
install-sh
autom4te.cache/
*.tar.gz
tarballs/
test-results/
# Mac bundle stuff
*.dmg
*.app
# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# JetBrains Rider
.idea/
*.sln.iml
##
## Visual Studio Code
##
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

289
Exercism.sln Normal file
View File

@ -0,0 +1,289 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.31903.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Accumulate", "csharp\accumulate\Accumulate.csproj", "{36BC796C-F769-4187-9DC9-18D93B3C8038}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Acronym", "csharp\acronym\Acronym.csproj", "{7B5CFEB3-804C-4F13-A5D2-517DFC74239B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Allergies", "csharp\allergies\Allergies.csproj", "{F7292847-F725-4F3D-825F-10D9E98E9347}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArmstrongNumbers", "csharp\armstrong-numbers\ArmstrongNumbers.csproj", "{EE82D297-6DCD-4C8E-A1D7-91251F6212CC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AttackOfTheTrolls", "csharp\attack-of-the-trolls\AttackOfTheTrolls.csproj", "{7AFD14F5-B9E9-47C2-80F3-4B720E98634F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AuthenticationSystem", "csharp\authentication-system\AuthenticationSystem.csproj", "{849D907E-AF8D-4D40-8754-F962337F6EA6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BinarySearch", "csharp\binary-search\BinarySearch.csproj", "{EB116248-E69E-443B-A51B-04E4AFACA0AB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bob", "csharp\bob\Bob.csproj", "{EC287BAF-EBEE-428A-A73F-2852B70A254F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CalculatorConundrum", "csharp\calculator-conundrum\CalculatorConundrum.csproj", "{71B6C45F-8B6A-4F92-BE7A-142B5BBB5338}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CircularBuffer", "csharp\circular-buffer\CircularBuffer.csproj", "{CA4E3CBB-694B-4B83-B0C3-37E5D0BDA4E3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Clock", "csharp\clock\Clock.csproj", "{6236E197-1EA5-4CC0-B111-9F9FAC43339E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CollatzConjecture", "csharp\collatz-conjecture\CollatzConjecture.csproj", "{84850B28-0E52-4EF9-8264-18C45E2385B9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Etl", "csharp\etl\Etl.csproj", "{6C82B7CE-5FC8-4261-887C-82D676849F2E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GradeSchool", "csharp\grade-school\GradeSchool.csproj", "{CFFDC8C1-DD6F-43F2-AAFB-432D6D5543E5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Grains", "csharp\grains\Grains.csproj", "{CE6D9F4C-D5F3-4EB6-9C58-7B33A61F066E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hamming", "csharp\hamming\Hamming.csproj", "{2647417E-860B-4295-A4B0-4F961749E447}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloWorld", "csharp\hello-world\HelloWorld.csproj", "{10C6E650-1C3A-44BB-B7BA-70B78F147896}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HighScores", "csharp\high-scores\HighScores.csproj", "{A24CCE8F-1ABC-4530-A525-8F607954835E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InternationalCallingConnoisseur", "csharp\international-calling-connoisseur\InternationalCallingConnoisseur.csproj", "{84876DE5-30FC-4D5D-A677-72E60197A4A7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Isogram", "csharp\isogram\Isogram.csproj", "{ADEE3F5B-9CF6-4912-83B4-A55BD99BB9C6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KindergartenGarden", "csharp\kindergarten-garden\KindergartenGarden.csproj", "{BBF1DEB0-3D6A-4752-A867-B525BC9E1855}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Leap", "csharp\leap\Leap.csproj", "{AB62433C-665A-4ADA-83E6-AC99F718B342}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LogsLogsLogs", "csharp\logs-logs-logs\LogsLogsLogs.csproj", "{D9299298-7DD8-4B3C-9380-BFB8799AE7D8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MatchingBrackets", "csharp\matching-brackets\MatchingBrackets.csproj", "{E54B2EE8-B9D6-4E0E-B1B9-1117DE5F574B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeedForSpeed", "csharp\need-for-speed\NeedForSpeed.csproj", "{22918E2D-D62C-4B5C-AE71-4E408087C042}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NucleotideCount", "csharp\nucleotide-count\NucleotideCount.csproj", "{8397787A-6C17-4B87-9FCE-5CE803455148}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pangram", "csharp\pangram\Pangram.csproj", "{94DC531F-59F5-4845-AF5A-A57C9D84E017}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PhoneNumber", "csharp\phone-number\PhoneNumber.csproj", "{A2B6D7E8-8EAF-48A4-8A80-581FAA5A54E1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Raindrops", "csharp\raindrops\Raindrops.csproj", "{A0DB99AD-D92E-4680-9F7D-9A47BF606A2E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ResistorColor", "csharp\resistor-color\ResistorColor.csproj", "{C36CD587-C333-47DD-B16B-F1F8AF8939EE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReverseString", "csharp\reverse-string\ReverseString.csproj", "{C808EB4D-E3BB-413C-889B-677B6A8051C1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RobotName", "csharp\robot-name\RobotName.csproj", "{2071ECA9-2ABF-4ECB-B6E2-219DE4981D2B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RotationalCipher", "csharp\rotational-cipher\RotationalCipher.csproj", "{17856656-17EA-4D4A-A205-93E786E05851}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScrabbleScore", "csharp\scrabble-score\ScrabbleScore.csproj", "{19561646-6533-48B7-A149-B27BF660A7D9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecureMunchesterUnited", "csharp\secure-munchester-united\SecureMunchesterUnited.csproj", "{78E0260D-02D6-486E-9D77-FE96C9014EC9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpaceAge", "csharp\space-age\SpaceAge.csproj", "{F1433E5E-9E04-4367-A6DB-87538C5F41AB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpiralMatrix", "csharp\spiral-matrix\SpiralMatrix.csproj", "{B5D9F7C1-6911-4F8B-984B-BBA644F9E190}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Strain", "csharp\strain\Strain.csproj", "{22E576EA-7A0B-48A3-8BBF-4605982FF3ED}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SumOfMultiples", "csharp\sum-of-multiples\SumOfMultiples.csproj", "{835280FB-9CE1-4A50-87E1-07EEF181DC5B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TheWeatherInDeather", "csharp\the-weather-in-deather\TheWeatherInDeather.csproj", "{9FF0C587-7DA4-4A17-8D3D-D0A04A5A2514}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tournament", "csharp\tournament\Tournament.csproj", "{EF1EFEE8-329E-4C9A-AA46-DB28338F992E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TwoFer", "csharp\two-fer\TwoFer.csproj", "{838B3C30-2E55-4352-8045-EBD97755C0D7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WizardsAndWarriors", "csharp\wizards-and-warriors\WizardsAndWarriors.csproj", "{240CFD47-2AEC-49F2-B0B2-884B45E9A27A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HyperOptimizedTelemetry", "csharp\hyper-optimized-telemetry\HyperOptimizedTelemetry.csproj", "{2AF7AFB0-D34C-4B5E-B1F2-A07475BE5B52}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RationalNumbers", "csharp\rational-numbers\RationalNumbers.csproj", "{6273C0C2-FAFD-4DE5-829B-D700CED941EA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{36BC796C-F769-4187-9DC9-18D93B3C8038}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{36BC796C-F769-4187-9DC9-18D93B3C8038}.Debug|Any CPU.Build.0 = Debug|Any CPU
{36BC796C-F769-4187-9DC9-18D93B3C8038}.Release|Any CPU.ActiveCfg = Release|Any CPU
{36BC796C-F769-4187-9DC9-18D93B3C8038}.Release|Any CPU.Build.0 = Release|Any CPU
{7B5CFEB3-804C-4F13-A5D2-517DFC74239B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7B5CFEB3-804C-4F13-A5D2-517DFC74239B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B5CFEB3-804C-4F13-A5D2-517DFC74239B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B5CFEB3-804C-4F13-A5D2-517DFC74239B}.Release|Any CPU.Build.0 = Release|Any CPU
{F7292847-F725-4F3D-825F-10D9E98E9347}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F7292847-F725-4F3D-825F-10D9E98E9347}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7292847-F725-4F3D-825F-10D9E98E9347}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7292847-F725-4F3D-825F-10D9E98E9347}.Release|Any CPU.Build.0 = Release|Any CPU
{EE82D297-6DCD-4C8E-A1D7-91251F6212CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE82D297-6DCD-4C8E-A1D7-91251F6212CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE82D297-6DCD-4C8E-A1D7-91251F6212CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE82D297-6DCD-4C8E-A1D7-91251F6212CC}.Release|Any CPU.Build.0 = Release|Any CPU
{7AFD14F5-B9E9-47C2-80F3-4B720E98634F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7AFD14F5-B9E9-47C2-80F3-4B720E98634F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AFD14F5-B9E9-47C2-80F3-4B720E98634F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AFD14F5-B9E9-47C2-80F3-4B720E98634F}.Release|Any CPU.Build.0 = Release|Any CPU
{849D907E-AF8D-4D40-8754-F962337F6EA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{849D907E-AF8D-4D40-8754-F962337F6EA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{849D907E-AF8D-4D40-8754-F962337F6EA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{849D907E-AF8D-4D40-8754-F962337F6EA6}.Release|Any CPU.Build.0 = Release|Any CPU
{EB116248-E69E-443B-A51B-04E4AFACA0AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EB116248-E69E-443B-A51B-04E4AFACA0AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB116248-E69E-443B-A51B-04E4AFACA0AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB116248-E69E-443B-A51B-04E4AFACA0AB}.Release|Any CPU.Build.0 = Release|Any CPU
{EC287BAF-EBEE-428A-A73F-2852B70A254F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC287BAF-EBEE-428A-A73F-2852B70A254F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC287BAF-EBEE-428A-A73F-2852B70A254F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC287BAF-EBEE-428A-A73F-2852B70A254F}.Release|Any CPU.Build.0 = Release|Any CPU
{71B6C45F-8B6A-4F92-BE7A-142B5BBB5338}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71B6C45F-8B6A-4F92-BE7A-142B5BBB5338}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71B6C45F-8B6A-4F92-BE7A-142B5BBB5338}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71B6C45F-8B6A-4F92-BE7A-142B5BBB5338}.Release|Any CPU.Build.0 = Release|Any CPU
{CA4E3CBB-694B-4B83-B0C3-37E5D0BDA4E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CA4E3CBB-694B-4B83-B0C3-37E5D0BDA4E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CA4E3CBB-694B-4B83-B0C3-37E5D0BDA4E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CA4E3CBB-694B-4B83-B0C3-37E5D0BDA4E3}.Release|Any CPU.Build.0 = Release|Any CPU
{6236E197-1EA5-4CC0-B111-9F9FAC43339E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6236E197-1EA5-4CC0-B111-9F9FAC43339E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6236E197-1EA5-4CC0-B111-9F9FAC43339E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6236E197-1EA5-4CC0-B111-9F9FAC43339E}.Release|Any CPU.Build.0 = Release|Any CPU
{84850B28-0E52-4EF9-8264-18C45E2385B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{84850B28-0E52-4EF9-8264-18C45E2385B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{84850B28-0E52-4EF9-8264-18C45E2385B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{84850B28-0E52-4EF9-8264-18C45E2385B9}.Release|Any CPU.Build.0 = Release|Any CPU
{6C82B7CE-5FC8-4261-887C-82D676849F2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C82B7CE-5FC8-4261-887C-82D676849F2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C82B7CE-5FC8-4261-887C-82D676849F2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C82B7CE-5FC8-4261-887C-82D676849F2E}.Release|Any CPU.Build.0 = Release|Any CPU
{CFFDC8C1-DD6F-43F2-AAFB-432D6D5543E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CFFDC8C1-DD6F-43F2-AAFB-432D6D5543E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CFFDC8C1-DD6F-43F2-AAFB-432D6D5543E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CFFDC8C1-DD6F-43F2-AAFB-432D6D5543E5}.Release|Any CPU.Build.0 = Release|Any CPU
{CE6D9F4C-D5F3-4EB6-9C58-7B33A61F066E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE6D9F4C-D5F3-4EB6-9C58-7B33A61F066E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE6D9F4C-D5F3-4EB6-9C58-7B33A61F066E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE6D9F4C-D5F3-4EB6-9C58-7B33A61F066E}.Release|Any CPU.Build.0 = Release|Any CPU
{2647417E-860B-4295-A4B0-4F961749E447}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2647417E-860B-4295-A4B0-4F961749E447}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2647417E-860B-4295-A4B0-4F961749E447}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2647417E-860B-4295-A4B0-4F961749E447}.Release|Any CPU.Build.0 = Release|Any CPU
{10C6E650-1C3A-44BB-B7BA-70B78F147896}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10C6E650-1C3A-44BB-B7BA-70B78F147896}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10C6E650-1C3A-44BB-B7BA-70B78F147896}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10C6E650-1C3A-44BB-B7BA-70B78F147896}.Release|Any CPU.Build.0 = Release|Any CPU
{A24CCE8F-1ABC-4530-A525-8F607954835E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A24CCE8F-1ABC-4530-A525-8F607954835E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A24CCE8F-1ABC-4530-A525-8F607954835E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A24CCE8F-1ABC-4530-A525-8F607954835E}.Release|Any CPU.Build.0 = Release|Any CPU
{84876DE5-30FC-4D5D-A677-72E60197A4A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{84876DE5-30FC-4D5D-A677-72E60197A4A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{84876DE5-30FC-4D5D-A677-72E60197A4A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{84876DE5-30FC-4D5D-A677-72E60197A4A7}.Release|Any CPU.Build.0 = Release|Any CPU
{ADEE3F5B-9CF6-4912-83B4-A55BD99BB9C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADEE3F5B-9CF6-4912-83B4-A55BD99BB9C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADEE3F5B-9CF6-4912-83B4-A55BD99BB9C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADEE3F5B-9CF6-4912-83B4-A55BD99BB9C6}.Release|Any CPU.Build.0 = Release|Any CPU
{BBF1DEB0-3D6A-4752-A867-B525BC9E1855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBF1DEB0-3D6A-4752-A867-B525BC9E1855}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBF1DEB0-3D6A-4752-A867-B525BC9E1855}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBF1DEB0-3D6A-4752-A867-B525BC9E1855}.Release|Any CPU.Build.0 = Release|Any CPU
{AB62433C-665A-4ADA-83E6-AC99F718B342}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB62433C-665A-4ADA-83E6-AC99F718B342}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB62433C-665A-4ADA-83E6-AC99F718B342}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB62433C-665A-4ADA-83E6-AC99F718B342}.Release|Any CPU.Build.0 = Release|Any CPU
{D9299298-7DD8-4B3C-9380-BFB8799AE7D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9299298-7DD8-4B3C-9380-BFB8799AE7D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9299298-7DD8-4B3C-9380-BFB8799AE7D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9299298-7DD8-4B3C-9380-BFB8799AE7D8}.Release|Any CPU.Build.0 = Release|Any CPU
{E54B2EE8-B9D6-4E0E-B1B9-1117DE5F574B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E54B2EE8-B9D6-4E0E-B1B9-1117DE5F574B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E54B2EE8-B9D6-4E0E-B1B9-1117DE5F574B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E54B2EE8-B9D6-4E0E-B1B9-1117DE5F574B}.Release|Any CPU.Build.0 = Release|Any CPU
{22918E2D-D62C-4B5C-AE71-4E408087C042}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22918E2D-D62C-4B5C-AE71-4E408087C042}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22918E2D-D62C-4B5C-AE71-4E408087C042}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22918E2D-D62C-4B5C-AE71-4E408087C042}.Release|Any CPU.Build.0 = Release|Any CPU
{8397787A-6C17-4B87-9FCE-5CE803455148}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8397787A-6C17-4B87-9FCE-5CE803455148}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8397787A-6C17-4B87-9FCE-5CE803455148}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8397787A-6C17-4B87-9FCE-5CE803455148}.Release|Any CPU.Build.0 = Release|Any CPU
{94DC531F-59F5-4845-AF5A-A57C9D84E017}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94DC531F-59F5-4845-AF5A-A57C9D84E017}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94DC531F-59F5-4845-AF5A-A57C9D84E017}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94DC531F-59F5-4845-AF5A-A57C9D84E017}.Release|Any CPU.Build.0 = Release|Any CPU
{A2B6D7E8-8EAF-48A4-8A80-581FAA5A54E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2B6D7E8-8EAF-48A4-8A80-581FAA5A54E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2B6D7E8-8EAF-48A4-8A80-581FAA5A54E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2B6D7E8-8EAF-48A4-8A80-581FAA5A54E1}.Release|Any CPU.Build.0 = Release|Any CPU
{A0DB99AD-D92E-4680-9F7D-9A47BF606A2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0DB99AD-D92E-4680-9F7D-9A47BF606A2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0DB99AD-D92E-4680-9F7D-9A47BF606A2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0DB99AD-D92E-4680-9F7D-9A47BF606A2E}.Release|Any CPU.Build.0 = Release|Any CPU
{C36CD587-C333-47DD-B16B-F1F8AF8939EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C36CD587-C333-47DD-B16B-F1F8AF8939EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C36CD587-C333-47DD-B16B-F1F8AF8939EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C36CD587-C333-47DD-B16B-F1F8AF8939EE}.Release|Any CPU.Build.0 = Release|Any CPU
{C808EB4D-E3BB-413C-889B-677B6A8051C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C808EB4D-E3BB-413C-889B-677B6A8051C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C808EB4D-E3BB-413C-889B-677B6A8051C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C808EB4D-E3BB-413C-889B-677B6A8051C1}.Release|Any CPU.Build.0 = Release|Any CPU
{2071ECA9-2ABF-4ECB-B6E2-219DE4981D2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2071ECA9-2ABF-4ECB-B6E2-219DE4981D2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2071ECA9-2ABF-4ECB-B6E2-219DE4981D2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2071ECA9-2ABF-4ECB-B6E2-219DE4981D2B}.Release|Any CPU.Build.0 = Release|Any CPU
{17856656-17EA-4D4A-A205-93E786E05851}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17856656-17EA-4D4A-A205-93E786E05851}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17856656-17EA-4D4A-A205-93E786E05851}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17856656-17EA-4D4A-A205-93E786E05851}.Release|Any CPU.Build.0 = Release|Any CPU
{19561646-6533-48B7-A149-B27BF660A7D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19561646-6533-48B7-A149-B27BF660A7D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19561646-6533-48B7-A149-B27BF660A7D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19561646-6533-48B7-A149-B27BF660A7D9}.Release|Any CPU.Build.0 = Release|Any CPU
{78E0260D-02D6-486E-9D77-FE96C9014EC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78E0260D-02D6-486E-9D77-FE96C9014EC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78E0260D-02D6-486E-9D77-FE96C9014EC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78E0260D-02D6-486E-9D77-FE96C9014EC9}.Release|Any CPU.Build.0 = Release|Any CPU
{F1433E5E-9E04-4367-A6DB-87538C5F41AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F1433E5E-9E04-4367-A6DB-87538C5F41AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F1433E5E-9E04-4367-A6DB-87538C5F41AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F1433E5E-9E04-4367-A6DB-87538C5F41AB}.Release|Any CPU.Build.0 = Release|Any CPU
{B5D9F7C1-6911-4F8B-984B-BBA644F9E190}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B5D9F7C1-6911-4F8B-984B-BBA644F9E190}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B5D9F7C1-6911-4F8B-984B-BBA644F9E190}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B5D9F7C1-6911-4F8B-984B-BBA644F9E190}.Release|Any CPU.Build.0 = Release|Any CPU
{22E576EA-7A0B-48A3-8BBF-4605982FF3ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22E576EA-7A0B-48A3-8BBF-4605982FF3ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22E576EA-7A0B-48A3-8BBF-4605982FF3ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22E576EA-7A0B-48A3-8BBF-4605982FF3ED}.Release|Any CPU.Build.0 = Release|Any CPU
{835280FB-9CE1-4A50-87E1-07EEF181DC5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{835280FB-9CE1-4A50-87E1-07EEF181DC5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{835280FB-9CE1-4A50-87E1-07EEF181DC5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{835280FB-9CE1-4A50-87E1-07EEF181DC5B}.Release|Any CPU.Build.0 = Release|Any CPU
{9FF0C587-7DA4-4A17-8D3D-D0A04A5A2514}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9FF0C587-7DA4-4A17-8D3D-D0A04A5A2514}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9FF0C587-7DA4-4A17-8D3D-D0A04A5A2514}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9FF0C587-7DA4-4A17-8D3D-D0A04A5A2514}.Release|Any CPU.Build.0 = Release|Any CPU
{EF1EFEE8-329E-4C9A-AA46-DB28338F992E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF1EFEE8-329E-4C9A-AA46-DB28338F992E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF1EFEE8-329E-4C9A-AA46-DB28338F992E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF1EFEE8-329E-4C9A-AA46-DB28338F992E}.Release|Any CPU.Build.0 = Release|Any CPU
{838B3C30-2E55-4352-8045-EBD97755C0D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{838B3C30-2E55-4352-8045-EBD97755C0D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{838B3C30-2E55-4352-8045-EBD97755C0D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{838B3C30-2E55-4352-8045-EBD97755C0D7}.Release|Any CPU.Build.0 = Release|Any CPU
{240CFD47-2AEC-49F2-B0B2-884B45E9A27A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{240CFD47-2AEC-49F2-B0B2-884B45E9A27A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{240CFD47-2AEC-49F2-B0B2-884B45E9A27A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{240CFD47-2AEC-49F2-B0B2-884B45E9A27A}.Release|Any CPU.Build.0 = Release|Any CPU
{2AF7AFB0-D34C-4B5E-B1F2-A07475BE5B52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2AF7AFB0-D34C-4B5E-B1F2-A07475BE5B52}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2AF7AFB0-D34C-4B5E-B1F2-A07475BE5B52}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2AF7AFB0-D34C-4B5E-B1F2-A07475BE5B52}.Release|Any CPU.Build.0 = Release|Any CPU
{6273C0C2-FAFD-4DE5-829B-D700CED941EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6273C0C2-FAFD-4DE5-829B-D700CED941EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6273C0C2-FAFD-4DE5-829B-D700CED941EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6273C0C2-FAFD-4DE5-829B-D700CED941EA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {49E47185-5199-4C59-BC30-0536FADEAD3E}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,26 @@
{
"blurb": "Bob is a lackadaisical teenager. In conversation, his responses are very limited.",
"authors": [
"mhelmetag"
],
"contributors": [
"amscotti",
"asterite",
"derekgottlieb",
"issyl0",
"mattkimmel"
],
"files": {
"solution": [
"src/bob.cr"
],
"test": [
"spec/bob_spec.cr"
],
"example": [
".meta/src/example.cr"
]
},
"source": "Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial.",
"source_url": "http://pine.fm/LearnToProgram/?Chapter=06"
}

View File

@ -0,0 +1 @@
{"track":"crystal","exercise":"bob","id":"b15fb7a8865a43af92fcef116148386c","url":"https://exercism.org/tracks/crystal/exercises/bob","handle":"benharri","is_requester":true,"auto_approve":false}

41
crystal/bob/HELP.md Normal file
View File

@ -0,0 +1,41 @@
# Help
## Running the tests
Execute the tests with:
```bash
$ crystal spec
```
## Skipped tests
In each test suite all but the first test have been skipped.
Once you get a test passing, you can unskip the next one by changing `pending` to `it`.
## Submitting your solution
You can submit your solution using the `exercism submit src/bob.cr` command.
This command will upload your solution to the Exercism website and print the solution page's URL.
It's possible to submit an incomplete solution which allows you to:
- See how others have completed the exercise
- Request help from a mentor
## Need to get help?
If you'd like help solving the exercise, check the following pages:
- The [Crystal track's documentation](https://exercism.org/docs/tracks/crystal)
- [Exercism's support channel on gitter](https://gitter.im/exercism/support)
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
To get help if you're having trouble, you can use one of the following resources:
- [Crystal API](http://crystal-lang.org/api/)
- [r/crystal_programming/](https://www.reddit.com/r/crystal_programming/) is the Crystal subreddit.
- [StackOverflow](http://stackoverflow.com/questions/tagged/crystal) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.

39
crystal/bob/README.md Normal file
View File

@ -0,0 +1,39 @@
# Bob
Welcome to Bob on Exercism's Crystal Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
## Instructions
Bob is a lackadaisical teenager. In conversation, his responses are very limited.
Bob answers 'Sure.' if you ask him a question, such as "How are you?".
He answers 'Whoa, chill out!' if you YELL AT HIM (in all capitals).
He answers 'Calm down, I know what I'm doing!' if you yell a question at him.
He says 'Fine. Be that way!' if you address him without actually saying
anything.
He answers 'Whatever.' to anything else.
Bob's conversational partner is a purist when it comes to written communication and always follows normal rules regarding sentence punctuation in English.
## Source
### Created by
- @mhelmetag
### Contributed to by
- @amscotti
- @asterite
- @derekgottlieb
- @issyl0
- @mattkimmel
### Based on
Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial. - http://pine.fm/LearnToProgram/?Chapter=06

View File

@ -0,0 +1,66 @@
require "spec"
require "../src/*"
describe "Bob" do
describe "#hey" do
it "responds to stating something" do
Bob.hey("Tom-ay-to, tom-aaaah-to.").should eq "Whatever."
end
pending "responds to shouting something" do
Bob.hey("WATCH OUT!").should eq "Whoa, chill out!"
end
pending "responds to asking a question" do
Bob.hey("Does this cryogenic chamber make me look fat?").should eq "Sure."
end
pending "responds to talking forcefully" do
Bob.hey("Let\'s go make out behind the gym!").should eq "Whatever."
end
pending "responds to using acronyms in regular speech" do
Bob.hey("It\'s OK if you don\'t want to go to the DMV.").should eq "Whatever."
end
pending "responds to forceful questions" do
Bob.hey("WHAT THE HELL WERE YOU THINKING?").should eq "Calm down, I know what I'm doing!"
end
pending "responds to shouting numbers" do
Bob.hey("1, 2, 3 GO!").should eq "Whoa, chill out!"
end
pending "responds to only numbers" do
Bob.hey("1, 2, 3").should eq "Whatever."
end
pending "responds to question with only numbers" do
Bob.hey("4?").should eq "Sure."
end
pending "responds to shouting with special characters" do
Bob.hey("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!").should eq "Whoa, chill out!"
end
pending "responds to shouting with no exclamation mark" do
Bob.hey("I HATE YOU").should eq "Whoa, chill out!"
end
pending "responds to statement containing question mark" do
Bob.hey("Ending with a ? means a question.").should eq "Whatever."
end
pending "responds to prattling on" do
Bob.hey("Wait! Hang on. Are you going to be OK?").should eq "Sure."
end
pending "responds to silence" do
Bob.hey("").should eq "Fine. Be that way!"
end
pending "responds to prolonged silence" do
Bob.hey(" ").should eq "Fine. Be that way!"
end
end
end

15
crystal/bob/src/bob.cr Normal file
View File

@ -0,0 +1,15 @@
class Bob
def self.hey(s)
if s.blank?
"Fine. Be that way!"
elsif s.each_char.any?(&.ascii_letter?) && s.each_char.none?(&.lowercase?)
return "Calm down, I know what I'm doing!" if s.ends_with?('?')
"Whoa, chill out!"
elsif s.ends_with?('?')
"Sure."
else
"Whatever."
end
end
end

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -10,56 +10,56 @@ public class HighScoresTests
Assert.Equal(new List<int> { 30, 50, 20, 70 }, sut.Scores());
}
[Fact(Skip = "Remove this Skip property to run this test")]
[Fact]
public void Latest_score()
{
var sut = new HighScores(new List<int> { 100, 0, 90, 30 });
Assert.Equal(30, sut.Latest());
}
[Fact(Skip = "Remove this Skip property to run this test")]
[Fact]
public void Personal_best()
{
var sut = new HighScores(new List<int> { 40, 100, 70 });
Assert.Equal(100, sut.PersonalBest());
}
[Fact(Skip = "Remove this Skip property to run this test")]
[Fact]
public void Personal_top_three_from_a_list_of_scores()
{
var sut = new HighScores(new List<int> { 10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70 });
Assert.Equal(new List<int> { 100, 90, 70 }, sut.PersonalTopThree());
}
[Fact(Skip = "Remove this Skip property to run this test")]
[Fact]
public void Personal_top_highest_to_lowest()
{
var sut = new HighScores(new List<int> { 20, 10, 30 });
Assert.Equal(new List<int> { 30, 20, 10 }, sut.PersonalTopThree());
}
[Fact(Skip = "Remove this Skip property to run this test")]
[Fact]
public void Personal_top_when_there_is_a_tie()
{
var sut = new HighScores(new List<int> { 40, 20, 40, 30 });
Assert.Equal(new List<int> { 40, 40, 30 }, sut.PersonalTopThree());
}
[Fact(Skip = "Remove this Skip property to run this test")]
[Fact]
public void Personal_top_when_there_are_less_than_3()
{
var sut = new HighScores(new List<int> { 30, 70 });
Assert.Equal(new List<int> { 70, 30 }, sut.PersonalTopThree());
}
[Fact(Skip = "Remove this Skip property to run this test")]
[Fact]
public void Personal_top_when_there_is_only_one()
{
var sut = new HighScores(new List<int> { 40 });
Assert.Equal(new List<int> { 40 }, sut.PersonalTopThree());
}
[Fact(Skip = "Remove this Skip property to run this test")]
[Fact]
public void Latest_score_should_not_change_after_calling_personal_best()
{
var sut = new HighScores(new List<int> { 20, 10, 30, 3, 2, 1 });
@ -67,7 +67,7 @@ public class HighScoresTests
Assert.Equal(1, sut.Latest());
}
[Fact(Skip = "Remove this Skip property to run this test")]
[Fact]
public void Latest_score_should_not_change_after_calling_personal_top_three()
{
var sut = new HighScores(new List<int> { 20, 100, 30, 90, 2, 70 });

View File

@ -0,0 +1,21 @@
{
"blurb": "Learn about bit conversion by implementing a message protocol.",
"contributors": [
"ErikSchierboom",
"yzAlvin"
],
"authors": [
"mikedamay"
],
"files": {
"solution": [
"HyperOptimizedTelemetry.cs"
],
"test": [
"HyperOptimizedTelemetryTests.cs"
],
"exemplar": [
".meta/Exemplar.cs"
]
}
}

View File

@ -0,0 +1 @@
{"track":"csharp","exercise":"hyper-optimized-telemetry","id":"c01516a8855647618a6e1d8bb9d1884f","url":"https://exercism.org/tracks/csharp/exercises/hyper-optimized-telemetry","handle":"benharri","is_requester":true,"auto_approve":false}

View File

@ -0,0 +1,39 @@
# Help
## Running the tests
You can run the tests by opening a command prompt in the exercise's directory, and then running the [`dotnet test` command](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test)
Alternatively, most IDE's have built-in support for running tests, including [Visual Studio](https://docs.microsoft.com/en-us/visualstudio/test/run-unit-tests-with-test-explorer), [Rider](https://www.jetbrains.com/help/rider/Unit_Testing_in_Solution.html) and [Visual Studio code](https://github.com/OmniSharp/omnisharp-vscode/wiki/How-to-run-and-debug-unit-tests).
See the [tests page](https://exercism.io/tracks/csharp/tests) for more information.
## Skipped tests
Initially, only the first test will be enabled.
This is to encourage you to solve the exercise one step at a time.
Once you get the first test passing, remove the `Skip` property from the next test and work on getting that test passing.
## Submitting your solution
You can submit your solution using the `exercism submit HyperOptimizedTelemetry.cs` command.
This command will upload your solution to the Exercism website and print the solution page's URL.
It's possible to submit an incomplete solution which allows you to:
- See how others have completed the exercise
- Request help from a mentor
## Need to get help?
If you'd like help solving the exercise, check the following pages:
- The [C# track's documentation](https://exercism.org/docs/tracks/csharp)
- [Exercism's support channel on gitter](https://gitter.im/exercism/support)
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
To get help if you're having trouble, you can use one of the following resources:
- [Gitter](https://gitter.im/exercism/xcsharp) is Exercism C# track's Gitter room; go here to get support and ask questions related to the C# track.
- [/r/csharp](https://www.reddit.com/r/csharp) is the C# subreddit.
- [StackOverflow](http://stackoverflow.com/questions/tagged/c%23) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.

View File

@ -0,0 +1,19 @@
# Hints
## General
- [Integral numeric types][integral-numeric-types]: overview of the integral numeric types.
- [Numeric conversions][numeric-conversions]: overview of implicit and explicit numeric conversions.
## 1. Encode an integral value ready to send
- Conversion to a byte array is dealt with [here][bit-converter-get-bytes]
## 2. Decode a received buffer
- Converting from a byte array is discussed [here][bit-converter-to-type]
[integral-numeric-types]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types
[numeric-conversions]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/numeric-conversions
[bit-converter-get-bytes]: https://docs.microsoft.com/en-us/dotnet/api/system.bitconverter.getbytes?view=netcore-3.1
[bit-converter-to-type]: https://docs.microsoft.com/en-us/dotnet/api/system.bitconverter.toint16?view=netcore-3.1

View File

@ -0,0 +1,34 @@
using System;
public static class TelemetryBuffer
{
public static byte[] ToBuffer(long reading)
{
var result = new byte[9];
var bytesOfReading = BitConverter.GetBytes(reading);
sbyte size = reading switch
{
> uint.MaxValue or < int.MinValue => -8,
> int.MaxValue => 4,
> ushort.MaxValue or < short.MinValue => -4,
>= 0 => 2,
>= short.MinValue => -2
};
Array.Resize(ref bytesOfReading, Math.Abs(size));
result[0] = (byte)size;
bytesOfReading.CopyTo(result, 1);
return result;
}
public static long FromBuffer(byte[] buffer) =>
(sbyte)buffer[0] switch
{
-8 => BitConverter.ToInt64(buffer, 1),
4 => BitConverter.ToUInt32(buffer, 1),
-4 => BitConverter.ToInt32(buffer, 1),
2 => BitConverter.ToUInt16(buffer, 1),
-2 => BitConverter.ToInt16(buffer, 1),
_ => 0
};
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="Exercism.Tests" Version="0.1.0-beta1" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,271 @@
using System;
using Xunit;
using Exercism.Tests;
public class HyperOptimizedTelemetryTests
{
[Fact]
[Task(1)]
public void ToBuffer_upper_long()
{
var bytes = TelemetryBuffer.ToBuffer(Int64.MaxValue);
Assert.Equal(new byte[] { 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f }, bytes);
}
[Fact]
[Task(1)]
public void ToBuffer_lower_long()
{
var bytes = TelemetryBuffer.ToBuffer((long)UInt32.MaxValue + 1);
Assert.Equal(new byte[] { 0xf8, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0 }, bytes);
}
[Fact]
[Task(1)]
public void ToBuffer_upper_uint()
{
var bytes = TelemetryBuffer.ToBuffer(UInt32.MaxValue);
Assert.Equal(new byte[] { 0x4, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0 }, bytes);
}
[Fact]
[Task(1)]
public void ToBuffer_lower_uint()
{
var bytes = TelemetryBuffer.ToBuffer((long)Int32.MaxValue + 1);
Assert.Equal(new byte[] { 0x4, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0 }, bytes);
}
[Fact]
[Task(1)]
public void ToBuffer_upper_int()
{
var bytes = TelemetryBuffer.ToBuffer(Int32.MaxValue);
Assert.Equal(new byte[] { 0xfc, 0xff, 0xff, 0xff, 0x7f, 0x0, 0x0, 0x0, 0x0 }, bytes);
}
[Fact]
[Task(1)]
public void ToBuffer_lower_int()
{
var bytes = TelemetryBuffer.ToBuffer((long)UInt16.MaxValue + 1);
Assert.Equal(new byte[] { 0xfc, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0 }, bytes);
}
[Fact]
[Task(1)]
public void ToBuffer_upper_ushort()
{
var bytes = TelemetryBuffer.ToBuffer(UInt16.MaxValue);
Assert.Equal(new byte[] { 0x2, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, bytes);
}
[Fact]
[Task(1)]
public void ToBuffer_lower_ushort()
{
var bytes = TelemetryBuffer.ToBuffer((long)Int16.MaxValue + 1);
Assert.Equal(new byte[] { 0x2, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, bytes);
}
[Fact]
[Task(1)]
public void ToBuffer_upper_short()
{
var bytes = TelemetryBuffer.ToBuffer(Int16.MaxValue);
Assert.Equal(new byte[] { 0x2, 0xff, 0x7f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, bytes);
}
[Fact]
[Task(1)]
public void ToBuffer_Zero()
{
var bytes = TelemetryBuffer.ToBuffer(0);
Assert.Equal(new byte[] { 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, bytes);
}
[Fact]
[Task(1)]
public void ToBuffer_upper_neg_short()
{
var bytes = TelemetryBuffer.ToBuffer(-1);
Assert.Equal(new byte[] { 0xfe, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, bytes);
}
[Fact]
[Task(1)]
public void ToBuffer_lower_neg_short()
{
var bytes = TelemetryBuffer.ToBuffer(Int16.MinValue);
Assert.Equal(new byte[] { 0xfe, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, bytes);
}
[Fact]
[Task(1)]
public void ToBuffer_upper_neg_int()
{
int n = Int16.MinValue - 1;
var bytes = TelemetryBuffer.ToBuffer(n);
Assert.Equal(new byte[] { 0xfc, 0xff, 0x7f, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0 }, bytes);
}
[Fact]
[Task(1)]
public void ToBuffer_lower_neg_int()
{
var bytes = TelemetryBuffer.ToBuffer(Int32.MinValue);
Assert.Equal(new byte[] { 0xfc, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0 }, bytes);
}
[Fact]
[Task(1)]
public void ToBuffer_upper_neg_long()
{
var bytes = TelemetryBuffer.ToBuffer((long)Int32.MinValue - 1);
Assert.Equal(new byte[] { 0xf8, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff }, bytes);
}
[Fact]
[Task(1)]
public void ToBuffer_lower_neg_long()
{
var bytes = TelemetryBuffer.ToBuffer(Int64.MinValue);
Assert.Equal(new byte[] { 0xf8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80 }, bytes);
}
[Fact]
[Task(2)]
public void FromBuffer_Invalid()
{
Assert.Equal(0,
TelemetryBuffer.FromBuffer(new byte[] { 22, 0xff, 0xff, 0xff, 0x7f, 0, 0, 0, 0 }));
}
[Fact]
[Task(2)]
public void FromBuffer_upper_long()
{
Assert.Equal(Int64.MaxValue,
TelemetryBuffer.FromBuffer(new byte[] { 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f }));
}
[Fact]
[Task(2)]
public void FromBuffer_lower_long()
{
Assert.Equal((long)UInt32.MaxValue + 1,
TelemetryBuffer.FromBuffer(new byte[] { 0xf8, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0 }));
}
[Fact]
[Task(2)]
public void FromBuffer_upper_uint()
{
Assert.Equal(UInt32.MaxValue,
TelemetryBuffer.FromBuffer(new byte[] { 0x4, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0 }));
}
[Fact]
[Task(2)]
public void FromBuffer_lower_uint()
{
Assert.Equal((long)Int32.MaxValue + 1,
TelemetryBuffer.FromBuffer(new byte[] { 0x4, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0 }));
}
[Fact]
[Task(2)]
public void FromBuffer_upper_int()
{
Assert.Equal(Int32.MaxValue,
TelemetryBuffer.FromBuffer(new byte[] { 0xfc, 0xff, 0xff, 0xff, 0x7f, 0x0, 0x0, 0x0, 0x0 }));
}
[Fact]
[Task(2)]
public void FromBuffer_lower_int()
{
Assert.Equal(UInt16.MaxValue + 1,
TelemetryBuffer.FromBuffer(new byte[] { 0xfc, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0 }));
}
[Fact]
[Task(2)]
public void FromBuffer_upper_ushort()
{
Assert.Equal(UInt16.MaxValue,
TelemetryBuffer.FromBuffer(new byte[] { 0x2, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }));
}
[Fact]
[Task(2)]
public void FromBuffer_lower_ushort()
{
Assert.Equal(Int16.MaxValue + 1,
TelemetryBuffer.FromBuffer(new byte[] { 0x2, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }));
}
[Fact]
[Task(2)]
public void FromBuffer_upper_short()
{
Assert.Equal(Int16.MaxValue,
TelemetryBuffer.FromBuffer(new byte[] { 0xfe, 0xff, 0x7f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }));
}
[Fact]
[Task(2)]
public void FromBuffer_Zero()
{
Assert.Equal(0,
TelemetryBuffer.FromBuffer(new byte[] { 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }));
}
[Fact]
[Task(2)]
public void FromBuffer_upper_neg_short()
{
Assert.Equal(-1,
TelemetryBuffer.FromBuffer(new byte[] { 0xfe, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }));
}
[Fact]
[Task(2)]
public void FromBuffer_lower_neg_short()
{
Assert.Equal(Int16.MinValue,
TelemetryBuffer.FromBuffer(new byte[] { 0xfe, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }));
}
[Fact]
[Task(2)]
public void FromBuffer_upper_neg_int()
{
Assert.Equal(Int16.MinValue - 1,
TelemetryBuffer.FromBuffer(new byte[] { 0xfc, 0xff, 0x7f, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0 }));
}
[Fact]
[Task(2)]
public void FromBuffer_lower_neg_int()
{
Assert.Equal(Int32.MinValue,
TelemetryBuffer.FromBuffer(new byte[] { 0xfc, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0 }));
}
[Fact]
[Task(2)]
public void FromBuffer_upper_neg_long()
{
Assert.Equal((long)Int32.MinValue - 1,
TelemetryBuffer.FromBuffer(new byte[] { 0xf8, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff }));
}
[Fact]
[Task(2)]
public void FromBuffer_lower_neg_long()
{
Assert.Equal(Int64.MinValue,
TelemetryBuffer.FromBuffer(new byte[] { 0xf8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80 }));
}
}

View File

@ -0,0 +1,102 @@
# Hyper-optimized Telemetry
Welcome to Hyper-optimized Telemetry on Exercism's C# Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :)
## Introduction
C#, like many statically typed languages, provides a number of types that represent integers, each with its own range of values. At the low end, the `sbyte` type has a minimum value of -128 and a maximum value of 127. Like all the integer types these values are available as `<type>.MinValue` and `<type>.MaxValue`. At the high end, the `long` type has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807. In between lie the `short` and `int` types.
The ranges are determined by the storage width of the type as allocated by the system. For example, a `byte` uses 8 bits and a `long` uses 64 bits.
Each of the above types is paired with an unsigned equivalent: `sbyte`/`byte`, `short`/`ushort`, `int`/`uint` and `long`/`ulong`. In all cases the range of the values is from 0 to the negative signed maximum times 2 plus 1.
| Type | Width | Minimum | Maximum |
| ------ | ------ | -------------------------- | --------------------------- |
| sbyte | 8 bit | -128 | +127 |
| short | 16 bit | -32_768 | +32_767 |
| int | 32 bit | -2_147_483_648 | +2_147_483_647 |
| long | 64 bit | -9_223_372_036_854_775_808 | +9_223_372_036_854_775_807 |
| byte | 8 bit | 0 | +255 |
| ushort | 16 bit | 0 | +65_535 |
| uint | 32 bit | 0 | +4_294_967_295 |
| ulong | 64 bit | 0 | +18_446_744_073_709_551_615 |
A variable (or expression) of one type can easily be converted to another. For instance, in an assignment operation, if the type of the value being assigned (lhs) ensures that the value will lie within the range of the type being assigned to (rhs) then there is a simple assignment:
```csharp
uint ui = uint.MaxValue;
ulong ul = ui; // no problem
```
On the other hand if the range of type being assigned from is not a subset of the assignee's range of values then a cast, `()` operation is required even if the particular value is within the assignee's range:
```csharp
short s = 42;
uint ui = (uint)s;
```
## Bit conversion
The `BitConverter` class provides a convenient way of converting integer types to and from arrays of bytes.
## Instructions
Work continues on the remote control car project. Bandwidth in the telemetry system is at a premium and you have been asked to implement a message protocol for communicating telemetry data.
Data is transmitted in a buffer (byte array). When integers are sent, the size of the buffer is reduced by employing the protocol described below.
Each value should be represented in the smallest possible integral type (types of `byte` and `sbyte` are not included as the saving would be trivial):
| From | To | Type |
| -------------------------- | ------------------------- | -------- |
| 4_294_967_296 | 9_223_372_036_854_775_807 | `long` |
| 2_147_483_648 | 4_294_967_295 | `uint` |
| 65_536 | 2_147_483_647 | `int` |
| 0 | 65_535 | `ushort` |
| -32_768 | -1 | `short` |
| -2_147_483_648 | -32_769 | `int` |
| -9_223_372_036_854_775_808 | -2_147_483_649 | `long` |
The value should be converted to the appropriate number of bytes for its assigned type. The complete buffer comprises a byte indicating the number of additional bytes in the buffer (_prefix byte_) followed by the bytes holding the integer (_payload bytes_).
Some of the types use an identical number of bytes (e.g. the `uint` and `int` types). Normally, they would have the same _prefix byte_, but that would make decoding problematic. To counter this, the protocol introduces a little trick: for signed types, their _prefix byte_ value is `256` minus the number of additional bytes in the buffer.
Only the prefix byte and the number of following bytes indicated by the prefix will be sent in the communication. Internally a 9 byte buffer is used (with trailing zeroes, as necessary) both by sending and receiving routines.
## 1. Encode an integral value ready to send
Please implement the static method `TelemetryBuffer.ToBuffer()` to encode a buffer taking the parameter passed to the method.
```csharp
// Type: ushort, bytes: 2, signed: no, prefix byte: 2
TelemetryBuffer.ToBuffer(5)
// => {0x2, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
// Type: int, bytes: 4, signed: yes, prefix byte: 256 - 4
TelemetryBuffer.ToBuffer(Int32.MaxValue)
// => {0xfc, 0xff, 0xff, 0xff, 0x7f, 0x0, 0x0, 0x0, 0x0 };
```
## 2. Decode a received buffer
Please implement the static method `TelemetryBuffer.FromBuffer()` to decode the buffer received and return the value in the form of a `long`.
```csharp
TelemetryBuffer.FromBuffer(new byte[] {0xfc, 0xff, 0xff, 0xff, 0x7f, 0x0, 0x0, 0x0, 0x0 })
// => 2147483647
```
If the prefix byte is not one of `-8`, `-4`, `-2`, `2` or `4` then `0` should be returned.
## Source
### Created by
- @mikedamay
### Contributed to by
- @ErikSchierboom
- @yzAlvin

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
public enum Plant
@ -12,8 +11,9 @@ public enum Plant
public class KindergartenGarden
{
private List<string> roster;
private Dictionary<string, List<Plant>> plants;
private readonly List<string> roster;
private readonly string row1;
private readonly string row2;
private static readonly IDictionary<char, Plant> PlantCodesToPlants = new Dictionary<char, Plant>
{
@ -25,32 +25,23 @@ public class KindergartenGarden
public KindergartenGarden(string diagram)
{
var plants = diagram.Split('\n');
row1 = plants[0]; row2 = plants[1];
roster = new List<string>
{
"Alice", "Bob", "Charlie", "David",
"Eve", "Fred", "Ginny", "Harriet",
"Ileana", "Joseph", "Kincaid", "Larry"
};
BuildFromDiagram(diagram);
}
public KindergartenGarden(string diagram, IEnumerable<string> students)
{
roster = students.ToList();
BuildFromDiagram(diagram);
}
private void BuildFromDiagram(string diagram)
{
var rows = diagram.Split("\n");
foreach (var student in roster)
{
}
}
public IEnumerable<Plant> Plants(string student)
{
throw new NotImplementedException("You need to implement this function.");
var i = 2 * roster.IndexOf(student);
var plants = new List<Plant>();
plants.AddRange(row1[i..(i + 2)].Select(p => PlantCodesToPlants[p]));
plants.AddRange(row2[i..(i + 2)].Select(p => PlantCodesToPlants[p]));
return plants;
}
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -11,56 +11,56 @@ public class KindergartenGardenTest
Assert.Equal(new[] { Plant.Radishes, Plant.Clover, Plant.Grass, Plant.Grass }, sut.Plants("Alice"));
}
[Fact(Skip = "Remove to run test")]
[Fact]
public void Partial_garden_different_garden_with_single_student()
{
var sut = new KindergartenGarden("VC\nRC");
Assert.Equal(new[] { Plant.Violets, Plant.Clover, Plant.Radishes, Plant.Clover }, sut.Plants("Alice"));
}
[Fact(Skip = "Remove to run test")]
[Fact]
public void Partial_garden_garden_with_two_students()
{
var sut = new KindergartenGarden("VVCG\nVVRC");
Assert.Equal(new[] { Plant.Clover, Plant.Grass, Plant.Radishes, Plant.Clover }, sut.Plants("Bob"));
}
[Fact(Skip = "Remove to run test")]
[Fact]
public void Partial_garden_multiple_students_for_the_same_garden_with_three_students_second_students_garden()
{
var sut = new KindergartenGarden("VVCCGG\nVVCCGG");
Assert.Equal(new[] { Plant.Clover, Plant.Clover, Plant.Clover, Plant.Clover }, sut.Plants("Bob"));
}
[Fact(Skip = "Remove to run test")]
[Fact]
public void Partial_garden_multiple_students_for_the_same_garden_with_three_students_third_students_garden()
{
var sut = new KindergartenGarden("VVCCGG\nVVCCGG");
Assert.Equal(new[] { Plant.Grass, Plant.Grass, Plant.Grass, Plant.Grass }, sut.Plants("Charlie"));
}
[Fact(Skip = "Remove to run test")]
[Fact]
public void Full_garden_first_students_garden()
{
var sut = new KindergartenGarden("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV");
Assert.Equal(new[] { Plant.Violets, Plant.Radishes, Plant.Violets, Plant.Radishes }, sut.Plants("Alice"));
}
[Fact(Skip = "Remove to run test")]
[Fact]
public void Full_garden_second_students_garden()
{
var sut = new KindergartenGarden("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV");
Assert.Equal(new[] { Plant.Clover, Plant.Grass, Plant.Clover, Plant.Clover }, sut.Plants("Bob"));
}
[Fact(Skip = "Remove to run test")]
[Fact]
public void Full_garden_second_to_last_students_garden()
{
var sut = new KindergartenGarden("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV");
Assert.Equal(new[] { Plant.Grass, Plant.Clover, Plant.Clover, Plant.Grass }, sut.Plants("Kincaid"));
}
[Fact(Skip = "Remove to run test")]
[Fact]
public void Full_garden_last_students_garden()
{
var sut = new KindergartenGarden("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV");

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -0,0 +1,141 @@
###############################
# Core EditorConfig Options #
###############################
; This file is for unifying the coding style for different editors and IDEs.
; More information at:
; https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2017
; https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2017
root = true
[*]
indent_style = space
[RationalNumbers.cs]
indent_size = 4
###############################
# .NET Coding Conventions #
###############################
# Organize usings
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = true
# this. preferences
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
# Language keywords vs BCL types preferences
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion
# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
# Modifier preferences
dotnet_style_require_accessibility_modifiers = always:suggestion
dotnet_style_readonly_field = true:suggestion
# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
###############################
# Naming Conventions #
###############################
# Style Definitions
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const
###############################
# C# Code Style Rules #
###############################
# var preferences
csharp_style_var_for_built_in_types = true:none
csharp_style_var_when_type_is_apparent = true:none
csharp_style_var_elsewhere = true:none
# Expression-bodied members
csharp_style_expression_bodied_methods = true:suggestion
csharp_style_expression_bodied_constructors = true:suggestion
csharp_style_expression_bodied_operators = true:suggestion
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_accessors = true:suggestion
# Pattern-matching preferences
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
# Null-checking preferences
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion
# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
# Expression-level preferences
csharp_prefer_braces = true:none
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_pattern_local_over_anonymous_function = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
###############################
# C# Formatting Rules #
###############################
# New line preferences
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_before_members_in_anonymous_types = false
csharp_new_line_between_query_expression_clauses = true
# Indentation preferences
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left
# Space preferences
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
# Wrapping preferences
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true

View File

@ -0,0 +1,25 @@
{
"blurb": "Implement rational numbers.",
"authors": [
"ShamilS"
],
"contributors": [
"ErikSchierboom",
"j2jensen",
"robkeim",
"wolf99"
],
"files": {
"solution": [
"RationalNumbers.cs"
],
"test": [
"RationalNumbersTests.cs"
],
"example": [
".meta/Example.cs"
]
},
"source": "Wikipedia",
"source_url": "https://en.wikipedia.org/wiki/Rational_number"
}

View File

@ -0,0 +1 @@
{"track":"csharp","exercise":"rational-numbers","id":"d09d0090713e4de5a261f300cdb7800f","url":"https://exercism.org/tracks/csharp/exercises/rational-numbers","handle":"benharri","is_requester":true,"auto_approve":false}

View File

@ -0,0 +1,39 @@
# Help
## Running the tests
You can run the tests by opening a command prompt in the exercise's directory, and then running the [`dotnet test` command](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test)
Alternatively, most IDE's have built-in support for running tests, including [Visual Studio](https://docs.microsoft.com/en-us/visualstudio/test/run-unit-tests-with-test-explorer), [Rider](https://www.jetbrains.com/help/rider/Unit_Testing_in_Solution.html) and [Visual Studio code](https://github.com/OmniSharp/omnisharp-vscode/wiki/How-to-run-and-debug-unit-tests).
See the [tests page](https://exercism.io/tracks/csharp/tests) for more information.
## Skipped tests
Initially, only the first test will be enabled.
This is to encourage you to solve the exercise one step at a time.
Once you get the first test passing, remove the `Skip` property from the next test and work on getting that test passing.
## Submitting your solution
You can submit your solution using the `exercism submit RationalNumbers.cs` command.
This command will upload your solution to the Exercism website and print the solution page's URL.
It's possible to submit an incomplete solution which allows you to:
- See how others have completed the exercise
- Request help from a mentor
## Need to get help?
If you'd like help solving the exercise, check the following pages:
- The [C# track's documentation](https://exercism.org/docs/tracks/csharp)
- [Exercism's support channel on gitter](https://gitter.im/exercism/support)
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
To get help if you're having trouble, you can use one of the following resources:
- [Gitter](https://gitter.im/exercism/xcsharp) is Exercism C# track's Gitter room; go here to get support and ask questions related to the C# track.
- [/r/csharp](https://www.reddit.com/r/csharp) is the C# subreddit.
- [StackOverflow](http://stackoverflow.com/questions/tagged/c%23) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.

View File

@ -0,0 +1,51 @@
# Rational Numbers
Welcome to Rational Numbers on Exercism's C# Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
## Instructions
A rational number is defined as the quotient of two integers `a` and `b`, called the numerator and denominator, respectively, where `b != 0`.
The absolute value `|r|` of the rational number `r = a/b` is equal to `|a|/|b|`.
The sum of two rational numbers `r₁ = a₁/b₁` and `r₂ = a₂/b₂` is `r₁ + r₂ = a₁/b₁ + a₂/b₂ = (a₁ * b₂ + a₂ * b₁) / (b₁ * b₂)`.
The difference of two rational numbers `r₁ = a₁/b₁` and `r₂ = a₂/b₂` is `r₁ - r₂ = a₁/b₁ - a₂/b₂ = (a₁ * b₂ - a₂ * b₁) / (b₁ * b₂)`.
The product (multiplication) of two rational numbers `r₁ = a₁/b₁` and `r₂ = a₂/b₂` is `r₁ * r₂ = (a₁ * a₂) / (b₁ * b₂)`.
Dividing a rational number `r₁ = a₁/b₁` by another `r₂ = a₂/b₂` is `r₁ / r₂ = (a₁ * b₂) / (a₂ * b₁)` if `a₂` is not zero.
Exponentiation of a rational number `r = a/b` to a non-negative integer power `n` is `r^n = (a^n)/(b^n)`.
Exponentiation of a rational number `r = a/b` to a negative integer power `n` is `r^n = (b^m)/(a^m)`, where `m = |n|`.
Exponentiation of a rational number `r = a/b` to a real (floating-point) number `x` is the quotient `(a^x)/(b^x)`, which is a real number.
Exponentiation of a real number `x` to a rational number `r = a/b` is `x^(a/b) = root(x^a, b)`, where `root(p, q)` is the `q`th root of `p`.
Implement the following operations:
- addition, subtraction, multiplication and division of two rational numbers,
- absolute value, exponentiation of a given rational number to an integer power, exponentiation of a given rational number to a real (floating-point) power, exponentiation of a real number to a rational number.
Your implementation of rational numbers should always be reduced to lowest terms. For example, `4/4` should reduce to `1/1`, `30/60` should reduce to `1/2`, `12/8` should reduce to `3/2`, etc. To reduce a rational number `r = a/b`, divide `a` and `b` by the greatest common divisor (gcd) of `a` and `b`. So, for example, `gcd(12, 8) = 4`, so `r = 12/8` can be reduced to `(12/4)/(8/4) = 3/2`.
Assume that the programming language you are using does not have an implementation of rational numbers.
## Source
### Created by
- @ShamilS
### Contributed to by
- @ErikSchierboom
- @j2jensen
- @robkeim
- @wolf99
### Based on
Wikipedia - https://en.wikipedia.org/wiki/Rational_number

View File

@ -0,0 +1,60 @@
using System;
public static class RealNumberExtension
{
public static double Expreal(this int realNumber, RationalNumber r) =>
Math.Pow(realNumber, r.AsDouble());
}
public struct RationalNumber
{
private int _numerator;
private int _denominator;
public RationalNumber(int numerator, int denominator)
{
_numerator = numerator;
_denominator = denominator;
if (_denominator < 0)
{
_numerator = -_numerator;
_denominator = -_denominator;
}
}
public override string ToString() => $"{_numerator} / {_denominator}";
public static RationalNumber operator +(RationalNumber r1, RationalNumber r2) =>
new(r1._numerator * r2._denominator + r2._numerator * r1._denominator, r1._denominator * r2._denominator);
public static RationalNumber operator -(RationalNumber r1, RationalNumber r2) =>
r1 with { _numerator = -r1._numerator } + r2;
public static RationalNumber operator *(RationalNumber r1, RationalNumber r2) =>
new(r1._numerator * r2._numerator, r1._denominator * r2._denominator);
public static RationalNumber operator /(RationalNumber r1, RationalNumber r2) =>
new(r1._numerator * r2._denominator, r1._denominator * r2._numerator);
public RationalNumber Abs() =>
new(Math.Abs(_numerator), Math.Abs(_denominator));
public RationalNumber Reduce()
{
var gcd = GreatestCommonDivisor(_numerator, _denominator);
return new(_numerator / gcd, _denominator / gcd);
}
public RationalNumber Exprational(int power) =>
new((int)Math.Pow(_numerator, power), (int)Math.Pow(_denominator, power));
public double Expreal(int baseNumber) =>
Math.Pow(Math.Pow(baseNumber, _numerator), 1d / _denominator);
public static int GreatestCommonDivisor(int a, int b) =>
b == 0 ? a : GreatestCommonDivisor(b, a % b);
public double AsDouble() =>
_numerator / (double)_denominator;
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="Exercism.Tests" Version="0.1.0-beta1" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,232 @@
using Xunit;
public class RationalNumbersTests
{
[Fact]
public void Add_two_positive_rational_numbers()
{
Assert.Equal(new RationalNumber(7, 6), new RationalNumber(1, 2) + (new RationalNumber(2, 3)));
}
[Fact]
public void Add_a_positive_rational_number_and_a_negative_rational_number()
{
Assert.Equal(new RationalNumber(-1, 6), new RationalNumber(1, 2) + (new RationalNumber(-2, 3)));
}
[Fact]
public void Add_two_negative_rational_numbers()
{
Assert.Equal(new RationalNumber(-7, 6), new RationalNumber(-1, 2) + (new RationalNumber(-2, 3)));
}
[Fact]
public void Add_a_rational_number_to_its_additive_inverse()
{
Assert.Equal(new RationalNumber(0, 1), new RationalNumber(1, 2) + (new RationalNumber(-1, 2)));
}
[Fact]
public void Subtract_two_positive_rational_numbers()
{
Assert.Equal(new RationalNumber(-1, 6), new RationalNumber(1, 2) - (new RationalNumber(2, 3)));
}
[Fact]
public void Subtract_a_positive_rational_number_and_a_negative_rational_number()
{
Assert.Equal(new RationalNumber(7, 6), new RationalNumber(1, 2) - (new RationalNumber(-2, 3)));
}
[Fact]
public void Subtract_two_negative_rational_numbers()
{
Assert.Equal(new RationalNumber(1, 6), new RationalNumber(-1, 2) - (new RationalNumber(-2, 3)));
}
[Fact]
public void Subtract_a_rational_number_from_itself()
{
Assert.Equal(new RationalNumber(0, 1), new RationalNumber(1, 2) - (new RationalNumber(1, 2)));
}
[Fact]
public void Multiply_two_positive_rational_numbers()
{
Assert.Equal(new RationalNumber(1, 3), new RationalNumber(1, 2) * (new RationalNumber(2, 3)));
}
[Fact]
public void Multiply_a_negative_rational_number_by_a_positive_rational_number()
{
Assert.Equal(new RationalNumber(-1, 3), new RationalNumber(-1, 2) * (new RationalNumber(2, 3)));
}
[Fact]
public void Multiply_two_negative_rational_numbers()
{
Assert.Equal(new RationalNumber(1, 3), new RationalNumber(-1, 2) * (new RationalNumber(-2, 3)));
}
[Fact]
public void Multiply_a_rational_number_by_its_reciprocal()
{
Assert.Equal(new RationalNumber(1, 1), new RationalNumber(1, 2) * (new RationalNumber(2, 1)));
}
[Fact]
public void Multiply_a_rational_number_by_1()
{
Assert.Equal(new RationalNumber(1, 2), new RationalNumber(1, 2) * (new RationalNumber(1, 1)));
}
[Fact]
public void Multiply_a_rational_number_by_0()
{
Assert.Equal(new RationalNumber(0, 1), new RationalNumber(1, 2) * (new RationalNumber(0, 1)));
}
[Fact]
public void Divide_two_positive_rational_numbers()
{
Assert.Equal(new RationalNumber(3, 4), new RationalNumber(1, 2) / (new RationalNumber(2, 3)));
}
[Fact]
public void Divide_a_positive_rational_number_by_a_negative_rational_number()
{
Assert.Equal(new RationalNumber(-3, 4), new RationalNumber(1, 2) / (new RationalNumber(-2, 3)));
}
[Fact]
public void Divide_two_negative_rational_numbers()
{
Assert.Equal(new RationalNumber(3, 4), new RationalNumber(-1, 2) / (new RationalNumber(-2, 3)));
}
[Fact]
public void Divide_a_rational_number_by_1()
{
Assert.Equal(new RationalNumber(1, 2), new RationalNumber(1, 2) / (new RationalNumber(1, 1)));
}
[Fact]
public void Absolute_value_of_a_positive_rational_number()
{
Assert.Equal(new RationalNumber(1, 2), new RationalNumber(1, 2).Abs());
}
[Fact]
public void Absolute_value_of_a_positive_rational_number_with_negative_numerator_and_denominator()
{
Assert.Equal(new RationalNumber(1, 2), new RationalNumber(-1, -2).Abs());
}
[Fact]
public void Absolute_value_of_a_negative_rational_number()
{
Assert.Equal(new RationalNumber(1, 2), new RationalNumber(-1, 2).Abs());
}
[Fact]
public void Absolute_value_of_a_negative_rational_number_with_negative_denominator()
{
Assert.Equal(new RationalNumber(1, 2), new RationalNumber(1, -2).Abs());
}
[Fact]
public void Absolute_value_of_zero()
{
Assert.Equal(new RationalNumber(0, 1), new RationalNumber(0, 1).Abs());
}
[Fact]
public void Raise_a_positive_rational_number_to_a_positive_integer_power()
{
Assert.Equal(new RationalNumber(1, 8), new RationalNumber(1, 2).Exprational(3));
}
[Fact]
public void Raise_a_negative_rational_number_to_a_positive_integer_power()
{
Assert.Equal(new RationalNumber(-1, 8), new RationalNumber(-1, 2).Exprational(3));
}
[Fact]
public void Raise_zero_to_an_integer_power()
{
Assert.Equal(new RationalNumber(0, 1), new RationalNumber(0, 1).Exprational(5));
}
[Fact]
public void Raise_one_to_an_integer_power()
{
Assert.Equal(new RationalNumber(1, 1), new RationalNumber(1, 1).Exprational(4));
}
[Fact]
public void Raise_a_positive_rational_number_to_the_power_of_zero()
{
Assert.Equal(new RationalNumber(1, 1), new RationalNumber(1, 2).Exprational(0));
}
[Fact]
public void Raise_a_negative_rational_number_to_the_power_of_zero()
{
Assert.Equal(new RationalNumber(1, 1), new RationalNumber(-1, 2).Exprational(0));
}
[Fact]
public void Raise_a_real_number_to_a_positive_rational_number()
{
Assert.Equal(16, 8.Expreal(new RationalNumber(4, 3)), precision: 7);
}
[Fact]
public void Raise_a_real_number_to_a_negative_rational_number()
{
Assert.Equal(0.33333334, 9.Expreal(new RationalNumber(-1, 2)), precision: 7);
}
[Fact]
public void Raise_a_real_number_to_a_zero_rational_number()
{
Assert.Equal(1, 2.Expreal(new RationalNumber(0, 1)), precision: 7);
}
[Fact]
public void Reduce_a_positive_rational_number_to_lowest_terms()
{
Assert.Equal(new RationalNumber(1, 2), new RationalNumber(2, 4).Reduce());
}
[Fact]
public void Reduce_a_negative_rational_number_to_lowest_terms()
{
Assert.Equal(new RationalNumber(-2, 3), new RationalNumber(-4, 6).Reduce());
}
[Fact]
public void Reduce_a_rational_number_with_a_negative_denominator_to_lowest_terms()
{
Assert.Equal(new RationalNumber(-1, 3), new RationalNumber(3, -9).Reduce());
}
[Fact]
public void Reduce_zero_to_lowest_terms()
{
Assert.Equal(new RationalNumber(0, 1), new RationalNumber(0, 6).Reduce());
}
[Fact]
public void Reduce_an_integer_to_lowest_terms()
{
Assert.Equal(new RationalNumber(-2, 1), new RationalNumber(-14, 7).Reduce());
}
[Fact]
public void Reduce_one_to_lowest_terms()
{
Assert.Equal(new RationalNumber(1, 1), new RationalNumber(13, 13).Reduce());
}
}

View File

@ -0,0 +1,4 @@
# Hints
This exercise requires you to write an extension method. For more information, see [this page](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods).
This exercise also requires you to write operator overloading methods for +, -, * and / operators. For more information, see [this page](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/operator-overloading).

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -8,7 +8,7 @@ public class SpiralMatrixTests
Assert.Empty(SpiralMatrix.GetMatrix(0));
}
[Fact(Skip = "Remove this Skip property to run this test")]
[Fact]
public void Trivial_spiral()
{
var expected = new[,]
@ -18,7 +18,7 @@ public class SpiralMatrixTests
Assert.Equal(expected, SpiralMatrix.GetMatrix(1));
}
[Fact(Skip = "Remove this Skip property to run this test")]
[Fact]
public void Spiral_of_size_2()
{
var expected = new[,]
@ -29,7 +29,7 @@ public class SpiralMatrixTests
Assert.Equal(expected, SpiralMatrix.GetMatrix(2));
}
[Fact(Skip = "Remove this Skip property to run this test")]
[Fact]
public void Spiral_of_size_3()
{
var expected = new[,]
@ -41,7 +41,7 @@ public class SpiralMatrixTests
Assert.Equal(expected, SpiralMatrix.GetMatrix(3));
}
[Fact(Skip = "Remove this Skip property to run this test")]
[Fact]
public void Spiral_of_size_4()
{
var expected = new[,]
@ -54,7 +54,7 @@ public class SpiralMatrixTests
Assert.Equal(expected, SpiralMatrix.GetMatrix(4));
}
[Fact(Skip = "Remove this Skip property to run this test")]
[Fact]
public void Spiral_of_size_5()
{
var expected = new[,]

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -35,7 +35,7 @@ class Wizard : Character
public override bool Vulnerable() => vulnerable;
public override int DamagePoints(Character target) => vulnerable ? 12 : 3;
public override int DamagePoints(Character target) => vulnerable ? 3 : 12;
public void PrepareSpell() => vulnerable = false;
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>