├── .gitattributes ├── .gitignore ├── A-Star └── readme.md ├── AcronymExpansion └── readme.md ├── BankOcrBootcamp ├── PartialSolutionFromBootcamp │ ├── .gitattributes │ ├── .gitignore │ ├── LICENSE │ ├── TDD101.sln │ ├── TDD101.v2.ncrunchsolution │ └── TddOneOhOne │ │ ├── Class1.cs │ │ ├── IRecogniseCharacter.cs │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── TddOneOhOne.csproj │ │ ├── TddOneOhOne.v2.ncrunchproject │ │ └── packages.config └── README.md ├── BloomFilters └── readme.md ├── Braille ├── grade2.gif ├── guide.png ├── punc.gif ├── readme.md └── uncontracted.gif ├── BuildATestFramework └── readme.md ├── BuildMonitor └── readme.md ├── BuildingFluentApis ├── AssertThat │ └── ClassLibrary1 │ │ ├── ClassLibrary1.sln │ │ ├── ClassLibrary1 │ │ ├── Class1.cs │ │ ├── ClassLibrary1.csproj │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── packages.config │ │ └── packages │ │ ├── NUnit.2.6.4 │ │ ├── NUnit.2.6.4.nupkg │ │ ├── NUnit.2.6.4.nuspec │ │ ├── lib │ │ │ ├── nunit.framework.dll │ │ │ └── nunit.framework.xml │ │ └── license.txt │ │ └── repositories.config └── README.md ├── ChristmasLights ├── answer.md ├── answer2.md ├── input.txt └── readme.md ├── CircuitBreaker └── readme.md ├── Concordance ├── magna_carta.txt └── readme.md ├── ConwaysGameOfLife └── readme.md ├── CreditCardValidation └── readme.md ├── Cryptograms └── readme.md ├── DeletingCodeComments └── readme.md ├── Diamond Kata └── readme.md ├── Dijkstra └── readme.md ├── Draughts └── readme.md ├── FloodFill └── readme.md ├── GEDCOM └── readme.md ├── HumanReadableUrls └── readme.md ├── ISBNValidator └── readme.md ├── InputHandling └── readme.md ├── IoCContainer └── readme.md ├── LICENSE ├── MarkovChains ├── alice-in-wonderland-pg11.txt ├── readme.md └── war-and-peace-pg2600.txt ├── MarsRover └── README.md ├── MatchMaking └── readme.md ├── MethodAutoCompletion └── readme.md ├── MorseCode ├── README.md └── Solutions │ └── Dw-C# │ ├── Class1.cs │ └── words.txt ├── ParsingMp3Tags ├── frederic-chopin-piano-sonata-2-op35-3-funeral-march.mp3 └── readme.md ├── README.md ├── Retrying └── readme.md ├── RomanNumerals └── readme.md ├── SassBasics └── readme.md ├── SecretSanta └── README.md ├── Tetris ├── readme.md └── srs.png ├── TextImages ├── Ducky.png └── readme.md ├── Throttling └── readme.md ├── WordChains └── readme.md ├── WordSearchSolver └── readme.md └── words.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | 11 | [Dd]ebug/ 12 | [Rr]elease/ 13 | x64/ 14 | build/ 15 | [Bb]in/ 16 | [Oo]bj/ 17 | 18 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 19 | !packages/*/build/ 20 | 21 | # MSTest test Results 22 | [Tt]est[Rr]esult*/ 23 | [Bb]uild[Ll]og.* 24 | 25 | *_i.c 26 | *_p.c 27 | *.ilk 28 | *.meta 29 | *.obj 30 | *.pch 31 | *.pdb 32 | *.pgc 33 | *.pgd 34 | *.rsp 35 | *.sbr 36 | *.tlb 37 | *.tli 38 | *.tlh 39 | *.tmp 40 | *.tmp_proj 41 | *.log 42 | *.vspscc 43 | *.vssscc 44 | .builds 45 | *.pidb 46 | *.log 47 | *.scc 48 | 49 | # Visual C++ cache files 50 | ipch/ 51 | *.aps 52 | *.ncb 53 | *.opensdf 54 | *.sdf 55 | *.cachefile 56 | 57 | # Visual Studio profiler 58 | *.psess 59 | *.vsp 60 | *.vspx 61 | 62 | # Guidance Automation Toolkit 63 | *.gpState 64 | 65 | # ReSharper is a .NET coding add-in 66 | _ReSharper*/ 67 | *.[Rr]e[Ss]harper 68 | 69 | # TeamCity is a build add-in 70 | _TeamCity* 71 | 72 | # DotCover is a Code Coverage Tool 73 | *.dotCover 74 | 75 | # NCrunch 76 | *.ncrunch* 77 | .*crunch*.local.xml 78 | 79 | # Installshield output folder 80 | [Ee]xpress/ 81 | 82 | # DocProject is a documentation generator add-in 83 | DocProject/buildhelp/ 84 | DocProject/Help/*.HxT 85 | DocProject/Help/*.HxC 86 | DocProject/Help/*.hhc 87 | DocProject/Help/*.hhk 88 | DocProject/Help/*.hhp 89 | DocProject/Help/Html2 90 | DocProject/Help/html 91 | 92 | # Click-Once directory 93 | publish/ 94 | 95 | # Publish Web Output 96 | *.Publish.xml 97 | 98 | # NuGet Packages Directory 99 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 100 | #packages/ 101 | 102 | # Windows Azure Build Output 103 | csx 104 | *.build.csdef 105 | 106 | # Windows Store app package directory 107 | AppPackages/ 108 | 109 | # Others 110 | sql/ 111 | *.Cache 112 | ClientBin/ 113 | [Ss]tyle[Cc]op.* 114 | ~$* 115 | *~ 116 | *.dbmdl 117 | *.[Pp]ublish.xml 118 | *.pfx 119 | *.publishsettings 120 | 121 | # RIA/Silverlight projects 122 | Generated_Code/ 123 | 124 | # Backup & report files from converting an old project file to a newer 125 | # Visual Studio version. Backup files are not needed, because we have git ;-) 126 | _UpgradeReport_Files/ 127 | Backup*/ 128 | UpgradeLog*.XML 129 | UpgradeLog*.htm 130 | 131 | # SQL Server files 132 | App_Data/*.mdf 133 | App_Data/*.ldf 134 | 135 | 136 | #LightSwitch generated files 137 | GeneratedArtifacts/ 138 | _Pvt_Extensions/ 139 | ModelManifest.xml 140 | 141 | # ========================= 142 | # Windows detritus 143 | # ========================= 144 | 145 | # Windows image file caches 146 | Thumbs.db 147 | ehthumbs.db 148 | 149 | # Folder config file 150 | Desktop.ini 151 | 152 | # Recycle Bin used on file shares 153 | $RECYCLE.BIN/ 154 | 155 | # Mac desktop service store files 156 | .DS_Store 157 | -------------------------------------------------------------------------------- /A-Star/readme.md: -------------------------------------------------------------------------------- 1 | A* for path-finding 2 | ====================================== 3 | 4 | The A* (A-Star) search algorithm is a path-finding algorithm with many uses, including Artificial Intelligence for games. 5 | 6 | The search builds the route from tile to tile until it reaches the goal. To help choose the best possible tile the algorithm will use an equation that takes into account the distance from the tile to the goal and the cost of moving to that tile. 7 | 8 | Example 9 | ========== 10 | 11 | **Step 1:** Search the surrounding tiles for walkable choices. 12 | 13 | **Step 2:** Go through that list finding the cost of movement for each of those choice tiles. The cost of movement is the path cost so far, plus the cost to move to the tile being considered. 14 | 15 | **Step 3:** Determine the distance from the choice tiles to the goal and add that to the cost from Step 2 to find the score for each tile. 16 | 17 | You can calculate the distance from the tile to the goal using **Manhattan distance** formula 18 | 19 | > (x1 - x2) + (y1 - y2). 20 | 21 | **Step 4:** Choose the best tile to move to by comparing the score of the surrounding tiles and choosing the lowest. 22 | 23 | **Step 5:** **Repeat Steps 1-4** until you reach the goal tile. Be careful to prevent checking tiles twice and/or circling back. 24 | 25 | 26 | Build a pathfinder 27 | =================== 28 | 29 | We're going to implement the A* algorithm to pathfind our way across maps like the one provided below. 30 | Paths can be diagonal. 31 | 32 | * **S** Starting point 33 | * **D** Destination 34 | * **.** Flat ground - difficultly cost 1 35 | * **V** Forest - difficulty cost 5 36 | * **#** Cliffs / un-traversable 37 | 38 |
39 | 
40 |     ..........D.VVV
41 |     ..........VVVVV
42 |     ..#########VVVV
43 |     ......#####VVVV
44 |     ........###VVVV
45 |     ...........VVVV
46 |     .............VV
47 |     .............S.
48 | 
49 | 
50 | 51 | # Simple pathfinding 52 | 53 | As an Pathfinding AI 54 | Given a 3x3 block 55 | I will pathfind diagonally 56 | 57 |
58 |     S..
59 |     ...
60 |     ..D
61 | 
62 | 63 | Accept 64 | 65 | * Path output to console 66 | * Path marked with X's 67 | 68 | # Pathfinding around a blockaid 69 | 70 | As an Pathfinding AI 71 | Given a 3x3 block with a blockaid 72 | I will pathfind around the blockaid 73 | 74 |
75 |     S..
76 |     ##.
77 |     D..
78 | 
79 | 80 | # Pathfinding around slow terrain 81 | 82 | As an Pathfinding AI 83 | Given a 3x3 block where the direct route is slow 84 | I will pathfind around the slow path 85 | 86 |
87 |     S..
88 |     V..
89 |     D..
90 | 
91 | 92 | # Acknowledgements 93 | 94 | This is derived from a Rubyquiz.com quiz here - http://rubyquiz.com/quiz98.html 95 | -------------------------------------------------------------------------------- /AcronymExpansion/readme.md: -------------------------------------------------------------------------------- 1 | # Origin 2 | 3 | This kata is adapted from reddit.com/r/dailyprogrammer - http://www.reddit.com/r/dailyprogrammer/comments/2ptrmp/20141219_challenge_193_easy_acronym_expander/ 4 | 5 | # Description 6 | 7 | During online gaming (or any video game that requires teamwork), there is often times that you need to speak to your teammates. 8 | Given the nature of the game, it may be inconvenient to say full sentences and it's for this reason that a lot of games have acronyms in place of sentences that are regularly said. 9 | 10 | Example 11 | 12 | gg : expands to 'Good Game' 13 | brb : expands to 'be right back' 14 | 15 | All this abbreviated text can be confusing and intimidating for someone new to a game. They're not going to instantly know what 16 | 17 | 'gl hf all' (good luck have fun all) 18 | 19 | means. 20 | 21 | You are tasked with converting an abbreviated sentence into its full version. 22 | 23 | ## Wordlist 24 | 25 | lol - laugh out loud 26 | dw - don't worry 27 | hf - have fun 28 | gg - good game 29 | brb - be right back 30 | g2g - got to go 31 | wp - well played 32 | gl - good luck 33 | imo - in my opinion 34 | 35 | ## Story 1 - Expand abbreviations 36 | 37 | As a newbie 38 | When I read some text 39 | Abbreviations are exploded into their full phrases 40 | 41 | ## Story 2 - Avoid sub-words 42 | 43 | As a newbie 44 | When a word contains an abbreviation 45 | The word isn't broken up 46 | 47 | Accept: "there's a global variable over there" 48 | does not explode to 49 | "there's a good luck obal variable over there" 50 | -------------------------------------------------------------------------------- /BankOcrBootcamp/PartialSolutionFromBootcamp/.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /BankOcrBootcamp/PartialSolutionFromBootcamp/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | [Rr]eleases/ 14 | x64/ 15 | x86/ 16 | build/ 17 | bld/ 18 | [Bb]in/ 19 | [Oo]bj/ 20 | 21 | # Roslyn cache directories 22 | *.ide/ 23 | 24 | # MSTest test Results 25 | [Tt]est[Rr]esult*/ 26 | [Bb]uild[Ll]og.* 27 | 28 | #NUNIT 29 | *.VisualState.xml 30 | TestResult.xml 31 | 32 | # Build Results of an ATL Project 33 | [Dd]ebugPS/ 34 | [Rr]eleasePS/ 35 | dlldata.c 36 | 37 | *_i.c 38 | *_p.c 39 | *_i.h 40 | *.ilk 41 | *.meta 42 | *.obj 43 | *.pch 44 | *.pdb 45 | *.pgc 46 | *.pgd 47 | *.rsp 48 | *.sbr 49 | *.tlb 50 | *.tli 51 | *.tlh 52 | *.tmp 53 | *.tmp_proj 54 | *.log 55 | *.vspscc 56 | *.vssscc 57 | .builds 58 | *.pidb 59 | *.svclog 60 | *.scc 61 | 62 | # Chutzpah Test files 63 | _Chutzpah* 64 | 65 | # Visual C++ cache files 66 | ipch/ 67 | *.aps 68 | *.ncb 69 | *.opensdf 70 | *.sdf 71 | *.cachefile 72 | 73 | # Visual Studio profiler 74 | *.psess 75 | *.vsp 76 | *.vspx 77 | 78 | # TFS 2012 Local Workspace 79 | $tf/ 80 | 81 | # Guidance Automation Toolkit 82 | *.gpState 83 | 84 | # ReSharper is a .NET coding add-in 85 | _ReSharper*/ 86 | *.[Rr]e[Ss]harper 87 | *.DotSettings.user 88 | 89 | # JustCode is a .NET coding addin-in 90 | .JustCode 91 | 92 | # TeamCity is a build add-in 93 | _TeamCity* 94 | 95 | # DotCover is a Code Coverage Tool 96 | *.dotCover 97 | 98 | # NCrunch 99 | _NCrunch_* 100 | .*crunch*.local.xml 101 | 102 | # MightyMoose 103 | *.mm.* 104 | AutoTest.Net/ 105 | 106 | # Web workbench (sass) 107 | .sass-cache/ 108 | 109 | # Installshield output folder 110 | [Ee]xpress/ 111 | 112 | # DocProject is a documentation generator add-in 113 | DocProject/buildhelp/ 114 | DocProject/Help/*.HxT 115 | DocProject/Help/*.HxC 116 | DocProject/Help/*.hhc 117 | DocProject/Help/*.hhk 118 | DocProject/Help/*.hhp 119 | DocProject/Help/Html2 120 | DocProject/Help/html 121 | 122 | # Click-Once directory 123 | publish/ 124 | 125 | # Publish Web Output 126 | *.[Pp]ublish.xml 127 | *.azurePubxml 128 | # TODO: Comment the next line if you want to checkin your web deploy settings 129 | # but database connection strings (with potential passwords) will be unencrypted 130 | *.pubxml 131 | *.publishproj 132 | 133 | # NuGet Packages 134 | *.nupkg 135 | # The packages folder can be ignored because of Package Restore 136 | **/packages/* 137 | # except build/, which is used as an MSBuild target. 138 | !**/packages/build/ 139 | # If using the old MSBuild-Integrated Package Restore, uncomment this: 140 | #!**/packages/repositories.config 141 | 142 | # Windows Azure Build Output 143 | csx/ 144 | *.build.csdef 145 | 146 | # Windows Store app package directory 147 | AppPackages/ 148 | 149 | # Others 150 | sql/ 151 | *.Cache 152 | ClientBin/ 153 | [Ss]tyle[Cc]op.* 154 | ~$* 155 | *~ 156 | *.dbmdl 157 | *.dbproj.schemaview 158 | *.pfx 159 | *.publishsettings 160 | node_modules/ 161 | 162 | # RIA/Silverlight projects 163 | Generated_Code/ 164 | 165 | # Backup & report files from converting an old project file 166 | # to a newer Visual Studio version. Backup files are not needed, 167 | # because we have git ;-) 168 | _UpgradeReport_Files/ 169 | Backup*/ 170 | UpgradeLog*.XML 171 | UpgradeLog*.htm 172 | 173 | # SQL Server files 174 | *.mdf 175 | *.ldf 176 | 177 | # Business Intelligence projects 178 | *.rdl.data 179 | *.bim.layout 180 | *.bim_*.settings 181 | 182 | # Microsoft Fakes 183 | FakesAssemblies/ 184 | -------------------------------------------------------------------------------- /BankOcrBootcamp/PartialSolutionFromBootcamp/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 David Whitney 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /BankOcrBootcamp/PartialSolutionFromBootcamp/TDD101.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TddOneOhOne", "TddOneOhOne\TddOneOhOne.csproj", "{03B1FFC1-B9FD-43B1-AD6C-A25C24A925BA}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {03B1FFC1-B9FD-43B1-AD6C-A25C24A925BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {03B1FFC1-B9FD-43B1-AD6C-A25C24A925BA}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {03B1FFC1-B9FD-43B1-AD6C-A25C24A925BA}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {03B1FFC1-B9FD-43B1-AD6C-A25C24A925BA}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /BankOcrBootcamp/PartialSolutionFromBootcamp/TDD101.v2.ncrunchsolution: -------------------------------------------------------------------------------- 1 | 2 | 1 3 | true 4 | true 5 | UseDynamicAnalysis 6 | UseStaticAnalysis 7 | UseStaticAnalysis 8 | UseStaticAnalysis 9 | 10 | 11 | -------------------------------------------------------------------------------- /BankOcrBootcamp/PartialSolutionFromBootcamp/TddOneOhOne/Class1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using NUnit.Framework; 6 | 7 | namespace TddOneOhOne 8 | { 9 | [TestFixture] 10 | public class BankInputTokeniserTests 11 | { 12 | [Test] 13 | public void Tokenise_GivenOneKnownCharacter_ReturnsOneToken() 14 | { 15 | var tokeniser = new BankInputTokeniser(); 16 | 17 | const string input = 18 | @" _ 19 | | | 20 | |_|"; 21 | 22 | var tokens = tokeniser.TokeniseLine(input); 23 | 24 | Assert.That(tokens.Count, Is.EqualTo(1)); 25 | } 26 | 27 | [Test] 28 | public void Tokenise_GivenOneKnownCharacter_TokenReturnedContainsCorrectRawData() 29 | { 30 | var tokeniser = new BankInputTokeniser(); 31 | 32 | const string input = 33 | @" _ 34 | | | 35 | |_|"; 36 | 37 | var tokens = tokeniser.TokeniseLine(input); 38 | 39 | Assert.That(tokens[0].Raw[0], Is.EqualTo(" _ ")); 40 | Assert.That(tokens[0].Raw[1], Is.EqualTo("| |")); 41 | Assert.That(tokens[0].Raw[2], Is.EqualTo("|_|")); 42 | } 43 | 44 | [Test] 45 | public void Tokenise_GivenStringOfKnownCharacters_ReturnsCorrectNumberOfTokens() 46 | { 47 | var tokeniser = new BankInputTokeniser(); 48 | 49 | var input = 50 | @" _ _ _ _ _ _ _ _ _ 51 | | || || || || || || || || | 52 | |_||_||_||_||_||_||_||_||_|"; 53 | 54 | var tokens = tokeniser.TokeniseLine(input); 55 | 56 | Assert.That(tokens.Count, Is.EqualTo(9)); 57 | } 58 | 59 | } 60 | 61 | [TestFixture] 62 | public class BankOcrTests 63 | { 64 | [Test] 65 | public void RecogniseAZero_GivenSingleToken_Recognises() 66 | { 67 | var ocr = new Ocr(new []{new ZeroRecogniser(), }); 68 | var token = new Token 69 | { 70 | Raw = new List 71 | { 72 | {" _ "}, 73 | {"| |"}, 74 | {"|_|"} 75 | } 76 | }; 77 | 78 | var digits = ocr.Recognise(token); 79 | 80 | Assert.That(digits[0], Is.EqualTo(0)); 81 | } 82 | } 83 | 84 | [TestFixture] 85 | public class ZeroRecogniserTests 86 | { 87 | [Test] 88 | public void TryMatch_GivenZero_Matches() 89 | { 90 | var token = new Token 91 | { 92 | Raw = new List 93 | { 94 | {" _ "}, 95 | {"| |"}, 96 | {"|_|"} 97 | } 98 | }; 99 | 100 | var zr = new ZeroRecogniser(); 101 | 102 | var result = zr.TryMatch(token); 103 | 104 | Assert.That(result.Item1, Is.True); 105 | } 106 | } 107 | 108 | public class Ocr 109 | { 110 | private readonly IList _components; 111 | 112 | public Ocr(IList components) 113 | { 114 | _components = components; 115 | } 116 | 117 | public int[] Recognise(params Token[] tokens) 118 | { 119 | var ints = new List(); 120 | 121 | foreach (var token in tokens) 122 | { 123 | foreach (var c in _components) 124 | { 125 | var result = c.TryMatch(token); 126 | if (result.Item1) 127 | { 128 | ints.Add(Int32.Parse( result.Item2)); 129 | } 130 | } 131 | 132 | ints.Add(0); 133 | } 134 | 135 | return ints.ToArray(); 136 | } 137 | } 138 | 139 | public class BankInputTokeniser 140 | { 141 | public List TokeniseLine(string input) 142 | { 143 | var tokens = new List(); 144 | var lines = input.Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries); 145 | 146 | for (var startIndex = 0; startIndex < lines[0].Length; startIndex = startIndex+3) 147 | { 148 | var token = new Token(); 149 | token.Raw.Add(lines[0].Substring(startIndex, 3)); 150 | token.Raw.Add(lines[1].Substring(startIndex, 3)); 151 | token.Raw.Add(lines[2].Substring(startIndex, 3)); 152 | tokens.Add(token); 153 | 154 | } 155 | 156 | return tokens; 157 | } 158 | } 159 | 160 | public class Token 161 | { 162 | public List Raw { get; set; } 163 | 164 | public Token() 165 | { 166 | Raw = new List(); 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /BankOcrBootcamp/PartialSolutionFromBootcamp/TddOneOhOne/IRecogniseCharacter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace TddOneOhOne 6 | { 7 | public interface IRecogniseCharacter 8 | { 9 | Tuple TryMatch(Token token); 10 | } 11 | 12 | public class ZeroRecogniser : IRecogniseCharacter 13 | { 14 | private List _pattern = new List 15 | { 16 | {" _ "}, 17 | {"| |"}, 18 | {"|_|"} 19 | }; 20 | 21 | public Tuple TryMatch(Token token) 22 | { 23 | var matches = string.Concat(_pattern) == string.Concat(token.Raw); 24 | 25 | return new Tuple(matches, "0"); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /BankOcrBootcamp/PartialSolutionFromBootcamp/TddOneOhOne/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TddOneOhOne")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TddOneOhOne")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("95b15180-3965-42b8-89e5-0b8dcb188e04")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /BankOcrBootcamp/PartialSolutionFromBootcamp/TddOneOhOne/TddOneOhOne.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {03B1FFC1-B9FD-43B1-AD6C-A25C24A925BA} 8 | Library 9 | Properties 10 | TddOneOhOne 11 | TddOneOhOne 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\NUnit.2.6.3\lib\nunit.framework.dll 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 60 | -------------------------------------------------------------------------------- /BankOcrBootcamp/PartialSolutionFromBootcamp/TddOneOhOne/TddOneOhOne.v2.ncrunchproject: -------------------------------------------------------------------------------- 1 | 2 | false 3 | false 4 | false 5 | true 6 | false 7 | false 8 | false 9 | false 10 | false 11 | true 12 | true 13 | false 14 | true 15 | true 16 | true 17 | 60000 18 | 19 | 20 | 21 | AutoDetect 22 | STA 23 | x86 24 | -------------------------------------------------------------------------------- /BankOcrBootcamp/PartialSolutionFromBootcamp/TddOneOhOne/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /BankOcrBootcamp/README.md: -------------------------------------------------------------------------------- 1 | # Original Description 2 | 3 | This is derived from a code kata presented at XP2006 by EmmanuelGaillot and ChristopheThibaut see: http://www.codingdojo.org/cgi-bin/wiki.pl?KataBankOCR 4 | 5 | ## Problem Description 6 | 7 | You work for a bank, which has recently purchased an ingenious machine to assist in reading letters and faxes sent in by branch offices. The machine scans the paper documents, and produces a file with a number of entries which each look like this: 8 | 9 |
 10 |     _  _     _  _  _  _  _
 11 |   | _| _||_||_ |_   ||_||_|
 12 |   ||_  _|  | _||_|  ||_| _|
 13 | 
14 | 15 | Each entry is 4 lines long, and each line has 27 characters. The first 3 lines of each entry contain an account number written using pipes and underscores, and the fourth line is blank. Each account number should have 9 digits, all of which should be in the range 0-9. A normal file contains around 500 entries. 16 | 17 | Your first task is to write a program that can take this file and parse it into actual account numbers. 18 | 19 | ### Story 1 20 | 21 | Parsing the output file. 22 | 23 | As a user 24 | When I parse a file with a single set of digits 25 | The correct numbers are returned 26 | 27 | ### Story 2 28 | 29 | Handling unknown characters 30 | 31 | As a developer 32 | When the parser encounters a pattern it doesn't recognise 33 | It throws an exception 34 | 35 | ## Clues 36 | 37 | I recommend finding a way to write out 3x3 cells on 3 lines in your 38 | code, so they form an identifiable digits. Even if your code actually 39 | doesn't represent them like that internally. I'd much rather read 40 | 41 |
 42 | "   " +
 43 | "|_|" +
 44 | "  |"
 45 | 
46 | 47 | than 48 | 49 |
 50 | "   |_|  |"
 51 | 
52 | 53 | anyday. 54 | 55 | ## Suggested Test Cases 56 | 57 | If you want to just copy and paste these test cases into your editor, 58 | I suggest first clicking "edit this page" so you can see the source. 59 | Then you can be sure to copy across all the whitespace necessary. Just 60 | don't save any changes by mistake. 61 | 62 |
 63 |  _  _  _  _  _  _  _  _  _
 64 | | || || || || || || || || |
 65 | |_||_||_||_||_||_||_||_||_|
 66 | 
 67 | => 000000000
 68 | 
 69 |   |  |  |  |  |  |  |  |  |
 70 |   |  |  |  |  |  |  |  |  |
 71 | 
 72 | => 111111111
 73 |  _  _  _  _  _  _  _  _  _
 74 |  _| _| _| _| _| _| _| _| _|
 75 | |_ |_ |_ |_ |_ |_ |_ |_ |_
 76 | 
 77 | => 222222222
 78 |  _  _  _  _  _  _  _  _  _
 79 |  _| _| _| _| _| _| _| _| _|
 80 |  _| _| _| _| _| _| _| _| _|
 81 | 
 82 | => 333333333
 83 | 
 84 | |_||_||_||_||_||_||_||_||_|
 85 |   |  |  |  |  |  |  |  |  |
 86 | 
 87 | => 444444444
 88 |  _  _  _  _  _  _  _  _  _
 89 | |_ |_ |_ |_ |_ |_ |_ |_ |_
 90 |  _| _| _| _| _| _| _| _| _|
 91 | 
 92 | => 555555555
 93 |  _  _  _  _  _  _  _  _  _
 94 | |_ |_ |_ |_ |_ |_ |_ |_ |_
 95 | |_||_||_||_||_||_||_||_||_|
 96 | 
 97 | => 666666666
 98 |  _  _  _  _  _  _  _  _  _
 99 |   |  |  |  |  |  |  |  |  |
100 |   |  |  |  |  |  |  |  |  |
101 | 
102 | => 777777777
103 |  _  _  _  _  _  _  _  _  _
104 | |_||_||_||_||_||_||_||_||_|
105 | |_||_||_||_||_||_||_||_||_|
106 | 
107 | => 888888888
108 |  _  _  _  _  _  _  _  _  _
109 | |_||_||_||_||_||_||_||_||_|
110 |  _| _| _| _| _| _| _| _| _|
111 | 
112 | => 999999999
113 |     _  _     _  _  _  _  _
114 |   | _| _||_||_ |_   ||_||_|
115 |   ||_  _|  | _||_|  ||_| _|
116 | 
117 | => 123456789
118 | 
119 | -------------------------------------------------------------------------------- /BloomFilters/readme.md: -------------------------------------------------------------------------------- 1 | ## Problem Description 2 | 3 | A bloom filter (http://en.wikipedia.org/wiki/Bloom_filter#Algorithm_description http://billmill.org/bloomfilter-tutorial/) is a quick and memory efficient way to work out if some data is NOT in a given set, or MIGHT BE in a set. 4 | 5 | You create a bloom filter by hashing each item in your set, and allocating them into bitmap - an array of bits with the hash used as the array position, and a bit set to 1 where the item is present. 6 | 7 | At first it might not be apparent why you'd want to know if a item is definitely not in a set, and only that it MIGHT BE - but consider the problem of a dictionary. Hashes may well collide in a bloom filter, with two items producing the same hash, but there are plenty of scenarios where this isn't important. 8 | 9 | We're going to build a dictionary using a bloom filter. 10 | 11 | ### Story 1 - Hashing words 12 | 13 | As a user 14 | Given a single word 15 | I can produce a single, bit-mappable-hash. 16 | 17 | ### Story 2 - Detecting mis-spelt words 18 | 19 | As a user 20 | When I type a sentence 21 | Words that are not in the word-list are returned as errors 22 | 23 | 24 | ### Hints 25 | 26 | There's a built in hash function in .NET - how do you convert those into an array location? 27 | 28 | There's a word list included. 29 | -------------------------------------------------------------------------------- /Braille/grade2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidwhitney/CodeDojos/64107347f8066b845cb7941e3ead782b72de1c21/Braille/grade2.gif -------------------------------------------------------------------------------- /Braille/guide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidwhitney/CodeDojos/64107347f8066b845cb7941e3ead782b72de1c21/Braille/guide.png -------------------------------------------------------------------------------- /Braille/punc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidwhitney/CodeDojos/64107347f8066b845cb7941e3ead782b72de1c21/Braille/punc.gif -------------------------------------------------------------------------------- /Braille/readme.md: -------------------------------------------------------------------------------- 1 | Braille Translation 2 | ====================================== 3 | 4 | We're going to build a program to translate ASCII text into Basic Braille. 5 | 6 | # About Braille 7 | 8 | Braille is writing system which enables blind and partially sighted people to read through touch. It was invented by Louis Braille (1809-1852), who became blind in a childhood accident and later became a teacher of the blind. 9 | 10 | Braille consists of patterns of raised dots arranged in cells of up to six dots in a 3 x 2 configuration. Each cell represents a letter, numeral or punctuation mark. Some frequently used words and letter combinations also have their own single cell patterns. It was based on a tactile military code developed by Charles Barbier known as night writing or sonography. 11 | 12 | Braille Alphabet and Braille Numbers (from: http://www.pharmabraille.com/pharmaceutical-braille/the-braille-alphabet/) 13 | 14 | These braille dots are positioned like the figure six on a die, in a grid of two parallel vertical lines of three dots each. 15 | 16 | From the six dots that make up the basic grid, 64 different configurations can be created. These 64 braille characters can be seen below in the Unicode braille code chart. 17 | 18 | The Unicode block for 6 dot braille is U+2800 – U+283F. 19 | 20 | ![alt text](guide.png "Patterns") 21 | 22 | (From: http://www.omniglot.com/writing/braille.htm) 23 | 24 | There are a number of different versions of Braille: 25 | 26 | Uncontracted or Grade 1 27 | 28 | Which consists of the 26 standard letters of the alphabet and punctuation. 29 | It is only used by people who are first starting to read Braille. 30 | 31 | ![alt text](uncontracted.gif "Patterns") 32 | ![alt text](punc.gif "Patterns") 33 | 34 | Contracted or Grade 2 35 | 36 | Which consists of the 26 standard letters of the alphabet, 37 | punctuation and contractions. The contractions are employed 38 | to save space because a Braille page cannot fit as much text as 39 | a standard printed page. Books, signs in public places, menus, 40 | and most other Braille materials are written in Contracted Braille. 41 | 42 | ![alt text](grade2.gif "Patterns") 43 | 44 | Grade 3 45 | 46 | Which is used mainly in personal letters, diaries, and notes, 47 | and also in literature to a limited extent. It is a kind of shorthand, 48 | with entire words shortened to a few letters. 49 | There is no official standard for this version of Braille. 50 | 51 | 52 | Build a translator 53 | =================== 54 | 55 | ### Story 1 56 | 57 | ASCII To Basic Braille 58 | 59 | As a user 60 | When I parse a text string 61 | I can output it as braille on the screen visibly 62 | 63 | Accept: Any visual representation will do. 64 | 65 | ### Story 2 66 | 67 | Word Wrap 68 | 69 | As a user 70 | When I type in a long sentence 71 | It word wraps my braille on the screen 72 | 73 | ### Story 3 74 | 75 | Contracted Braille 76 | 77 | As a user 78 | When I type in a word that is part of the contracted braille syntax 79 | The word is shortened to the contracted pattern 80 | 81 | -------------------------------------------------------------------------------- /Braille/uncontracted.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidwhitney/CodeDojos/64107347f8066b845cb7941e3ead782b72de1c21/Braille/uncontracted.gif -------------------------------------------------------------------------------- /BuildATestFramework/readme.md: -------------------------------------------------------------------------------- 1 | Build a test framework! 2 | ======================== 3 | 4 | Working through some of the katas you'll have hopefully grown an appreciation for test driven development - so it's time to work out how test frameworks really work. 5 | 6 | In this dojo, we're going to build the simplest test framework imaginable. 7 | 8 | This dojo is about developing code that detects conventions, and a excercise in using the meta-programming features of the language of your choice. 9 | 10 | Here are some example conventions, feel free to use them or think up your own 11 | 12 | ### Example conventions 13 | 14 | * The test runner runs on the command line, pointed at a directory. 15 | * Any assembly in that directory is loaded 16 | * Test classes are classes with names suffixed `Tests` 17 | * Any public method called `SetUp` is invoked before each test run 18 | * All other public methods are presumed to be tests. 19 | * The test class is created fresh before each test is invoked. 20 | * Exceptions are considered test failures 21 | 22 | This is a reasonable and wide range of requirements. Don't expect to have a working and extensible test framework built in an hour! 23 | 24 | * Assertion frameworks are out of scope. 25 | 26 | ### Story 1 - Running tests 27 | 28 | As a user 29 | When I invoke the test runner 30 | It executes all tests that match my convention 31 | 32 | Accept: Count of pass / fail output. 33 | List of failing test names output. 34 | Exception thrown = failing test. 35 | 36 | ### Story 2 - Support for setup 37 | 38 | As a user 39 | When I invoke the test runner 40 | My setup method is invoked 41 | 42 | ### Story 3 - Isolated test execution 43 | 44 | As a user 45 | When a single test is run 46 | The test can't overwrite local variables in use by other tests 47 | 48 | Accept: Tests run in single instance of their own classes 49 | -------------------------------------------------------------------------------- /BuildMonitor/readme.md: -------------------------------------------------------------------------------- 1 | ## Problem Description - Build monitor 2 | 3 | You work in a nice, friendly, modern software development company - and as a result, you have a comprehensive build server. 4 | 5 | But alas! Somebody keeps on breaking builds! In order to convince people that breaking builds is a really bad idea, you decide to build an alarm that rings every time a build is broken. 6 | 7 | (Example API response in appendix) 8 | 9 | --- 10 | 11 | ### Getting the build status for a build 12 | 13 | As a developer 14 | I want to get the build status for a build 15 | So I can raise an alarm if it breaks 16 | 17 | 18 | ### Ringing an alarm 19 | 20 | As a developer 21 | When a build breaks (API returns negative status) 22 | An alarm rings 23 | 24 | Accept: Can hear alarm! 25 | If the last build failed, don't ring the alarm again 26 | 27 | ### Alerting on multiple builds 28 | 29 | As a developer 30 | I want the build alarm to ring for more than one build 31 | So I can monitor multiple projects 32 | 33 | 34 | ### Coping with the build server being down 35 | 36 | As a developer 37 | I don't want the build alarm to ring when connectivity to the build server is interrupted. 38 | Because that'd be annoying 39 | 40 | Accept: Must be obvious somehow that the build results are stale 41 | 42 | 43 | ### Second build server 44 | 45 | As a developer 46 | I want to monitor a second, completely different build server using the same alarm 47 | Because we now build iOS software as well as websites and need a different build chain 48 | 49 | Accept: Mutiple servers monitored 50 | Servers run different build software / have different APIs 51 | 52 | ### Configuration 53 | 54 | As a developer 55 | I want to trivially configure the alarm to ring for many builds 56 | With as little configuration as possible. 57 | 58 | ### Stretch goal 59 | 60 | As a developer 61 | I want to know a build failed in ways other than a ringing alarm 62 | Because I can miss an alarm ringing 63 | 64 | # Example call 65 | 66 | GET http://tempuri.org/build/status 67 | 68 | 69 | ## Example API call response 70 | 71 | { 72 | "Projects": [ 73 | { 74 | "Id": "0b33a915-8fa2-4edc-9a33-8a51ace565a2", 75 | "Name": "MyRockingApp", 76 | "Configurations": [ 77 | { 78 | "Id": "2eaed57c-28e8-4ce4-a0e7-112f4077aa0a", 79 | "Name": "Build", 80 | "CurrentStatus": "Passing", 81 | "Message": null 82 | }, 83 | { 84 | "Id": "59c4b0f8-d5d4-449a-841b-c1b180018a7e", 85 | "Name": "Deploy - Dev", 86 | "CurrentStatus": "Passing", 87 | "Message": null 88 | }, 89 | { 90 | "Id": "0e6b8f47-a893-45fb-989b-08b5882a49b3", 91 | "Name": "Deploy - QA", 92 | "CurrentStatus": "Passing", 93 | "Message": null 94 | }, 95 | { 96 | "Id": "1ac4bf7d-dfca-49a3-9100-546a9921517a", 97 | "Name": "Deploy - Production", 98 | "CurrentStatus": "Passing", 99 | "Message": null 100 | } 101 | ] 102 | }, 103 | { 104 | "Id": "bbc484fb-e673-4ec4-9a7f-faf3279bdd0b", 105 | "Name": "MySuckingApp", 106 | "Configurations": [ 107 | { 108 | "Id": "ab32d9f8-1914-4966-a8c4-dee195065a40", 109 | "Name": "Build", 110 | "CurrentStatus": "Failing", 111 | "Message": null 112 | }, 113 | { 114 | "Id": "2d80a96a-b51a-438c-96ac-c99f9a83e3e5", 115 | "Name": "Deploy - Dev", 116 | "CurrentStatus": "Passing", 117 | "Message": null 118 | }, 119 | { 120 | "Id": "110b79bf-b742-4dc8-94f4-a43199a19675", 121 | "Name": "Deploy - QA", 122 | "CurrentStatus": "Inconclusive", 123 | "Message": null 124 | }, 125 | { 126 | "Id": "89f7ee03-c9a4-40b7-acb6-e87333e7ab1a", 127 | "Name": "Deploy - Production", 128 | "CurrentStatus": "Passing", 129 | "Message": null 130 | } 131 | ] 132 | } 133 | ] 134 | } 135 | -------------------------------------------------------------------------------- /BuildingFluentApis/AssertThat/ClassLibrary1/ClassLibrary1.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{3CADB7AD-19A3-4533-8CEF-B63871BE8E03}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3CADB7AD-19A3-4533-8CEF-B63871BE8E03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3CADB7AD-19A3-4533-8CEF-B63871BE8E03}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3CADB7AD-19A3-4533-8CEF-B63871BE8E03}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3CADB7AD-19A3-4533-8CEF-B63871BE8E03}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /BuildingFluentApis/AssertThat/ClassLibrary1/ClassLibrary1/Class1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | 4 | namespace ClassLibrary1 5 | { 6 | [TestFixture] 7 | public class CheckTests 8 | { 9 | [Test] 10 | public void That_GivenStringThatIsEqual_Works() 11 | { 12 | Check.That("hi", IsTotally.EqualTo("hi")); 13 | } 14 | 15 | [Test] 16 | public void That_GivenStringThatIsNotEqual_Throws() 17 | { 18 | Assert.Throws(() => Check.That("hi", IsTotally.EqualTo("hello"))); 19 | } 20 | 21 | [Test] 22 | public void That_GivenStringThatIsNotNotEqual_Throws() 23 | { 24 | Assert.Throws(() => Check.That("hi", IsTotally.Not.Not.EqualTo("hello"))); 25 | } 26 | 27 | [Test] 28 | public void That_GivenStringThatIsNotEqual_Works() 29 | { 30 | Check.That("hi", IsTotally.Not.EqualTo("hello")); 31 | } 32 | 33 | [Test] 34 | public void That_GivenStringThatIsNotNotEqual_Works() 35 | { 36 | Check.That("hi", IsTotally.Not.Not.EqualTo("hi")); 37 | } 38 | } 39 | 40 | public static class IsTotally 41 | { 42 | private static readonly IAssertionRoot Default = new IsTotallyInstance(ComparisonSettings.Regular); 43 | 44 | public static IPerformAComparison EqualTo(object objB) 45 | { 46 | return Default.EqualTo(objB); 47 | } 48 | 49 | public static IAssertionRoot Not 50 | { 51 | get { return new IsTotallyInstance(ComparisonSettings.Negated); } 52 | } 53 | } 54 | 55 | public class ComparisonSettings 56 | { 57 | public static ComparisonSettings Regular = new ComparisonSettings(); 58 | public static ComparisonSettings Negated = new ComparisonSettings(); 59 | 60 | public ComparisonSettings GetOther() 61 | { 62 | return this == Regular ? Negated : Regular; 63 | } 64 | } 65 | 66 | public class IsTotallyInstance : IAssertionRoot 67 | { 68 | private readonly ComparisonSettings _comparisonSettings; 69 | 70 | public IsTotallyInstance(ComparisonSettings comparisonSettings) 71 | { 72 | _comparisonSettings = comparisonSettings; 73 | } 74 | 75 | public IPerformAComparison EqualTo(object objB) 76 | { 77 | return Shim(new CheckEquality(objB)); 78 | } 79 | 80 | public IAssertionRoot Not 81 | { 82 | get { return new IsTotallyInstance(_comparisonSettings.GetOther()); } 83 | } 84 | 85 | public IPerformAComparison Shim(IPerformAComparison comparison) 86 | { 87 | return _comparisonSettings == ComparisonSettings.Negated 88 | ? new Invert(comparison) 89 | : comparison; 90 | } 91 | } 92 | 93 | public interface IAssertionRoot 94 | { 95 | IPerformAComparison EqualTo(object objB); 96 | IAssertionRoot Not { get; } 97 | } 98 | 99 | public class Invert : IPerformAComparison 100 | { 101 | private readonly IPerformAComparison _regular; 102 | 103 | public Invert(IPerformAComparison regular) 104 | { 105 | _regular = regular; 106 | } 107 | 108 | public bool Execute(object objA) 109 | { 110 | return !_regular.Execute(objA); 111 | } 112 | 113 | public Exception GenerateError(object objA) 114 | { 115 | return _regular.GenerateError(objA); 116 | } 117 | } 118 | 119 | 120 | public static class Check 121 | { 122 | public static void That(object objA, IPerformAComparison comparison) 123 | { 124 | var success = comparison.Execute(objA); 125 | if (!success) 126 | { 127 | throw comparison.GenerateError(objA); 128 | } 129 | } 130 | } 131 | 132 | public interface IPerformAComparison 133 | { 134 | bool Execute(object objA); 135 | Exception GenerateError(object objA); 136 | } 137 | 138 | public class CheckEquality : IPerformAComparison 139 | { 140 | public object ObjB { get; set; } 141 | 142 | public CheckEquality(object objB) 143 | { 144 | ObjB = objB; 145 | } 146 | 147 | public bool Execute(object objA) 148 | { 149 | return objA == ObjB; 150 | } 151 | 152 | public Exception GenerateError(object objA) 153 | { 154 | return new Exception("objA doesn't match objB"); 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /BuildingFluentApis/AssertThat/ClassLibrary1/ClassLibrary1/ClassLibrary1.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {3CADB7AD-19A3-4533-8CEF-B63871BE8E03} 8 | Library 9 | Properties 10 | ClassLibrary1 11 | ClassLibrary1 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\NUnit.2.6.4\lib\nunit.framework.dll 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 59 | -------------------------------------------------------------------------------- /BuildingFluentApis/AssertThat/ClassLibrary1/ClassLibrary1/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ClassLibrary1")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ClassLibrary1")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e43d6044-bb60-452b-a4a5-d5133f90b5f2")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /BuildingFluentApis/AssertThat/ClassLibrary1/ClassLibrary1/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /BuildingFluentApis/AssertThat/ClassLibrary1/packages/NUnit.2.6.4/NUnit.2.6.4.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidwhitney/CodeDojos/64107347f8066b845cb7941e3ead782b72de1c21/BuildingFluentApis/AssertThat/ClassLibrary1/packages/NUnit.2.6.4/NUnit.2.6.4.nupkg -------------------------------------------------------------------------------- /BuildingFluentApis/AssertThat/ClassLibrary1/packages/NUnit.2.6.4/NUnit.2.6.4.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NUnit 5 | 2.6.4 6 | NUnit 7 | Charlie Poole 8 | Charlie Poole 9 | http://nunit.org/nuget/license.html 10 | http://nunit.org/ 11 | http://nunit.org/nuget/nunit_32x32.png 12 | false 13 | NUnit features a fluent assert syntax, parameterized, generic and theory tests and is user-extensible. A number of runners, both from the NUnit project and by third parties, are able to execute NUnit tests. 14 | 15 | Version 2.6 is the seventh major release of this well-known and well-tested programming tool. 16 | 17 | This package includes only the framework assembly. You will need to install the NUnit.Runners package unless you are using a third-party runner. 18 | NUnit is a unit-testing framework for all .Net languages with a strong TDD focus. 19 | Version 2.6 is the seventh major release of NUnit. 20 | 21 | Unlike earlier versions, this package includes only the framework assembly. You will need to install the NUnit.Runners package unless you are using a third-party runner. 22 | 23 | The nunit.mocks assembly is now provided by the NUnit.Mocks package. The pnunit.framework assembly is provided by the pNUnit package. 24 | en-US 25 | nunit test testing tdd framework fluent assert theory plugin addin 26 | 27 | -------------------------------------------------------------------------------- /BuildingFluentApis/AssertThat/ClassLibrary1/packages/NUnit.2.6.4/lib/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidwhitney/CodeDojos/64107347f8066b845cb7941e3ead782b72de1c21/BuildingFluentApis/AssertThat/ClassLibrary1/packages/NUnit.2.6.4/lib/nunit.framework.dll -------------------------------------------------------------------------------- /BuildingFluentApis/AssertThat/ClassLibrary1/packages/NUnit.2.6.4/license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidwhitney/CodeDojos/64107347f8066b845cb7941e3ead782b72de1c21/BuildingFluentApis/AssertThat/ClassLibrary1/packages/NUnit.2.6.4/license.txt -------------------------------------------------------------------------------- /BuildingFluentApis/AssertThat/ClassLibrary1/packages/repositories.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /BuildingFluentApis/README.md: -------------------------------------------------------------------------------- 1 | ## Problem Description 2 | 3 | Fluent interfaces (http://en.wikipedia.org/wiki/Fluent_interface) are implementations APIs designed to look more human readable. You'll see them everywhere, with mainstream examples including FluentNHibernate and the assertion syntax in many libraries. 4 | 5 | There's an interesting library by Michael Wolfenden called "Polly" (https://github.com/michael-wolfenden/Polly) that implements some interesting syntax: 6 | 7 | // Retry multiple times, calling an action on each retry 8 | // with the current exception and retry count 9 | Policy 10 | .Handle() 11 | .Retry(3, (exception, retryCount) => 12 | { 13 | // do something 14 | }); 15 | 16 | We're going implement this kind of API in C# / Java 17 | 18 | ### Story 1 - Asserting Not equality 19 | 20 | One of the simplest examples of an API is the following from NUnit: 21 | 22 | Assert.That(myString, Is.EqualTo("Hello") ); 23 | 24 | Implement this API. 25 | 26 | ### Story 2 - Asserting inverse equality 27 | 28 | Assert.That(myString, Is.Not.EqualTo("Hello") ); 29 | 30 | Implement this API. 31 | 32 | ### Story 3 - Stretch 33 | 34 | Attempt to implement the larger API sample shown above 35 | -------------------------------------------------------------------------------- /ChristmasLights/answer.md: -------------------------------------------------------------------------------- 1 | Part 1: Your puzzle answer was 569999. 2 | -------------------------------------------------------------------------------- /ChristmasLights/answer2.md: -------------------------------------------------------------------------------- 1 | Your puzzle answer was 17836115. 2 | -------------------------------------------------------------------------------- /ChristmasLights/input.txt: -------------------------------------------------------------------------------- 1 | turn on 489,959 through 759,964 2 | turn off 820,516 through 871,914 3 | turn off 427,423 through 929,502 4 | turn on 774,14 through 977,877 5 | turn on 410,146 through 864,337 6 | turn on 931,331 through 939,812 7 | turn off 756,53 through 923,339 8 | turn off 313,787 through 545,979 9 | turn off 12,823 through 102,934 10 | toggle 756,965 through 812,992 11 | turn off 743,684 through 789,958 12 | toggle 120,314 through 745,489 13 | toggle 692,845 through 866,994 14 | turn off 587,176 through 850,273 15 | turn off 674,321 through 793,388 16 | toggle 749,672 through 973,965 17 | turn on 943,30 through 990,907 18 | turn on 296,50 through 729,664 19 | turn on 212,957 through 490,987 20 | toggle 171,31 through 688,88 21 | turn off 991,989 through 994,998 22 | turn off 913,943 through 958,953 23 | turn off 278,258 through 367,386 24 | toggle 275,796 through 493,971 25 | turn off 70,873 through 798,923 26 | toggle 258,985 through 663,998 27 | turn on 601,259 through 831,486 28 | turn off 914,94 through 941,102 29 | turn off 558,161 through 994,647 30 | turn on 119,662 through 760,838 31 | toggle 378,775 through 526,852 32 | turn off 384,670 through 674,972 33 | turn off 249,41 through 270,936 34 | turn on 614,742 through 769,780 35 | turn on 427,70 through 575,441 36 | turn on 410,478 through 985,753 37 | turn off 619,46 through 931,342 38 | turn on 284,55 through 768,922 39 | turn off 40,592 through 728,685 40 | turn on 825,291 through 956,950 41 | turn on 147,843 through 592,909 42 | turn off 218,675 through 972,911 43 | toggle 249,291 through 350,960 44 | turn off 556,80 through 967,675 45 | toggle 609,148 through 968,279 46 | toggle 217,605 through 961,862 47 | toggle 407,177 through 548,910 48 | toggle 400,936 through 599,938 49 | turn off 721,101 through 925,455 50 | turn on 268,631 through 735,814 51 | toggle 549,969 through 612,991 52 | toggle 553,268 through 689,432 53 | turn off 817,668 through 889,897 54 | toggle 801,544 through 858,556 55 | toggle 615,729 through 832,951 56 | turn off 427,477 through 958,948 57 | turn on 164,49 through 852,946 58 | turn on 542,449 through 774,776 59 | turn off 923,196 through 980,446 60 | toggle 90,310 through 718,846 61 | turn off 657,215 through 744,252 62 | turn off 800,239 through 811,712 63 | turn on 502,90 through 619,760 64 | toggle 649,512 through 862,844 65 | turn off 334,903 through 823,935 66 | turn off 630,233 through 839,445 67 | turn on 713,67 through 839,865 68 | turn on 932,50 through 982,411 69 | turn off 480,729 through 984,910 70 | turn on 100,219 through 796,395 71 | turn on 758,108 through 850,950 72 | turn off 427,276 through 439,938 73 | turn on 178,284 through 670,536 74 | toggle 540,27 through 625,102 75 | turn off 906,722 through 936,948 76 | toggle 345,418 through 859,627 77 | toggle 175,775 through 580,781 78 | toggle 863,28 through 929,735 79 | turn off 824,858 through 905,973 80 | toggle 752,312 through 863,425 81 | turn on 985,716 through 988,852 82 | turn off 68,504 through 763,745 83 | toggle 76,209 through 810,720 84 | turn off 657,607 through 676,664 85 | toggle 596,869 through 896,921 86 | turn off 915,411 through 968,945 87 | turn off 368,39 through 902,986 88 | turn on 11,549 through 393,597 89 | turn off 842,893 through 976,911 90 | toggle 274,106 through 581,329 91 | toggle 406,403 through 780,950 92 | toggle 408,988 through 500,994 93 | toggle 217,73 through 826,951 94 | turn on 917,872 through 961,911 95 | toggle 394,34 through 510,572 96 | toggle 424,603 through 583,626 97 | toggle 106,159 through 755,738 98 | turn off 244,610 through 472,709 99 | turn on 350,265 through 884,690 100 | turn on 688,184 through 928,280 101 | toggle 279,443 through 720,797 102 | turn off 615,493 through 888,610 103 | toggle 118,413 through 736,632 104 | turn on 798,782 through 829,813 105 | turn off 250,934 through 442,972 106 | turn on 68,503 through 400,949 107 | toggle 297,482 through 313,871 108 | toggle 710,3 through 839,859 109 | turn on 125,300 through 546,888 110 | toggle 482,39 through 584,159 111 | turn off 536,89 through 765,962 112 | turn on 530,518 through 843,676 113 | turn on 994,467 through 994,676 114 | turn on 623,628 through 744,927 115 | toggle 704,912 through 837,983 116 | turn on 154,364 through 517,412 117 | toggle 344,409 through 780,524 118 | turn off 578,740 through 725,879 119 | turn on 251,933 through 632,957 120 | turn on 827,705 through 971,789 121 | toggle 191,282 through 470,929 122 | toggle 324,525 through 446,867 123 | toggle 534,343 through 874,971 124 | toggle 550,650 through 633,980 125 | toggle 837,404 through 881,915 126 | toggle 338,881 through 845,905 127 | turn on 469,462 through 750,696 128 | turn on 741,703 through 892,870 129 | turn off 570,215 through 733,562 130 | turn on 445,576 through 870,775 131 | turn on 466,747 through 554,878 132 | turn off 820,453 through 868,712 133 | turn off 892,706 through 938,792 134 | turn off 300,238 through 894,746 135 | turn off 306,44 through 457,444 136 | turn off 912,569 through 967,963 137 | toggle 109,756 through 297,867 138 | turn on 37,546 through 41,951 139 | turn on 321,637 through 790,910 140 | toggle 66,50 through 579,301 141 | toggle 933,221 through 933,791 142 | turn on 486,676 through 878,797 143 | turn on 417,231 through 556,317 144 | toggle 904,468 through 981,873 145 | turn on 417,675 through 749,712 146 | turn on 692,371 through 821,842 147 | toggle 324,73 through 830,543 148 | turn on 912,490 through 977,757 149 | turn off 634,872 through 902,949 150 | toggle 266,779 through 870,798 151 | turn on 772,982 through 990,996 152 | turn off 607,46 through 798,559 153 | turn on 295,602 through 963,987 154 | turn on 657,86 through 944,742 155 | turn off 334,639 through 456,821 156 | turn off 997,667 through 997,670 157 | turn off 725,832 through 951,945 158 | turn off 30,120 through 952,984 159 | turn on 860,965 through 917,976 160 | toggle 471,997 through 840,998 161 | turn off 319,307 through 928,504 162 | toggle 823,631 through 940,908 163 | toggle 969,984 through 981,993 164 | turn off 691,319 through 865,954 165 | toggle 911,926 through 938,929 166 | turn on 953,937 through 968,991 167 | toggle 914,643 through 975,840 168 | turn on 266,982 through 436,996 169 | turn off 101,896 through 321,932 170 | turn off 193,852 through 751,885 171 | turn off 576,532 through 863,684 172 | turn on 761,456 through 940,783 173 | turn on 20,290 through 398,933 174 | turn off 435,335 through 644,652 175 | turn on 830,569 through 905,770 176 | turn off 630,517 through 905,654 177 | turn on 664,53 through 886,976 178 | toggle 275,416 through 408,719 179 | turn on 370,621 through 515,793 180 | turn on 483,373 through 654,749 181 | turn on 656,786 through 847,928 182 | turn off 532,752 through 945,974 183 | toggle 301,150 through 880,792 184 | turn off 951,488 through 958,952 185 | turn on 207,729 through 882,828 186 | toggle 694,532 through 973,961 187 | toggle 676,639 through 891,802 188 | turn off 653,6 through 905,519 189 | toggle 391,109 through 418,312 190 | turn on 877,423 through 957,932 191 | turn on 340,145 through 563,522 192 | turn off 978,467 through 988,895 193 | turn off 396,418 through 420,885 194 | turn off 31,308 through 816,316 195 | turn on 107,675 through 758,824 196 | turn on 61,82 through 789,876 197 | turn on 750,743 through 754,760 198 | toggle 88,733 through 736,968 199 | turn off 754,349 through 849,897 200 | toggle 157,50 through 975,781 201 | turn off 230,231 through 865,842 202 | turn off 516,317 through 630,329 203 | turn off 697,820 through 829,903 204 | turn on 218,250 through 271,732 205 | toggle 56,167 through 404,431 206 | toggle 626,891 through 680,927 207 | toggle 370,207 through 791,514 208 | toggle 860,74 through 949,888 209 | turn on 416,527 through 616,541 210 | turn off 745,449 through 786,908 211 | turn on 485,554 through 689,689 212 | turn on 586,62 through 693,141 213 | toggle 506,759 through 768,829 214 | turn on 473,109 through 929,166 215 | turn on 760,617 through 773,789 216 | toggle 595,683 through 618,789 217 | turn off 210,775 through 825,972 218 | toggle 12,426 through 179,982 219 | turn on 774,539 through 778,786 220 | turn on 102,498 through 121,807 221 | turn off 706,897 through 834,965 222 | turn off 678,529 through 824,627 223 | turn on 7,765 through 615,870 224 | turn off 730,872 through 974,943 225 | turn off 595,626 through 836,711 226 | turn off 215,424 through 841,959 227 | toggle 341,780 through 861,813 228 | toggle 507,503 through 568,822 229 | turn on 252,603 through 349,655 230 | toggle 93,521 through 154,834 231 | turn on 565,682 through 951,954 232 | turn on 544,318 through 703,418 233 | toggle 756,953 through 891,964 234 | turn on 531,123 through 856,991 235 | turn on 148,315 through 776,559 236 | turn off 925,835 through 963,971 237 | turn on 895,944 through 967,964 238 | turn off 102,527 through 650,747 239 | toggle 626,105 through 738,720 240 | turn off 160,75 through 384,922 241 | toggle 813,724 through 903,941 242 | turn on 207,107 through 982,849 243 | toggle 750,505 through 961,697 244 | toggle 105,410 through 885,819 245 | turn on 226,104 through 298,283 246 | turn off 224,604 through 508,762 247 | turn on 477,368 through 523,506 248 | turn off 477,901 through 627,936 249 | turn off 887,131 through 889,670 250 | turn on 896,994 through 938,999 251 | toggle 401,580 through 493,728 252 | toggle 987,184 through 991,205 253 | turn on 821,643 through 882,674 254 | toggle 784,940 through 968,959 255 | turn off 251,293 through 274,632 256 | turn off 339,840 through 341,844 257 | turn off 675,351 through 675,836 258 | toggle 918,857 through 944,886 259 | toggle 70,253 through 918,736 260 | turn off 612,604 through 772,680 261 | turn off 277,40 through 828,348 262 | toggle 692,139 through 698,880 263 | toggle 124,446 through 883,453 264 | toggle 969,932 through 990,945 265 | toggle 855,692 through 993,693 266 | toggle 722,472 through 887,899 267 | toggle 978,149 through 985,442 268 | toggle 837,540 through 916,889 269 | turn off 612,2 through 835,82 270 | toggle 560,767 through 878,856 271 | turn on 461,734 through 524,991 272 | toggle 206,824 through 976,912 273 | turn on 826,610 through 879,892 274 | turn on 577,699 through 956,933 275 | turn off 9,250 through 50,529 276 | turn off 77,657 through 817,677 277 | turn on 68,419 through 86,426 278 | turn on 991,720 through 992,784 279 | turn on 668,20 through 935,470 280 | turn off 133,418 through 613,458 281 | turn off 487,286 through 540,328 282 | toggle 247,874 through 840,955 283 | toggle 301,808 through 754,970 284 | turn off 34,194 through 578,203 285 | turn off 451,49 through 492,921 286 | turn on 907,256 through 912,737 287 | turn off 479,305 through 702,587 288 | turn on 545,583 through 732,749 289 | toggle 11,16 through 725,868 290 | turn on 965,343 through 986,908 291 | turn on 674,953 through 820,965 292 | toggle 398,147 through 504,583 293 | turn off 778,194 through 898,298 294 | turn on 179,140 through 350,852 295 | turn off 241,118 through 530,832 296 | turn off 41,447 through 932,737 297 | turn off 820,663 through 832,982 298 | turn on 550,460 through 964,782 299 | turn on 31,760 through 655,892 300 | toggle 628,958 through 811,992 -------------------------------------------------------------------------------- /ChristmasLights/readme.md: -------------------------------------------------------------------------------- 1 | This is borrowed wholesale from the excellent "Advent of Code" Day 6 challange - http://adventofcode.com/day/6 2 | ----------------- 3 | # Christmas Lights 4 | 5 | ## Day 6: Probably a Fire Hazard 6 | 7 | Because your neighbors keep defeating you in the holiday house decorating contest year after year, you've decided to deploy one million lights in a 1000x1000 grid. 8 | 9 | Furthermore, because you've been especially nice this year, Santa has mailed you instructions on how to display the ideal lighting configuration. 10 | 11 | Lights in your grid are numbered from 0 to 999 in each direction; the lights at each corner are at 0,0, 0,999, 999,999, and 999,0. The instructions include whether to turn on, turn off, or toggle various inclusive ranges given as coordinate pairs. Each coordinate pair represents opposite corners of a rectangle, inclusive; a coordinate pair like 0,0 through 2,2 therefore refers to 9 lights in a 3x3 square. The lights all start turned off. 12 | 13 | To defeat your neighbors this year, all you have to do is set up your lights by doing the instructions Santa sent you in order. 14 | 15 | For example: 16 | 17 | * turn on 0,0 through 999,999 would turn on (or leave on) every light. 18 | * toggle 0,0 through 999,0 would toggle the first line of 1000 lights, turning off the ones that were on, and turning on the ones that were off. 19 | * turn off 499,499 through 500,500 would turn off (or leave off) the middle four lights. 20 | 21 | After following the instructions, how many lights are lit? 22 | 23 | 24 | ## Part Two 25 | 26 | You just finish implementing your winning light pattern when you realize you mistranslated Santa's message from Ancient Nordic Elvish. 27 | 28 | The light grid you bought actually has individual brightness controls; each light can have a brightness of zero or more. The lights all start at zero. 29 | 30 | * The phrase turn on actually means that you should increase the brightness of those lights by 1. 31 | * The phrase turn off actually means that you should decrease the brightness of those lights by 1, to a minimum of zero. 32 | * The phrase toggle actually means that you should increase the brightness of those lights by 2. 33 | 34 | What is the total brightness of all lights combined after following Santa's instructions? 35 | 36 | For example: 37 | 38 | * turn on 0,0 through 0,0 would increase the total brightness by 1. 39 | * toggle 0,0 through 999,999 would increase the total brightness by 2000000. 40 | -------------------------------------------------------------------------------- /CircuitBreaker/readme.md: -------------------------------------------------------------------------------- 1 | # Circuit Breakers 2 | 3 | To quote Martin Fowler: 4 | 5 | > It's common for software systems to make remote calls to software running in different processes, probably on different machines across a network. 6 | 7 | >One of the big differences between in-memory calls and remote calls is that remote calls can fail, or hang without a response until some timeout limit is reached. 8 | 9 | >What's worse if you have many callers on a unresponsive supplier, then you can run out of critical resources leading to cascading failures across multiple systems. 10 | 11 | >In his excellent book Release It, Michael Nygard popularized the Circuit Breaker pattern to prevent this kind of catastrophic cascade. 12 | 13 | 14 | Circuit breakers are very simple - they: 15 | 16 | * Wrap a protected function call in a circuit breaker object, which monitors for failures. 17 | * Once the failures reach a certain threshold, the circuit breaker trips 18 | * Further calls to the circuit breaker return with an error without the protected call being made at all. 19 | * After a time limit, the circuit enters a "half-open" state 20 | * While half-open, the next call is allowed through 21 | * If the call succeeds, the circuit closes 22 | * If the call fails, the circuit opens and a timer is reset 23 | 24 | A circuit breaker has three states, and is modeled after electrical circuits 25 | 26 | * Closed - A closed circuit sends requests naturally 27 | * Open - Automatically returns an error when a call is attempted. 28 | * Half open - After a timeout, a open circuit becomes "half open" allowing a single call through 29 | 30 | 31 | 32 | --- 33 | ## Story - Implement a circuit breaker 34 | 35 | As a systems maintainer 36 | I want my calls to be resilient to failure 37 | So I don't need to turn features on and off 38 | 39 | - Implement the circuit breaker pattern 40 | - Fault tolerance should be configurable 41 | - Half-open timeouts should be configurable 42 | 43 | 44 | ### Scenario 1 - Monitoring failure 45 | 46 | As a developer 47 | I want to count failures when I make calls 48 | A failure count is incremented 49 | 50 | ### Scenario 2 - Opening a circuit 51 | 52 | As a developer 53 | When my failure count exceeds a configured tolerance 54 | All subsequent calls throw an exception and block the call 55 | 56 | ### Scenario 3 - Half opened state 57 | 58 | As a developer 59 | When my code is blocking calls and a configured timeout passes 60 | I allow a single call to proceed 61 | 62 | - Single call succeeding closes circuit 63 | - Single call failing resets some kind of timeout 64 | -------------------------------------------------------------------------------- /Concordance/magna_carta.txt: -------------------------------------------------------------------------------- 1 | JOHN, by the grace of God King of England, Lord of Ireland, Duke of Normandy and Aquitaine, and Count of Anjou, to his archbishops, bishops, abbots, earls, barons, justices, foresters, sheriffs, stewards, servants, and to all his officials and loyal subjects, Greeting. 2 | 3 | 4 | 5 | KNOW THAT BEFORE GOD, for the health of our soul and those of our ancestors and heirs, to the honour of God, the exaltation of the holy Church, and the better ordering of our kingdom, at the advice of our reverend fathers Stephen, archbishop of Canterbury, primate of all England, and cardinal of the holy Roman Church, Henry archbishop of Dublin, William bishop of London, Peter bishop of Winchester, Jocelin bishop of Bath and Glastonbury, Hugh bishop of Lincoln, Walter Bishop of Worcester, William bishop of Coventry, Benedict bishop of Rochester, Master Pandulf subdeacon and member of the papal household, Brother Aymeric master of the knighthood of the Temple in England, William Marshal earl of Pembroke, William earl of Salisbury, William earl of Warren, William earl of Arundel, Alan de Galloway constable of Scotland, Warin Fitz Gerald, Peter Fitz Herbert, Hubert de Burgh seneschal of Poitou, Hugh de Neville, Matthew Fitz Herbert, Thomas Basset, Alan Basset, Philip Daubeny, Robert de Roppeley, John Marshal, John Fitz Hugh, and other loyal subjects: 6 | 7 | + (1) FIRST, THAT WE HAVE GRANTED TO GOD, and by this present charter have confirmed for us and our heirs in perpetuity, that the English Church shall be free, and shall have its rights undiminished, and its liberties unimpaired. That we wish this so to be observed, appears from the fact that of our own free will, before the outbreak of the present dispute between us and our barons, we granted and confirmed by charter the freedom of the Church's elections - a right reckoned to be of the greatest necessity and importance to it - and caused this to be confirmed by Pope Innocent III. This freedom we shall observe ourselves, and desire to be observed in good faith by our heirs in perpetuity. 8 | 9 | TO ALL FREE MEN OF OUR KINGDOM we have also granted, for us and our heirs for ever, all the liberties written out below, to have and to keep for them and their heirs, of us and our heirs: 10 | 11 | (2) If any earl, baron, or other person that holds lands directly of the Crown, for military service, shall die, and at his death his heir shall be of full age and owe a `relief', the heir shall have his inheritance on payment of the ancient scale of `relief'. That is to say, the heir or heirs of an earl shall pay £100 for the entire earl's barony, the heir or heirs of a knight l00s. at most for the entire knight's `fee', and any man that owes less shall pay less, in accordance with the ancient usage of `fees' 12 | 13 | (3) But if the heir of such a person is under age and a ward, when he comes of age he shall have his inheritance without `relief' or fine. 14 | 15 | (4) The guardian of the land of an heir who is under age shall take from it only reasonable revenues, customary dues, and feudal services. He shall do this without destruction or damage to men or property. If we have given the guardianship of the land to a sheriff, or to any person answerable to us for the revenues, and he commits destruction or damage, we will exact compensation from him, and the land shall be entrusted to two worthy and prudent men of the same `fee', who shall be answerable to us for the revenues, or to the person to whom we have assigned them. If we have given or sold to anyone the guardianship of such land, and he causes destruction or damage, he shall lose the guardianship of it, and it shall be handed over to two worthy and prudent men of the same `fee', who shall be similarly answerable to us. 16 | 17 | (5) For so long as a guardian has guardianship of such land, he shall maintain the houses, parks, fish preserves, ponds, mills, and everything else pertaining to it, from the revenues of the land itself. When the heir comes of age, he shall restore the whole land to him, stocked with plough teams and such implements of husbandry as the season demands and the revenues from the land can reasonably bear. 18 | 19 | (6) Heirs may be given in marriage, but not to someone of lower social standing. Before a marriage takes place, it shall be' made known to the heir's next-of-kin. 20 | 21 | (7) At her husband's death, a widow may have her marriage portion and inheritance at once and without trouble. She shall pay nothing for her dower, marriage portion, or any inheritance that she and her husband held jointly on the day of his death. She may remain in her husband's house for forty days after his death, and within this period her dower shall be assigned to her. 22 | 23 | (8) No widow shall be compelled to marry, so long as she wishes to remain without a husband. But she must give security that she will not marry without royal consent, if she holds her lands of the Crown, or without the consent of whatever other lord she may hold them of. 24 | 25 | (9) Neither we nor our officials will seize any land or rent in payment of a debt, so long as the debtor has movable goods sufficient to discharge the debt. A debtor's sureties shall not be distrained upon so long as the debtor himself can discharge his debt. If, for lack of means, the debtor is unable to discharge his debt, his sureties shall be answerable for it. If they so desire, they may have the debtor's lands and rents until they have received satisfaction for the debt that they paid for him, unless the debtor can show that he has settled his obligations to them. 26 | 27 | * (10) If anyone who has borrowed a sum of money from Jews dies before the debt has been repaid, his heir shall pay no interest on the debt for so long as he remains under age, irrespective of whom he holds his lands. If such a debt falls into the hands of the Crown, it will take nothing except the principal sum specified in the bond. 28 | 29 | * (11) If a man dies owing money to Jews, his wife may have her dower and pay nothing towards the debt from it. If he leaves children that are under age, their needs may also be provided for on a scale appropriate to the size of his holding of lands. The debt is to be paid out of the residue, reserving the service due to his feudal lords. Debts owed to persons other than Jews are to be dealt with similarly. 30 | 31 | * (12) No `scutage' or `aid' may be levied in our kingdom without its general consent, unless it is for the ransom of our person, to make our eldest son a knight, and (once) to marry our eldest daughter. For these purposes ouly a reasonable `aid' may be levied. `Aids' from the city of London are to be treated similarly. 32 | 33 | + (13) The city of London shall enjoy all its ancient liberties and free customs, both by land and by water. We also will and grant that all other cities, boroughs, towns, and ports shall enjoy all their liberties and free customs. 34 | 35 | * (14) To obtain the general consent of the realm for the assessment of an `aid' - except in the three cases specified above - or a `scutage', we will cause the archbishops, bishops, abbots, earls, and greater barons to be summoned individually by letter. To those who hold lands directly of us we will cause a general summons to be issued, through the sheriffs and other officials, to come together on a fixed day (of which at least forty days notice shall be given) and at a fixed place. In all letters of summons, the cause of the summons will be stated. When a summons has been issued, the business appointed for the day shall go forward in accordance with the resolution of those present, even if not all those who were summoned have appeared. 36 | 37 | * (15) In future we will allow no one to levy an `aid' from his free men, except to ransom his person, to make his eldest son a knight, and (once) to marry his eldest daughter. For these purposes only a reasonable `aid' may be levied. 38 | 39 | (16) No man shall be forced to perform more service for a knight's `fee', or other free holding of land, than is due from it. 40 | 41 | (17) Ordinary lawsuits shall not follow the royal court around, but shall be held in a fixed place. 42 | 43 | (18) Inquests of novel disseisin, mort d'ancestor, and darrein presentment shall be taken only in their proper county court. We ourselves, or in our absence abroad our chief justice, will send two justices to each county four times a year, and these justices, with four knights of the county elected by the county itself, shall hold the assizes in the county court, on the day and in the place where the court meets. 44 | 45 | (19) If any assizes cannot be taken on the day of the county court, as many knights and freeholders shall afterwards remain behind, of those who have attended the court, as will suffice for the administration of justice, having regard to the volume of business to be done. 46 | 47 | (20) For a trivial offence, a free man shall be fined only in proportion to the degree of his offence, and for a serious offence correspondingly, but not so heavily as to deprive him of his livelihood. In the same way, a merchant shall be spared his merchandise, and a husbandman the implements of his husbandry, if they fall upon the mercy of a royal court. None of these fines shall be imposed except by the assessment on oath of reputable men of the neighbourhood. 48 | 49 | (21) Earls and barons shall be fined only by their equals, and in proportion to the gravity of their offence. 50 | 51 | (22) A fine imposed upon the lay property of a clerk in holy orders shall be assessed upon the same principles, without reference to the value of his ecclesiastical benefice. 52 | 53 | (23) No town or person shall be forced to build bridges over rivers except those with an ancient obligation to do so. 54 | 55 | (24) No sheriff, constable, coroners, or other royal officials are to hold lawsuits that should be held by the royal justices. 56 | 57 | * (25) Every county, hundred, wapentake, and tithing shall remain at its ancient rent, without increase, except the royal demesne manors. 58 | 59 | (26) If at the death of a man who holds a lay `fee' of the Crown, a sheriff or royal official produces royal letters patent of summons for a debt due to the Crown, it shall be lawful for them to seize and list movable goods found in the lay `fee' of the dead man to the value of the debt, as assessed by worthy men. Nothing shall be removed until the whole debt is paid, when the residue shall be given over to the executors to carry out the dead man s will. If no debt is due to the Crown, all the movable goods shall be regarded as the property of the dead man, except the reasonable shares of his wife and children. 60 | 61 | * (27) If a free man dies intestate, his movable goods are to be distributed by his next-of-kin and friends, under the supervision of the Church. The rights of his debtors are to be preserved. 62 | 63 | (28) No constable or other royal official shall take corn or other movable goods from any man without immediate payment, unless the seller voluntarily offers postponement of this. 64 | 65 | (29) No constable may compel a knight to pay money for castle-guard if the knight is willing to undertake the guard in person, or with reasonable excuse to supply some other fit man to do it. A knight taken or sent on military service shall be excused from castle-guard for the period of this servlce. 66 | 67 | (30) No sheriff, royal official, or other person shall take horses or carts for transport from any free man, without his consent. 68 | 69 | (31) Neither we nor any royal official will take wood for our castle, or for any other purpose, without the consent of the owner. 70 | 71 | (32) We will not keep the lands of people convicted of felony in our hand for longer than a year and a day, after which they shall be returned to the lords of the `fees' concerned. 72 | 73 | (33) All fish-weirs shall be removed from the Thames, the Medway, and throughout the whole of England, except on the sea coast. 74 | 75 | (34) The writ called precipe shall not in future be issued to anyone in respect of any holding of land, if a free man could thereby be deprived of the right of trial in his own lord's court. 76 | 77 | (35) There shall be standard measures of wine, ale, and corn (the London quarter), throughout the kingdom. There shall also be a standard width of dyed cloth, russett, and haberject, namely two ells within the selvedges. Weights are to be standardised similarly. 78 | 79 | (36) In future nothing shall be paid or accepted for the issue of a writ of inquisition of life or limbs. It shall be given gratis, and not refused. 80 | 81 | (37) If a man holds land of the Crown by `fee-farm', `socage', or `burgage', and also holds land of someone else for knight's service, we will not have guardianship of his heir, nor of the land that belongs to the other person's `fee', by virtue of the `fee-farm', `socage', or `burgage', unless the `fee-farm' owes knight's service. We will not have the guardianship of a man's heir, or of land that he holds of someone else, by reason of any small property that he may hold of the Crown for a service of knives, arrows, or the like. 82 | 83 | (38) In future no official shall place a man on trial upon his own unsupported statement, without producing credible witnesses to the truth of it. 84 | 85 | + (39) No free man shall be seized or imprisoned, or stripped of his rights or possessions, or outlawed or exiled, or deprived of his standing in any other way, nor will we proceed with force against him, or send others to do so, except by the lawful judgement of his equals or by the law of the land. 86 | 87 | + (40) To no one will we sell, to no one deny or delay right or justice. 88 | 89 | (41) All merchants may enter or leave England unharmed and without fear, and may stay or travel within it, by land or water, for purposes of trade, free from all illegal exactions, in accordance with ancient and lawful customs. This, however, does not apply in time of war to merchants from a country that is at war with us. Any such merchants found in our country at the outbreak of war shall be detained without injury to their persons or property, until we or our chief justice have discovered how our own merchants are being treated in the country at war with us. If our own merchants are safe they shall be safe too. 90 | 91 | * (42) In future it shall be lawful for any man to leave and return to our kingdom unharmed and without fear, by land or water, preserving his allegiance to us, except in time of war, for some short period, for the common benefit of the realm. People that have been imprisoned or outlawed in accordance with the law of the land, people from a country that is at war with us, and merchants - who shall be dealt with as stated above - are excepted from this provision. 92 | 93 | (43) If a man holds lands of any `escheat' such as the `honour' of Wallingford, Nottingham, Boulogne, Lancaster, or of other `escheats' in our hand that are baronies, at his death his heir shall give us only the `relief' and service that he would have made to the baron, had the barony been in the baron's hand. We will hold the `escheat' in the same manner as the baron held it. 94 | 95 | (44) People who live outside the forest need not in future appear before the royal justices of the forest in answer to general summonses, unless they are actually involved in proceedings or are sureties for someone who has been seized for a forest offence. 96 | 97 | * (45) We will appoint as justices, constables, sheriffs, or other officials, only men that know the law of the realm and are minded to keep it well. 98 | 99 | (46) All barons who have founded abbeys, and have charters of English kings or ancient tenure as evidence of this, may have guardianship of them when there is no abbot, as is their due. 100 | 101 | (47) All forests that have been created in our reign shall at once be disafforested. River-banks that have been enclosed in our reign shall be treated similarly. 102 | 103 | * (48) All evil customs relating to forests and warrens, foresters, warreners, sheriffs and their servants, or river-banks and their wardens, are at once to be investigated in every county by twelve sworn knights of the county, and within forty days of their enquiry the evil customs are to be abolished completely and irrevocably. But we, or our chief justice if we are not in England, are first to be informed. 104 | 105 | * (49) We will at once return all hostages and charters delivered up to us by Englishmen as security for peace or for loyal service. 106 | 107 | * (50) We will remove completely from their offices the kinsmen of Gerard de Athée, and in future they shall hold no offices in England. The people in question are Engelard de Cigogné', Peter, Guy, and Andrew de Chanceaux, Guy de Cigogné, Geoffrey de Martigny and his brothers, Philip Marc and his brothers, with Geoffrey his nephew, and all their followers. 108 | 109 | * (51) As soon as peace is restored, we will remove from the kingdom all the foreign knights, bowmen, their attendants, and the mercenaries that have come to it, to its harm, with horses and arms. 110 | 111 | * (52) To any man whom we have deprived or dispossessed of lands, castles, liberties, or rights, without the lawful judgement of his equals, we will at once restore these. In cases of dispute the matter shall be resolved by the judgement of the twenty-five barons referred to below in the clause for securing the peace (§ 61). In cases, however, where a man was deprived or dispossessed of something without the lawful judgement of his equals by our father King Henry or our brother King Richard, and it remains in our hands or is held by others under our warranty, we shall have respite for the period commonly allowed to Crusaders, unless a lawsuit had been begun, or an enquiry had been made at our order, before we took the Cross as a Crusader. On our return from the Crusade, or if we abandon it, we will at once render justice in full. 112 | 113 | * (53) We shall have similar respite in rendering justice in connexion with forests that are to be disafforested, or to remain forests, when these were first a-orested by our father Henry or our brother Richard; with the guardianship of lands in another person's `fee', when we have hitherto had this by virtue of a `fee' held of us for knight's service by a third party; and with abbeys founded in another person's `fee', in which the lord of the `fee' claims to own a right. On our return from the Crusade, or if we abandon it, we will at once do full justice to complaints about these matters. 114 | 115 | (54) No one shall be arrested or imprisoned on the appeal of a woman for the death of any person except her husband. 116 | 117 | * (55) All fines that have been given to us unjustiy and against the law of the land, and all fines that we have exacted unjustly, shall be entirely remitted or the matter decided by a majority judgement of the twenty-five barons referred to below in the clause for securing the peace (§ 61) together with Stephen, archbishop of Canterbury, if he can be present, and such others as he wishes to bring with him. If the archbishop cannot be present, proceedings shall continue without him, provided that if any of the twenty-five barons has been involved in a similar suit himself, his judgement shall be set aside, and someone else chosen and sworn in his place, as a substitute for the single occasion, by the rest of the twenty-five. 118 | 119 | (56) If we have deprived or dispossessed any Welshmen of lands, liberties, or anything else in England or in Wales, without the lawful judgement of their equals, these are at once to be returned to them. A dispute on this point shall be determined in the Marches by the judgement of equals. English law shall apply to holdings of land in England, Welsh law to those in Wales, and the law of the Marches to those in the Marches. The Welsh shall treat us and ours in the same way. 120 | 121 | * (57) In cases where a Welshman was deprived or dispossessed of anything, without the lawful judgement of his equals, by our father King Henry or our brother King Richard, and it remains in our hands or is held by others under our warranty, we shall have respite for the period commonly allowed to Crusaders, unless a lawsuit had been begun, or an enquiry had been made at our order, before we took the Cross as a Crusader. But on our return from the Crusade, or if we abandon it, we will at once do full justice according to the laws of Wales and the said regions. 122 | 123 | * (58) We will at once return the son of Llywelyn, all Welsh hostages, and the charters delivered to us as security for the peace. 124 | 125 | * (59) With regard to the return of the sisters and hostages of Alexander, king of Scotland, his liberties and his rights, we will treat him in the same way as our other barons of England, unless it appears from the charters that we hold from his father William, formerly king of Scotland, that he should be treated otherwise. This matter shall be resolved by the judgement of his equals in our court. 126 | 127 | (60) All these customs and liberties that we have granted shall be observed in our kingdom in so far as concerns our own relations with our subjects. Let all men of our kingdom, whether clergy or laymen, observe them similarly in their relations with their own men. 128 | 129 | * (61) SINCE WE HAVE GRANTED ALL THESE THINGS for God, for the better ordering of our kingdom, and to allay the discord that has arisen between us and our barons, and since we desire that they shall be enjoyed in their entirety, with lasting strength, for ever, we give and grant to the barons the following security: 130 | 131 | The barons shall elect twenty-five of their number to keep, and cause to be observed with all their might, the peace and liberties granted and confirmed to them by this charter. 132 | 133 | If we, our chief justice, our officials, or any of our servants offend in any respect against any man, or transgress any of the articles of the peace or of this security, and the offence is made known to four of the said twenty-five barons, they shall come to us - or in our absence from the kingdom to the chief justice - to declare it and claim immediate redress. If we, or in our absence abroad the chiefjustice, make no redress within forty days, reckoning from the day on which the offence was declared to us or to him, the four barons shall refer the matter to the rest of the twenty-five barons, who may distrain upon and assail us in every way possible, with the support of the whole community of the land, by seizing our castles, lands, possessions, or anything else saving only our own person and those of the queen and our children, until they have secured such redress as they have determined upon. Having secured the redress, they may then resume their normal obedience to us. 134 | 135 | Any man who so desires may take an oath to obey the commands of the twenty-five barons for the achievement of these ends, and to join with them in assailing us to the utmost of his power. We give public and free permission to take this oath to any man who so desires, and at no time will we prohibit any man from taking it. Indeed, we will compel any of our subjects who are unwilling to take it to swear it at our command. 136 | 137 | If-one of the twenty-five barons dies or leaves the country, or is prevented in any other way from discharging his duties, the rest of them shall choose another baron in his place, at their discretion, who shall be duly sworn in as they were. 138 | 139 | In the event of disagreement among the twenty-five barons on any matter referred to them for decision, the verdict of the majority present shall have the same validity as a unanimous verdict of the whole twenty-five, whether these were all present or some of those summoned were unwilling or unable to appear. 140 | 141 | The twenty-five barons shall swear to obey all the above articles faithfully, and shall cause them to be obeyed by others to the best of their power. 142 | 143 | We will not seek to procure from anyone, either by our own efforts or those of a third party, anything by which any part of these concessions or liberties might be revoked or diminished. Should such a thing be procured, it shall be null and void and we will at no time make use of it, either ourselves or through a third party. 144 | 145 | * (62) We have remitted and pardoned fully to all men any ill-will, hurt, or grudges that have arisen between us and our subjects, whether clergy or laymen, since the beginning of the dispute. We have in addition remitted fully, and for our own part have also pardoned, to all clergy and laymen any offences committed as a result of the said dispute between Easter in the sixteenth year of our reign (i.e. 1215) and the restoration of peace. 146 | 147 | In addition we have caused letters patent to be made for the barons, bearing witness to this security and to the concessions set out above, over the seals of Stephen archbishop of Canterbury, Henry archbishop of Dublin, the other bishops named above, and Master Pandulf. 148 | 149 | * (63) IT IS ACCORDINGLY OUR WISH AND COMMAND that the English Church shall be free, and that men in our kingdom shall have and keep all these liberties, rights, and concessions, well and peaceably in their fulness and entirety for them and their heirs, of us and our heirs, in all things and all places for ever. 150 | 151 | Both we and the barons have sworn that all this shall be observed in good faith and without deceit. Witness the abovementioned people and many others. 152 | 153 | Given by our hand in the meadow that is called Runnymede, between Windsor and Staines, on the fifteenth day of June in the seventeenth year of our reign (i.e. 1215: the new regnal year began on 28 May). -------------------------------------------------------------------------------- /Concordance/readme.md: -------------------------------------------------------------------------------- 1 | # Concordance Kata 2 | 3 | A concordance (https://en.wikipedia.org/wiki/Concordance_%28publishing%29) is an alphabetical list of the principal words used in a 4 | book or body of work, listing every instance of each word with its 5 | immediate context. 6 | 7 | Only works of special importance have had 8 | concordances prepared for them, such as the Vedas, 9 | Bible, Qur'an or the works of Shakespeare or classical Latin and 10 | Greek authors, because of the time, difficulty, and expense involved 11 | in creating a concordance in the pre-computer era. 12 | 13 | # Generate a Concordance 14 | 15 | The purpose of this kata is to write a program that generates a concordance. 16 | Included is a copy of the Magna Carta. -------------------------------------------------------------------------------- /ConwaysGameOfLife/readme.md: -------------------------------------------------------------------------------- 1 | # Conways Game of Life 2 | 3 | The Game of Life is a cellular automaton devised by the mathematician John Horton Conway in 1970. 4 | 5 | The "game" is a **zero-player game**, meaning that its **evolution is determined by its initial state**, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves or, for advanced players, by creating patterns with particular properties. 6 | 7 | 8 | ## The Rules 9 | 10 | The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead. 11 | 12 | Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, cells evaluate their state and transition between being alive and dead depending on their neighbours. 13 | 14 | The initial pattern constitutes the seed of the system. 15 | 16 | The first generation is created by applying the rule in the user stories below simultaneously to every cell in the seed. Births and deaths occur simultaneously, and the discrete moment at which this happens is called a tick. 17 | 18 | The rules continue to be applied repeatedly to create further generations. 19 | 20 | ## Expressed as user stories 21 | 22 | Scenario 1: 23 | 24 | As a *player* 25 | When I start the program 26 | I see a gameboard on screen 27 | 28 | Scenario 2: 29 | 30 | As a *player* 31 | When I start the program 32 | I can generate a random initial state 33 | 34 | Accept: 35 | Half or less of the cells set to alive at random 36 | Living cells visible on the rendered gameboard 37 | 38 | Scenario 3: 39 | 40 | As a *living cell* 41 | When the game ticks 42 | I change state 43 | 44 | Accept: 45 | If cell has < 2 living neighbours, cell dies 46 | If cell has > 3 living neighbours, cell dies 47 | If cell has 2-3 living neighbours, cell lives 48 | 49 | 50 | Scenario 4: 51 | 52 | As a *dead or empty cell* 53 | When the game ticks 54 | I change state 55 | 56 | Accept: 57 | If cell has 3 living neighbours, cell lives 58 | 59 | Feel free to render the board and the states in any way, and in any language you like - but I'd recommend a command line app for the purpose of this excercise. 60 | 61 | We'll be spending an hour. 62 | 63 | ## Example 64 | 65 | Initial State: 66 | 67 | |   |   |   |   | 68 | | - | - | - | - | 69 | | | A | | | 70 | | | A | | | 71 | | | A | | | 72 | | | | |   | 73 | 74 | 75 | Tick 1: 76 | 77 | |   |   |   |   | 78 | | - | - | - | - | 79 | |   | | | | 80 | | A | A | A | | 81 | |   | | | | 82 | | | | |   | 83 | 84 | There are lots of [example patterns on wikipedia](http://en.wikipedia.org/wiki/Conway's_Game_of_Life#Examples_of_pattern) 85 | 86 | --- 87 | 88 | We're going to be implementing Conways game of life - using [ping pong TDD](http://c2.com/cgi/wiki?PairProgrammingPingPongPattern). 89 | 90 | Ping Pong TDD is a simple practice: 91 | 92 | * Dev 1 writes a new test and sees that it fails. 93 | * Dev 2 implements the code needed to pass the test. 94 | * Dev 2 writes the next test and sees that it fails. 95 | * Dev 1 implements the code needed to pass the test. 96 | 97 | If this is your first time, try pairing with someone you don't normally work with. 98 | -------------------------------------------------------------------------------- /CreditCardValidation/readme.md: -------------------------------------------------------------------------------- 1 | This is derived from RubyQuiz: http://rubyquiz.com/quiz122.html 2 | 3 | # Credit Card Validation and Detection 4 | 5 | Before a credit card is submitted to a financial institution, it generally makes sense to run some simple reality checks on the number. The numbers are a good length and it's common to make minor transcription errors when the card is not scanned directly. 6 | 7 | The first check people often do is to validate that the card matches a known pattern from one of the accepted card providers. Some of these patterns are: 8 | 9 | +============+=============+===============+ 10 | | Card Type | Begins With | Number Length | 11 | +============+=============+===============+ 12 | | AMEX | 34 or 37 | 15 | 13 | +------------+-------------+---------------+ 14 | | Discover | 6011 | 16 | 15 | +------------+-------------+---------------+ 16 | | MasterCard | 51-55 | 16 | 17 | +------------+-------------+---------------+ 18 | | Visa | 4 | 13 or 16 | 19 | +------------+-------------+---------------+ 20 | 21 | Writing code to detect these card types is simple enough, but additionally, card numbers are generated so that they all validate against the `Luhn Check`. 22 | 23 | 1. Starting with the next to last digit and continuing with every other 24 | digit going back to the beginning of the card, double the digit 25 | 2. Sum all doubled and untouched digits in the number 26 | 3. If that total is a multiple of 10, the number is valid 27 | 28 | Valid example - 29 | 30 | 1. 8 4 0 8 0 4 2 2 6 4 10 6 14 8 18 3 31 | 2. 8+4+0+8+0+4+2+2+6+4+1+0+6+1+4+8+1+8+3 = 70 32 | 3. 70 % 10 == 0 33 | 34 | Invalid example - 35 | 36 | 1. 8 4 2 7 2 2 6 4 10 6 14 8 18 1 2 2 37 | 2. 8+4+2+7+2+2+6+4+1+0+6+1+4+8+1+8+1+2+2 = 69 38 | 3. 69 % 10 != 0 39 | 40 | 41 | Lets write some code to detect and identify card types. 42 | 43 | ## Story 1 - Detect card type 44 | 45 | As a user 46 | When I provide a card number 47 | The card type is detected 48 | 49 | ## Story 2 - Luhn validity 50 | 51 | As a user 52 | When I provide a card number 53 | It is validated against the luhn algorithm 54 | 55 | 56 | # Notes 57 | 58 | Pay attention to how you factor your code - is there an elegant way to express these types of validation rules? 59 | 60 | Can you think of creative or idiomatic ways to express these kinds of requirements? 61 | 62 | Be playful - it's a kata! 63 | -------------------------------------------------------------------------------- /Cryptograms/readme.md: -------------------------------------------------------------------------------- 1 | # Original Description 2 | 3 | This is derived from a quiz posted on rubyquiz.com see: http://rubyquiz.com/quiz13.html 4 | 5 | ## Problem Description 6 | 7 | A cryptogram is piece of text that has been passed through a simple cipher that maps all instances of one letter to a different letter. The familiar rot13 encoding is a trivial example. 8 | 9 | A solution to a cryptogram is a one-to-one mapping between two sets of (up to) 26 letters, such that applying the map to the cryptogram yields the greatest possible number from words in the dictionary. 10 | 11 | Three unsolved cryptograms given. Each cryptogram uses a different cipher. **The cryptograms may contain a few words that are not in the dictionary**. 12 | 13 | Theres a dictionary in the root of this repository you can use. 14 | 15 | ### Story - Detect cipher 16 | 17 | As a user, when I provide a cryptogram 18 | I want to detect the most likely cipher 19 | So I can crack codes! 20 | 21 | Accept: Translation output 22 | Translation with most valid detected words choosen 23 | 24 | ### Story - Output cipher 25 | 26 | As a user, when detect a cipher 27 | I want to output the cipher results to the screen 28 | So I can see which letters correspond in my match 29 | 30 | Accept: Cipher matches output 31 | 32 | # Examples 33 | 34 | Given this cryptogram 35 | 36 | gebo tev e cwaack cegn gsatkb ussyk 37 | 38 | Output is 39 | 40 | 41 | Best match: mary had a little lamb mother goose 42 | 43 | Cipher 44 | abcdefghijklmnopqrstuvwxyz 45 | trl.a.m...e..by...ohgdi.s. 46 | 47 | 48 | ## CRYPTOGRAMS 49 | 50 | Sample 1 51 | 52 | zfsbhd bd lsf xfe ofsr bsdxbejrbls sbsfra sbsf xfe ofsr xfedxbejrbls rqlujd jvwj fpbdls 53 | 54 | Sample 2 55 | 56 | mkr ideerqruhr nrmsrru mkr ozgcym qdakm scqi oui mkr qdakm scqi dy mkr ideerqruhr nrmsrru mkr zdakmudua nja oui mkr zdakmudua goqb msodu 57 | 58 | Sample 3 59 | 60 | ftyw uwmb yw ilwwv qvb bjtvi fupxiu t dqvi tv yj huqtvd mtrw fuw dwq bjmqv fupyqd 61 | -------------------------------------------------------------------------------- /DeletingCodeComments/readme.md: -------------------------------------------------------------------------------- 1 | # Deleting Code Comments 2 | 3 | One of the biggest frustrations that people often have with with legacy code-bases is the prevalence of huge blocks of commented out code. This code is clutter that confuses the future maintenance of software, so today we're going to write a program that removes them. 4 | 5 | As a secondary concern, we want to retain "narrative comments" and XDoc / Ghost doc style comments on class, method, and interface signatures. 6 | 7 | The syntax of comment blocks varies from language to language - pick one of your choice to start with. Requirement examples are in C#. 8 | 9 | ## Requirements 10 | 11 | ### Story 1 - Stripping commented out code 12 | 13 | As a user 14 | When I run the program over a specific file 15 | Single line comment blocks are removed 16 | 17 | Accept: 18 | 19 | Single line code comments removed 20 | // Console.WriteLine("remove this"); 21 | 22 | ### Story 2 - Retaining single line text comments 23 | 24 | As a user 25 | When I run the program over a specific file 26 | Single line text comments retained 27 | 28 | Accept: 29 | 30 | Single line text comments retained 31 | // Do not remove me 32 | 33 | ### Story 3 - Removing multi-line comments 34 | 35 | As a user 36 | When I run the program over a specific file 37 | Multi-line comment blocks are removed 38 | 39 | Accept: 40 | 41 | /* Remove 42 | 43 | anything like this 44 | */ 45 | 46 | ### Story 3 - XMLDoc style comments retained 47 | 48 | As a user 49 | When I run the program 50 | Comments on method, interface and class declarations are retained 51 | 52 | Accept: 53 | 54 | Comments in this style retained 55 | 56 | /// 57 | /// Class level summary documentation goes here. 58 | /// 59 | /// Longer comments can be associated with a type or member 60 | /// through the remarks tag 61 | public class SomeClass 62 | {.... 63 | 64 | 65 | ## Example file 66 | 67 | ```csharp 68 | /// 69 | /// Good comment 70 | /// 71 | public class Test 72 | { 73 | /// 74 | /// Good comment 75 | /// 76 | public void Method() 77 | { 78 | // Console.WriteLine("haha"); // BAD COMMENT! 79 | 80 | Console.WriteLine("Hi"); // Good comment 81 | 82 | // Good comment 83 | Console.WriteLine("with some narrative"); 84 | 85 | /* 86 | * Good comment 87 | */ 88 | 89 | //Console.WriteLine("Bad"); 90 | //Console.WriteLine("Bad"); 91 | //Console.WriteLine("Bad"); 92 | //Console.WriteLine("Bad"); 93 | //Console.WriteLine("Bad"); 94 | 95 | /* 96 | Console.WriteLine("Very bad"); 97 | Console.WriteLine("Very bad"); 98 | Console.WriteLine("Very bad"); 99 | Console.WriteLine("Very bad"); 100 | Console.WriteLine("Very bad"); 101 | Console.WriteLine("Very bad"); 102 | Console.WriteLine("Very bad");*/ 103 | 104 | /* 105 | Good comment 106 | */ 107 | Console.WriteLine("Some code"); 108 | 109 | //Console.WriteLine("Bad comment"); 110 | Console.WriteLine("Good code"); 111 | } 112 | } 113 | ``` 114 | -------------------------------------------------------------------------------- /Diamond Kata/readme.md: -------------------------------------------------------------------------------- 1 | ### Origin 2 | 3 | This kata is based on a post by Seb Rose here: http://claysnow.co.uk/recycling-tests-in-tdd/ 4 | 5 | ### Problem 6 | 7 | Given a character from the alphabet, print a diamond of its output with that character being the midpoint of the diamond. 8 | 9 | Examples 10 | 11 | > diamond.exe A 12 | A 13 | 14 | > diamond.exe B 15 | A 16 | B B 17 | A 18 | 19 | > diamond.exe C 20 | A 21 | B B 22 | C C 23 | B B 24 | A 25 | 26 | It may be helpful visualise the whitespace in your rendering like this: 27 | 28 | > diamond.exe C 29 | _ _ A _ _ 30 | _ B _ B _ 31 | C _ _ _ C 32 | _ B _ B _ 33 | _ _ A _ _ 34 | -------------------------------------------------------------------------------- /Dijkstra/readme.md: -------------------------------------------------------------------------------- 1 | Dijkstra's Algorithm for path-finding 2 | ====================================== 3 | 4 | Dijkstra thought about shortest path problem when working at Mathematical Center in Amsterdam in 1956 as a program to demonstrate capabilities of the new computer called ARMAC. 5 | 6 | His objective was to choose both a problem as well as answer (that will be produced by computer) that non-computing people can understand. He designed the shortest path algorithm in about 20 minutes without aid of paper and pen and later implemented it for ARMAC for slightly simplified transportation map of 64 cities in Netherland. 7 | 8 | The algorithm and the A* variant are used for path finding in video games, attempting traveling salesman style problems, and are pretty fun to see working. 9 | 10 | Algorithm 11 | ========== 12 | 13 | **1)** **Assign to every node a tentative distance value**: set it to zero for our initial node and to infinity for all other nodes. 14 | 15 | **2)** Set the initial node as current. Mark all other nodes unvisited. Create a set of all the unvisited nodes called the unvisited set. 16 | 17 | **3)** For the current node, **consider all of its unvisited neighbors** and calculate their tentative distances. 18 | 19 | You can use a "Manhatten score" to work out a tentative distance: 20 | 21 | > (x1 - x2) + (y1 - y2) 22 | 23 | Compare the newly calculated tentative distance to the current assigned value and assign the smaller one. 24 | 25 | For example: 26 | 27 | If the current node A is marked with a distance of 6 28 | The edge connecting it with a neighbor B has length 2 29 | The distance to B (through A) will be 6 + 2 = 8. 30 | If B was previously marked with a distance greater than 8 then change it to 8. 31 | 32 | 33 | **4)** When we are done considering all of the neighbors of the current node, mark the current node as visited and remove it from the unvisited set. **A visited node will never be checked again**. 34 | 35 | **5)** If the destination node has been marked visited (when planning a route between two specific nodes) **or** if the smallest tentative distance among the nodes in the unvisited set is infinity (when planning a complete traversal; occurs when there is no connection between the initial node and remaining unvisited nodes), **then stop**. **The algorithm has finished.** 36 | 37 | **6)** Select the unvisited node that is marked with the **smallest tentative distance**, and set it as the new "current node" then go back to step 3. 38 | 39 | 40 | Build a pathfinder 41 | =================== 42 | 43 | We want to find the shortest path from S to D given the node layout below. 44 | Paths can be diagonal. 45 | 46 | * S: Starting point 47 | * D: Destination 48 | * \#: Traversable node 49 | * @: Blocked / un-traversable 50 | 51 | 52 | ##########D#### 53 | ############### 54 | ###@@@@@@@@#### 55 | ########@@@#### 56 | ##########@#### 57 | ############### 58 | ####S########## 59 | ############### 60 | 61 | 62 | ## Story 1 - Display the path scores 63 | 64 | As a user 65 | When I provide two points 66 | I want see the #'s replaced with distance scores 67 | 68 | Accept: Output to screen 69 | 70 | ## Story 2 - Select the shortest route 71 | 72 | As a user 73 | I want to visualise the shortest path 74 | So I can marvel in its wonder. 75 | 76 | Accept: Some kind of visualisation on screen 77 | 78 | ## Story 3 - Animate the shortest path 79 | 80 | As a user 81 | I want to see an animation of the S walking towards the D 82 | Because that'd be cool! 83 | 84 | Accept: Stretch goal! Walk the path :) 85 | -------------------------------------------------------------------------------- /Draughts/readme.md: -------------------------------------------------------------------------------- 1 | # Draughts 2 | 3 | (Adapted from http://www.mastersgames.com/rules/draughts-rules.htm) 4 | 5 | The game of Draughts goes by a variety of different names and has several 6 | different variations. The game given first is English Draughts which is 7 | known as Checkers in North America. Also given is Polish Draughts, which 8 | is played all over Western Europe and which is the most commonly played 9 | version of the game in International competition. 10 | 11 | # The Board 12 | 13 | * English Draughts is played on a standard 8x8 chess board. 14 | 15 | # Objectives 16 | 17 | 18 | The objective of the game is to take all of the opponent's pieces 19 | or 20 | to produce a position such that the opponent is unable to move. 21 | 22 | 23 | # Gameplay 24 | 25 | * Black always plays first. 26 | * A coin is tossed to decide which player will be black. 27 | * Each player's pieces are placed on the 12 black squares nearest to that player. 28 | 29 | * Players take turns to move a piece of their own colour 30 | * Pieces can only move diagonally, and initially only forwards. 31 | 32 | * Any piece that reaches the far edge of the board is `crowned` and is refered to as a `king` 33 | * Kings can move forwards and backwards. 34 | 35 | * If the piece is adjacent to an oponents piece, and there is a space behind it, the oppontents piece can be `captured` 36 | * A player captures a piece by hopping over it into the space behind. 37 | * If a player can `capture` a piece, they must do so. 38 | * If, upon capturing a piece, another piece can be captured, they must also capture any subsequent pieces. 39 | 40 | * If more than one piece can capture, the player chooses. 41 | 42 | # Finishing 43 | 44 | The game is won by the player who first manages to take all his opponent's pieces or 45 | renders them unable to move. 46 | 47 | # Dojo 48 | 49 | Implement draughts! -------------------------------------------------------------------------------- /FloodFill/readme.md: -------------------------------------------------------------------------------- 1 | # Flood Filling 2 | 3 | This dojo was derived from a post in reddit.com/r/dailyprogrammer here: http://www.reddit.com/r/dailyprogrammer/comments/2ug3hx/20150202_challenge_200_easy_floodfill/ 4 | There are a few changes, but this is mostly provided as-is. 5 | 6 | Credit goes to the author and community there. 7 | 8 | --- 9 | 10 | Flood-fill is a tool used in essentially any image editing program that's worth its salt. It allows you to fill in any contigious region of colour with another colour, like flooding a depression in a board with paint. For example, take this beautiful image. If I was to flood-fill the colour orange into this region of the image, then that region would be turned completely orange. 11 | 12 | Today, you're going to implement an algorithm to perform a flood-fill on a text ASCII-style image. 13 | 14 | ### Challenge Input 15 | 16 | You will accept two numbers, w and h, separated by a space. 17 | 18 | * **You will then accept a grid of ASCII characters of size w*h.** 19 | * **You will accept two numbers, x and y, and a character c**. 20 | * `x` and `y` are the co-ordinates on the image where the flood fill should be done, and `c` is the character that will be filled. 21 | 22 | Pixels are defined as contigious (touching) when they share at least one edge (pixels that only touch at corners aren't contigious). 23 | 24 | For example: 25 | 26 | ..................................... 27 | ...#######################........... 28 | ...#.....................#........... 29 | ...#.....................#........... 30 | ...#.....................#........... 31 | ...#.....................#........... 32 | ...#.....................#........... 33 | ...#.....................#######..... 34 | ...###.................##......#..... 35 | ...#..##.............##........#..... 36 | ...#....##.........##..........#..... 37 | ...#......##.....##............#..... 38 | ...#........#####..............#..... 39 | ...#........#..................#..... 40 | ...#.......##..................#..... 41 | ...#.....##....................#..... 42 | ...#...##......................#..... 43 | ...#############################..... 44 | ..................................... 45 | ..................................... 46 | ..................................... 47 | ..................................... 48 | 49 | `8 12 @` 50 | 51 | **Output** 52 | 53 | ..................................... 54 | ...#######################........... 55 | ...#.....................#........... 56 | ...#.....................#........... 57 | ...#.....................#........... 58 | ...#.....................#........... 59 | ...#.....................#........... 60 | ...#.....................#######..... 61 | ...###.................##......#..... 62 | ...#@@##.............##........#..... 63 | ...#@@@@##.........##..........#..... 64 | ...#@@@@@@##.....##............#..... 65 | ...#@@@@@@@@#####..............#..... 66 | ...#@@@@@@@@#..................#..... 67 | ...#@@@@@@@##..................#..... 68 | ...#@@@@@##....................#..... 69 | ...#@@@##......................#..... 70 | ...#############################..... 71 | ..................................... 72 | ..................................... 73 | ..................................... 74 | ..................................... 75 | 76 | # Sample Inputs and Outputs 77 | 78 | **Input** 79 | 80 | ---------------- 81 | -++++++++++++++- 82 | -+------------+- 83 | -++++++++++++-+- 84 | -+------------+- 85 | -+-++++++++++++- 86 | -+------------+- 87 | -++++++++++++-+- 88 | -+------------+- 89 | -+-++++++++++++- 90 | -+------------+- 91 | -++++++++++++++- 92 | -+------------+- 93 | -++++++++++++++- 94 | ---------------- 95 | 96 | `2 2 @` 97 | 98 | **Output** 99 | 100 | ---------------- 101 | -++++++++++++++- 102 | -+@@@@@@@@@@@@+- 103 | -++++++++++++@+- 104 | -+@@@@@@@@@@@@+- 105 | -+@++++++++++++- 106 | -+@@@@@@@@@@@@+- 107 | -++++++++++++@+- 108 | -+@@@@@@@@@@@@+- 109 | -+@++++++++++++- 110 | -+@@@@@@@@@@@@+- 111 | -++++++++++++++- 112 | -+------------+- 113 | -++++++++++++++- 114 | ---------------- 115 | 116 | **Input** 117 | 118 | aaaaaaaaa 119 | aaadefaaa 120 | abcdafgha 121 | abcdafgha 122 | abcdafgha 123 | abcdafgha 124 | aacdafgaa 125 | aaadafaaa 126 | aaaaaaaaa 127 | 128 | `8 3 ,` 129 | 130 | **Output** 131 | 132 | ,,,,,,,,, 133 | ,,,def,,, 134 | ,bcd,fgh, 135 | ,bcd,fgh, 136 | ,bcd,fgh, 137 | ,bcd,fgh, 138 | ,,cd,fg,, 139 | ,,,d,f,,, 140 | ,,,,,,,,, 141 | 142 | 143 | # Extension (Easy/Intermediate) 144 | 145 | Extend your program so that the image 'wraps' around from the bottom to the top, and from the left to the right (and vice versa). This makes it so that the top and bottom, and left and right edges of the image are touching (like the surface map of a torus). 146 | 147 | **Input** 148 | 149 | \/\/\/\.\ 150 | /./..././ 151 | \.\.\.\.\ 152 | /.../.../ 153 | \/\/\/\/\ 154 | /.../.../ 155 | \.\.\.\.\ 156 | /./..././ 157 | \/\/\/\.\ 158 | 159 | `1 7 #` 160 | 161 | **Output** 162 | 163 | \/\/\/\#\ 164 | /#/###/#/ 165 | \#\#\#\#\ 166 | /###/###/ 167 | \/\/\/\/\ 168 | /###/###/ 169 | \#\#\#\#\ 170 | /#/###/#/ 171 | \/\/\/\#\ 172 | -------------------------------------------------------------------------------- /GEDCOM/readme.md: -------------------------------------------------------------------------------- 1 | # Original Description 2 | 3 | This is derived from a quiz posted on rubyquiz.com see: http://rubyquiz.com/quiz6.html 4 | 5 | ## Problem Description 6 | 7 | GEDCOM (http://en.wikipedia.org/wiki/GEDCOM) is the "GEnealogical Data COMmunication" file format. It is a plain-text electronic format used to transfer genealogical data. The purpose of this quiz is to develop a simple parser than can convert a GEDCOM file to an XML file. 8 | 9 | The GEDCOM file format is very straightforward. Each line represents a node in a tree. It looks something like this: 10 | 11 | 0 @I1@ INDI 12 | 1 NAME Jamis Gordon /Buck/ 13 | 2 SURN Buck 14 | 2 GIVN Jamis Gordon 15 | 1 SEX M 16 | 17 | In general, each line is formatted thus: 18 | 19 | LEVEL TAG-OR-ID [DATA] 20 | 21 | 22 | The above sample would be rendered in XML as 23 | 24 | 25 | 26 | 27 | Buck 28 | Jamis Gordon 29 | 30 | M 31 | ... 32 | 33 | ... 34 | 35 | 36 | * "0 @I1@ INDI". This starts a new subtree of type INDI (individual). The id for this individual is "@I1@". 37 | * "1 NAME Jamis Gordon /Buck/". This starts a NAME subtree with a value of "Jamis Gordon /Buck/". 38 | * "2 SURN Buck". This is a subelement of the NAME subtree, of type SURN ("surname"). 39 | * "2 GIVN Jamis Gordon". As SURN, but specifies the given name of the individual. 40 | * "1 SEX M". Creates a new subelement of the INDI element, of type "SEX" (i.e., "gender"). 41 | 42 | This is a simplified version of GEDCOM, the real spec is very broad and features many other elements and relationship types - produce a file format converter that isn't looking for specific tags. 43 | 44 | ### Story 1 - File format conversion 45 | 46 | As a user 47 | When I pass a block of GEDCOM data 48 | I can transcode it to XML 49 | -------------------------------------------------------------------------------- /HumanReadableUrls/readme.md: -------------------------------------------------------------------------------- 1 | # Human Readable Urls 2 | 3 | Url shortening is a common (and often web breaking!) practice - 4 | but sometimes you want your short Urls to be a little more... memorable. 5 | 6 | Gfycat (https://gfycat.com/) popularised "human readable short Urls" 7 | 8 | Let's take a look at one 9 | 10 | https://gfycat.com/SpotlessImpracticalCockatoo 11 | 12 | What LOLS! What Larks! How Memorable! Much Cockatoo! So Wow! 13 | 14 | In this kata, we're going to build our own human readable Url generator. 15 | Be creative with your source data. Make some really memorable Urls. 16 | 17 | We're going to make a program that shortens Urls for us. 18 | 19 | # Story 1 - Generate readable Urls 20 | 21 | As a user 22 | I want to generate a human readable Url 23 | So that people can remember it 24 | 25 | 26 | # Story 2 - Urls must not conflict 27 | 28 | As a user 29 | When I generate a Url 30 | It should not conflict with previously generated Urls 31 | 32 | (Think about running your code in a loop and maintaining state) 33 | 34 | # Story 3 - Urls must not be rude 35 | 36 | As a user 37 | When I generate a Url 38 | It should be funny, but not offensive -------------------------------------------------------------------------------- /ISBNValidator/readme.md: -------------------------------------------------------------------------------- 1 | ISBN Validator 2 | =============== 3 | 4 | This is a reformatted kata from [reddit.com/r/dailyprogrammer](http://www.reddit.com/r/dailyprogrammer/comments/2s7ezp/20150112_challenge_197_easy_isbn_validator/) 5 | 6 | ISBN's (International Standard Book Numbers) are identifiers for books. Given the correct sequence of digits, one book can be identified out of millions of others thanks to this ISBN. 7 | 8 | But when is an ISBN not just a random slurry of digits? That's for you to find out. 9 | 10 | # Rules 11 | 12 | Given the following constraints of the ISBN number, you should write a function that can return True if a number is a valid ISBN and False otherwise. 13 | 14 | An ISBN is a ten digit code which identifies a book. The first nine digits represent the book and the last digit is used to make sure the ISBN is correct. 15 | 16 | To verify an ISBN you: 17 | 18 | * obtain the sum of 10 times the first digit, 9 times the second digit, 8 times the third digit... all the way till you add 1 times the last digit. If the sum leaves no remainder when divided by 11 the code is a valid ISBN. 19 | 20 | For example: 21 | 22 | `0-7475-3269-9` is Valid because: 23 | 24 | (10*0) + (9*7) + (8*4) + (7*7) + (6*5) + (5*3) + (4*2) + (3*6) + (2*9) + (1*9) = 242 25 | 26 | Which can be divided by 11 and have no remainder. 27 | 28 | For the cases where the last digit has to equal to ten, the last digit is written as X. For example `156881111X`. 29 | 30 | --- 31 | 32 | ### Story 1 - Validate a known good ISBN 33 | 34 | As a user 35 | When I provide a valid ISBN 36 | The program returns true 37 | 38 | ### Story 2 - Reject invalid ISBN 39 | 40 | As a user 41 | When I provide a junk ISBN 42 | The program returns false 43 | 44 | ### Story 3 - Generate a valid ISBN 45 | 46 | As a user 47 | I can generate a fresh, valid ISBN 48 | So that I can write a new book! 49 | -------------------------------------------------------------------------------- /InputHandling/readme.md: -------------------------------------------------------------------------------- 1 | # Input Handling 2 | 3 | One of the most common things in software is to accept user input on a command line - however generally the built in mechanism to do so is remarkably low level. 4 | 5 | Todays challenge is to write a high-er level library or class to formalise a few common input patterns. 6 | 7 | The output here is provided for example purposes, but you should carefully consider 8 | the usability, extensibility and syntax of your call. 9 | 10 | The more elegant and idiomatic to your language, with the lease noise, the better. 11 | 12 | # Story 1 - As a user, I am asked to verify my input 13 | 14 | * Given an input value 'input' 15 | * You are prompted to verify the input 16 | 17 | ``` 18 | Enter input: a 19 | Are you sure? Press 'y' to confirm, or any other key to cancel. 20 | ``` 21 | 22 | # Story 2 - As a user, I can enter validated input 23 | 24 | * When asked for a specific `type` of input 25 | * The input is validated 26 | 27 | ``` 28 | Enter a number: 10 29 | 30 | Enter a number: no! 31 | 'no!' is not a valid number. 32 | ``` 33 | 34 | # Story 3 - As a user, I can constrain my input 35 | 36 | * When asked for an input 37 | * Custom rules can be defined 38 | 39 | ``` 40 | Enter a number between 1-10: 6 41 | 42 | ``` 43 | # Story 4 - As a user, I am asked to retry 44 | 45 | * When asked for an input 46 | * And I provide an invalid value 47 | * I am asked to retry. 48 | 49 | ``` 50 | Enter a number between 1-10: 6 51 | 52 | Enter a number between 1-10: 11 53 | '11' is out of range. 54 | Enter a number between 1-10: 55 | 56 | ``` 57 | 58 | # Story 5 - As a user, I can input from a selection 59 | 60 | * When asked for an input 61 | * I am constrained to choices 62 | 63 | ``` 64 | Enter 'dog' or 'cat': dog 65 | Enter 'dog' or 'cat': fish 66 | 'fish' is invalid 67 | Enter 'dog' or 'cat': 68 | ``` 69 | -------------------------------------------------------------------------------- /IoCContainer/readme.md: -------------------------------------------------------------------------------- 1 | # Inversion of Control Containers 2 | 3 | In software engineering, inversion of control (IoC) describes a design in which custom-written portions of a computer program receive the flow of control from a generic, reusable library. A software architecture with this design inverts control as compared to traditional procedural programming: in traditional programming, the custom code that expresses the purpose of the program calls into reusable libraries to take care of generic tasks, but with inversion of control, it is the reusable code that calls into the custom, or task-specific, code. 4 | 5 | Inversion of control is used to increase modularity of the program and make it extensible, and has applications in object-oriented programming and other programming paradigms. The term was popularized by Robert C. Martin and Martin Fowler. The term is related to but different from the dependency inversion principle, which concerns itself with decoupling dependencies between high-level and low-level layers through shared abstractions. 6 | 7 | (Source: Wikipedia) 8 | 9 | --- 10 | ## An example 11 | 12 | From Stackoverflow - http://stackoverflow.com/questions/3058/what-is-inversion-of-control 13 | 14 | The Inversion of Control (IoC) and Dependency Injection (DI) patterns are all about removing dependencies from your code. 15 | 16 | For example, say your application has a text editor component and you want to provide spell checking. Your standard code would look something like this: 17 | 18 | ```csharp 19 | public class TextEditor 20 | { 21 | private SpellChecker _checker; 22 | 23 | public TextEditor() 24 | { 25 | _checker = new SpellChecker(); 26 | } 27 | } 28 | ``` 29 | 30 | What we've done here is create a dependency between the TextEditor and the SpellChecker. In an IoC scenario we would instead do something like this: 31 | 32 | ```csharp 33 | public class TextEditor 34 | { 35 | private ISpellChecker _checker; 36 | 37 | public TextEditor(ISpellChecker checker) 38 | { 39 | _checker = checker; 40 | } 41 | } 42 | ``` 43 | 44 | Now, the client creating the TextEditor class has the control over which SpellChecker implementation to use. We're injecting the TextEditor with the dependency. 45 | 46 | --- 47 | 48 | ## IoC Containers 49 | 50 | IoC containers are tools that help you implement the *dependency inversion principle* - normally acting as some kind of registry for components in your code. 51 | 52 | Generally, containers work in the following way: 53 | 54 | * You register your components with your container 55 | * When you need to construct a class, you ask your container to give you an instance of the class 56 | * Any dependencies are automatically resolved and created for you 57 | * Dependencies are resolved via constructor injection or property injection 58 | 59 | --- 60 | 61 | # Implement a simple IoC container! 62 | 63 | ### Story 1 - Create a class with no constructor parameters 64 | 65 | ``` 66 | As a developer 67 | When I ask my container for an instance of Foo 68 | I get an instance of Foo 69 | ``` 70 | 71 | ### Story 2 - Create a class with constructor parameters 72 | 73 | ``` 74 | As a developer 75 | When I ask my container for an instance of Foo, where Foo depends on Bar 76 | I get an instance of Foo 77 | ``` 78 | 79 | ### Story 3 - Create a class with a dependency on an interface 80 | 81 | ``` 82 | As a developer 83 | When I ask my container for an instance of Foo, where Foo depends on IBar 84 | I get an instance of Foo 85 | ``` 86 | 87 | ### Story 4 - Clashing dependencies 88 | 89 | ``` 90 | As a developer 91 | When I ask my container for an instance of Foo, where Foo depends on IBar 92 | And there are multiple implementations of IBar 93 | I get an error explaining why I couldn't create Foo 94 | ``` 95 | 96 | ### Story 5 - Registrations 97 | 98 | ``` 99 | As a developer 100 | When I ask my container for an instance of Foo, where Foo depends on IBar 101 | I can tell the container which instance of IBar to use 102 | ``` 103 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 David Whitney 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /MarkovChains/readme.md: -------------------------------------------------------------------------------- 1 | # Origin 2 | 3 | Derived from RubyQuiz #74 - http://rubyquiz.com/quiz74.html 4 | 5 | # Markov Chains 6 | 7 | A Markov chain, named after Andrey Markov, is a mathematical system that undergoes transitions from one state to another on a state space. It is a random process usually characterized as memoryless: the next state depends only on the current state and not on the sequence of events that preceded it. Markov chains have many applications as statistical models of real-world processes. 8 | 9 | **Thanks for the science, wikipedia.** 10 | 11 | Markov processes can also be used to generate superficially real-looking text given a sample document: they are used in a variety of recreational "parody generator" programs as well as spammers to inject real-looking hidden paragraphs into unsolicited email and post comments in an attempt to get these messages past spam filters. 12 | 13 | To use Markov Chains, **you read some text document(s), making note of which words commonly follow other words**. Then, when generating text, you **select a word to output, based on the characters or words that came before it**. 14 | 15 | **The number of previous words considered is called the "order" and you can adjust that to try and find a natural feel**. This means that rather than noting the words that follow one specific word, you'll be noting the words that follow a set of words. 16 | 17 | You can find training texts on [Project Gutenberg](http://www.gutenberg.org/) and I've included two sample tests - the famously long "War and Peace" and "Alice's Adventures in Wonderland" in this repository. 18 | 19 | ### Story 1 - A markov chain for a single order 20 | 21 | As a user 22 | When I supply a word 23 | A story is generated 24 | 25 | Accept: Story is ~800 words long. 26 | 27 | ### Story 2 - Human sentences 28 | 29 | As a user 30 | When I supply a word 31 | The output contains sentences punctuated with full stops 32 | 33 | Accept: Full stops placed at average sentence length 34 | Preceeding words influnced by markov chain 35 | 36 | ### Story 3 - Order greater than 1 37 | 38 | As a user 39 | When I supply a word, and an order > 1 40 | A story is generated 41 | 42 | Accept: Story must consider sets of preceeding words 43 | Attempt to make the story "human readable" 44 | 45 | # Example 46 | 47 | Here is some generated text using a second order word chain derived from the Sherlock Holmes novel "The Hound of the Baskervilles" by Arthur Conan Doyle: 48 | 49 | The stars shone cold and bright, while a crushing weight of responsibility 50 | from my shoulders. Suddenly my thoughts with sadness. Then on the lady's 51 | face. "What can I assist you?" 52 | -------------------------------------------------------------------------------- /MarsRover/README.md: -------------------------------------------------------------------------------- 1 | ## Origin 2 | 3 | This kata was originally a Thoughtworks recruitment test that got widely circulated. They don't use it anymore, but it's still a fun puzzle. 4 | 5 | ## Problem Description - Mars Rovers 6 | 7 | A squad of robotic rovers are to be landed by NASA on a plateau on Mars. This plateau, which is curiously rectangular, must be navigated by the rovers so that their on-board cameras can get a complete view of the surrounding terrain to send back to Earth. 8 | 9 | A rover's position and location is represented by a combination of x and y co-ordinates and a letter representing one of the four cardinal compass points. The plateau is divided up into a grid to simplify navigation. 10 | 11 | An example position might be `0, 0, N` 12 | 13 | which means the rover is in the bottom left corner and facing North. 14 | 15 | In order to control a rover, NASA sends a simple string of letters. 16 | 17 | * L - Rotate 90 degrees left 18 | * R - Rotate 90 degrees right 19 | * M - Move forward one grid point 20 | 21 | **Assume that the square directly North from (x, y) is (x, y+1).** 22 | 23 | The first line of input is the upper-right coordinates of the plateau, **the lower-left coordinates are assumed to be 0,0**. 24 | The rest of the input is information pertaining to the rovers that have been deployed. Each rover has two lines of input. 25 | 26 | The input data is in the following form: 27 | 28 | GRIDX GRIDY <-- Grid dimensions 29 | XLoc YLoc Bearing <-- Rover 1 30 | XXXXXXXXXX <-- Instructions 31 | XLoc YLoc Bearing <-- Rover 2 32 | XXXXXXXXXX <-- Instructions 33 | 34 | 35 | ### Input 36 | 37 | 5 5 38 | 1 2 N 39 | LMLMLMLMM 40 | 3 3 E 41 | MMRMMRMRRM 42 | 43 | ### Expected Output 44 | 45 | 1 3 N 46 | 5 1 E 47 | 48 | 49 | Each rover will be finished sequentially, which means that the second rover won't start to move until the first one has finished moving. 50 | 51 | ---- 52 | 53 | ### Story 1 - Generating a grid 54 | 55 | As a user 56 | When I input grid dimensions 57 | The appropriate grid is generated 58 | 59 | Accept: Input is parsed 60 | Grid generated based on input 61 | 62 | 63 | ### Story 2 - Placing a rover 64 | 65 | As a user 66 | When I input a rover location 67 | A rover is placed at the correct grid location 68 | 69 | Accept: Rover must be facing the right direction 70 | 71 | 72 | ### Story 3 - Rotating a rover 73 | 74 | As a parser processing rover instructions 75 | When I encounter an L or R 76 | The rover rotates on the spot 77 | 78 | 79 | ### Story 4 - Moving a rover 80 | 81 | As a parser processing rover instructions 82 | When I encounter an M 83 | I move the rover one location in the direction the rover is facing 84 | -------------------------------------------------------------------------------- /MatchMaking/readme.md: -------------------------------------------------------------------------------- 1 | ## Videogame matchmaking kata 2 | 3 | Matchmaking is a common part of online video games. While reading the changelog for the latest revision of "Halo: The Master Chief Collection" (http://www.polygon.com/2014/12/8/7352941/another-major-update-hits-halo-the-master-chief-collection-for), it became apparent that it's something that can easily go wrong, and has lots of interesting subtleties - and is ripe for the slaying with some traditional TDD. 4 | 5 | #### Matchmaking for games 6 | 7 | Given a pool of players searching for a game, there are a number of factors to consider: 8 | 9 | * The **skill** of the player 10 | * If the game requires a **host player** 11 | * The **latency / ping** of the player 12 | * If the player is **looking for a specific game type** 13 | * If the player is looking for a **team based or free-for-all game** 14 | * If the game type is team based, **correctly balancing the teams** 15 | * If a set of players are already "partied up" and wish to play on the same team 16 | * If the game type is team based, ensuring **partied players are on the same team**, and the opposing team is balanced 17 | 18 | There are a few **common "game types"**, in modern first person shooters 19 | * **Deathmatch** (*free for all*, no teams) 20 | * **Team Deathmatch** (*two teams*) 21 | * **Team objective based games** (*two or more teams*) 22 | 23 | With so many permutations and variables, it's no surprise that matchmaking is something that frequently goes wrong, especially during launch periods of games. 24 | 25 | Calculating the skill of players is a difficult topic, with some of the most dominant research in the field being the Microsoft Research "TrueSkill" ranking system: http://research.microsoft.com/en-us/projects/trueskill/ For the sake of this kata, we'll **descope "player skill calculations" and presume that we have a single number representing player skill**. 26 | 27 | From these factors, emerge *the following requirements*: 28 | 29 | * Each game needs a host 30 | * Each game should be balanced 31 | * Players that look for a specific game-type should only be paired with others seeking the same game-type 32 | * Players who share a screen, should be on the same team 33 | * Players who are partied, should be on the same team 34 | * Players should be ideally paired with people of the same level of latency 35 | * The game should be balanced 36 | * The lower the latency of the host, the better 37 | * Matchmaking should be as quick as possible 38 | 39 | --- 40 | 41 | ## Lets build a matchmaker! 42 | 43 | Given a representation of a pool of players, we want to produce balanced, match-made games. 44 | 45 | "Id", "Can host", "Latency ", "In-Party of Player", "Skill" 46 | 1, 1, 27,, 100 47 | 2, 1, 500,, 90 48 | 3, 0, 200,, 50 49 | 4, 0, 250,6, 100 50 | 5, 0, 600,, 10 51 | 6, 1, 15,, 1 52 | 7, 0, 60,, 99 53 | 8, 0, 27,, 45 54 | 9, 0, 50,, 30 55 | 10, 0, 50,, 67 56 | 11, 1, 2000, 2, 12 57 | 12, 0, 97,,100 58 | 13, 1, 550,, 90 59 | 14, 0, 120,, 50 60 | 15, 0, 60, 6, 100 61 | 16, 0, 4000,, 10 62 | 17, 1, 15,, 1 63 | 18, 0, 80,, 99 64 | 19, 0, 27,, 45 65 | 20, 1, 22,, 30 66 | 21, 0, 500,, 67 67 | 68 | 69 | ## Kata 1 - Matchmaking for a balanced free-for-all deathmatch game 70 | 71 | We have a pool of players all looking to play a balanced, 6 player, free-for-all deathmatch. 72 | 73 | ### Story 1 - Electing Hosts 74 | 75 | As a server 76 | When I have a queue of players waiting for a free for all deathmatch 77 | Then I should elect the most appropriate hosts for those matches 78 | 79 | Accept: 80 | Hosts should be as low-latency as possible 81 | 82 | ### Story 2 - Balancing games 83 | 84 | As a server 85 | When I have a pool of players waiting for a free for all deathmatch 86 | Then players in the game should be of roughly the same skill level 87 | 88 | Accept: 89 | Minimise the standard deviation of skill between players 90 | It's OK to make smaller, more balanced games if enough hosts are available 91 | 92 | 93 | ## Kata 2 - Matchmaking for a team deathmatch 94 | 95 | We have a pool of players all looking to play a balanced, 3v3 player, team deathmatch. 96 | Maximum party size is 3. 97 | In addition to the rules in the first kata, consider these stories. 98 | How does it effect how you matchmake? 99 | 100 | ### Story 1 - Teams must be evenly balanced 101 | 102 | As a server 103 | When I select players 104 | Then the pool of players should be split into balanced teams 105 | 106 | ### Story 2 - Friends play together 107 | 108 | As a server 109 | When I form teams 110 | Then players who are partied together should be on the same team 111 | 112 | ## Final thoughts and clues 113 | 114 | In the real world, you want to optimise for getting players into a game as soon as possible, so it's likely that you would matchmake on intervals, splitting on game types. 115 | 116 | People would join queues for specific game types, and you'd either wait until you had a sufficient set of people to matchmake from, or a certain time window had elapsed, favouring "getting people playing" over perfect balancing. The data provided above would likely represent one "chunk" of players to matchmake. 117 | 118 | Would your solution change "at scale"? 119 | 120 | ## Appendix 121 | 122 | Here's the "matchmaking" portion of the Halo changelog. Some of these issues are just regular bugs, other are matchmaking related. 123 | 124 | * Made improvements to matchmaking team balance 125 | * Made an update to improve matchmaking search times and success rates, specifically expediting the "Players Found" and "Connecting Session" search phases 126 | * Made improvements to prevent a player's rank from resetting unexpectedly 127 | * Made an update to resolve an issue that allowed players to be placed into an incorrect lobby after a matchmaking game 128 | * Made improvements to prevent the party from being disbanded upon returning to lobby 129 | * Made an update to ensure that players are sorted by team in the "Match Found" screen 130 | * Resolved an issue where Team Slayer matches in Halo 3 could separate players onto individual teams 131 | * Resolved an issue where players could be placed into a group of 7 players and unable to find more 132 | * Made improvements to ensure that the party-leader is prompted to "Bring Party" when leaving a lobby 133 | * Made an update to ensure that split-screen players cannot be divided onto different teams 134 | * Made improvements to ensure that clients are not kicked from parties at the end of matchmaking games with a "failed to connect" error 135 | * Made an update to ensure that Halo 2: Anniversary matches do not continue indefinitely after entire opposing team quits 136 | * Made an update to ensure that parties are not separated when the party leader navigates through multiple titles 137 | -------------------------------------------------------------------------------- /MethodAutoCompletion/readme.md: -------------------------------------------------------------------------------- 1 | # Method Auto-Completion 2 | 3 | Based on ideas presented in http://rubyquiz.com/quiz110.html 4 | 5 | # The Problem 6 | 7 | Most modern IDEs implement some form of "auto-completion" of programming syntax. 8 | Auto-completion is when you type a partial member name, and after a short delay, the possible members matched by your text are displayed. 9 | 10 | We want to build a command line application that mimics auto-complete in the language of your choice. 11 | 12 | ###C# Example 13 | 14 | > autocomplete.exe 15 | > Enter Typename: string 16 | > Enter Stub: To 17 | > Possible Members: 18 | > ToString 19 | > ToSomethingElse 20 | 21 | 22 | 23 | [UNFINISHED KATA] 24 | -------------------------------------------------------------------------------- /MorseCode/README.md: -------------------------------------------------------------------------------- 1 | # Original Description 2 | 3 | This is derived from a quiz posted on rubyquiz.com see: http://rubyquiz.com/quiz121.html 4 | 5 | ## Problem Description 6 | 7 | Morse code is a way to encode telegraphic messages in a series of long and short sounds or visual signals. During transmission, pauses are used to group letters and words, but in written form the code can be ambiguous. 8 | 9 | For example, using the typical dot (.) and dash (-) for a written representation of the code, the word ...---..-....- in Morse code could be an encoding of the names Sofia or Eugenia depending on where you break up the letters: 10 | 11 |
12 | ...|---|..-.|..|.-    Sofia
13 | .|..-|--.|.|-.|..|.-  Eugenia
14 | 
15 | 16 | Write program that displays all possible translations for ambiguous words provided in code. 17 | 18 | Your program will be passed a word of Morse code. 19 | Your program should print all possible translations of the code. 20 | 21 | Your code should print gibberish translations in case they have some meaning for the reader, but indicating which translations are in the dictionary could be a nice added feature. 22 | 23 | We will only focus on the alphabet for this quiz to keep things simple. Here are the encodings for each letter: 24 | 25 |
26 | A .-            N -.
27 | B -...          O ---
28 | C -.-.          P .--.
29 | D -..           Q --.-
30 | E .             R .-.
31 | F ..-.          S ...
32 | G --.           T -
33 | H ....          U ..-
34 | I ..            V ...-
35 | J .---          W .--
36 | K -.-           X -..-
37 | L .-..          Y -.--
38 | M --            Z --..
39 | 
40 | 41 | 42 | 43 | ### Story 1 44 | 45 | Parsing a word. 46 | 47 | As a user 48 | When I pass a known word in morse code 49 | The word is returned in English 50 | 51 | ### Story 2 52 | 53 | Parsing a word with multiple options 54 | 55 | As a user 56 | When I pass morse code that could be more than one word 57 | Both word options are returned in English 58 | 59 | ## Clues 60 | 61 | You might need to find a dictionary file form somewhere. Here's one I found: https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt 62 | -------------------------------------------------------------------------------- /MorseCode/Solutions/Dw-C#/Class1.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using System.Linq; 4 | using NUnit.Framework; 5 | 6 | namespace MorseKata 7 | { 8 | [TestFixture] 9 | public class MorseParserTests 10 | { 11 | private MorseParser _parser; 12 | 13 | [SetUp] 14 | public void SetUp() 15 | { 16 | _parser = new MorseParser(); 17 | } 18 | 19 | [TestCase("A", ".-")] 20 | [TestCase("B", "-...")] 21 | [TestCase("C", "-.-.")] 22 | [TestCase("D", "-..")] 23 | [TestCase("E", ".")] 24 | [TestCase("F", "..-.")] 25 | [TestCase("G", "--.")] 26 | [TestCase("H", "....")] 27 | [TestCase("I", "..")] 28 | [TestCase("J", ".---")] 29 | [TestCase("K", "-.-")] 30 | [TestCase("L", ".-..")] 31 | [TestCase("M", "--")] 32 | [TestCase("N", "-.")] 33 | [TestCase("O", "---")] 34 | [TestCase("P", ".--.")] 35 | [TestCase("Q", "--.-")] 36 | [TestCase("R", ".-.")] 37 | [TestCase("S", "...")] 38 | [TestCase("T", "-")] 39 | [TestCase("U", "..-")] 40 | [TestCase("V", "...-")] 41 | [TestCase("W", ".--")] 42 | [TestCase("X", "-..-")] 43 | [TestCase("Y", "-.--")] 44 | [TestCase("Z", "--..")] 45 | public void Parse_WithMorseForSingleLetter_ReturnsA(string expectation, string morse) 46 | { 47 | var letter = _parser.Paser(morse); 48 | 49 | Assert.That(letter[0], Is.EqualTo(expectation)); 50 | } 51 | 52 | [Test] 53 | public void Parse_WithMorseSequenceThatHasTwoWordMatchesReturnsBothMatches() 54 | { 55 | var results = _parser.Paser("...---..-....-"); 56 | 57 | Assert.That(results.Contains("SOFIA")); 58 | Assert.That(results.Contains("EUGENIA")); 59 | 60 | } 61 | } 62 | 63 | public class MorseParser 64 | { 65 | private readonly Dictionary> _wordDic; 66 | private readonly Dictionary _charToMorse; 67 | private readonly Dictionary _morseLookup 68 | = new Dictionary 69 | { 70 | {".-", "A"}, {"-...", "B"}, {"-.-.", "C"}, {"-..", "D"}, {".", "E"}, 71 | {"..-.", "F"}, {"--.", "G"}, {"....", "H"}, {"..", "I"}, {".---", "J"}, 72 | {"-.-", "K"}, {".-..", "L"}, {"--", "M"}, {"-.", "N"}, {"---", "O"}, 73 | {".--.", "P"}, {"--.-", "Q"}, {".-.", "R"}, {"...", "S"}, {"-", "T"}, 74 | {"..-", "U"}, {"...-", "V"}, {".--", "W"}, {"-..-", "X"}, {"-.--", "Y"}, 75 | {"--..", "Z"} 76 | }; 77 | 78 | public MorseParser() 79 | { 80 | _charToMorse = new Dictionary(); 81 | PopulateCharacterToMorseCodeMap(); 82 | _wordDic = BuildMorseCodeToWordListMapping(); 83 | } 84 | 85 | public List Paser(string code) 86 | { 87 | if (_morseLookup.ContainsKey(code)) 88 | { 89 | return new List{_morseLookup[code]}; 90 | } 91 | 92 | return _wordDic[code]; 93 | } 94 | 95 | private void PopulateCharacterToMorseCodeMap() 96 | { 97 | foreach (var item in _morseLookup) 98 | { 99 | _charToMorse.Add(item.Value.ToUpper()[0], item.Key); 100 | } 101 | } 102 | 103 | private Dictionary> BuildMorseCodeToWordListMapping() 104 | { 105 | var wordDic = new Dictionary>(); 106 | var allWords = File.ReadAllLines("words.txt"); 107 | 108 | foreach (var word in allWords.Select(x=>x.ToUpper())) 109 | { 110 | var morse = word.Where(chr => _charToMorse.ContainsKey(chr)) 111 | .Aggregate("", (current, chr) => current + _charToMorse[chr]); 112 | 113 | if (!wordDic.ContainsKey(morse)) 114 | { 115 | wordDic.Add(morse, new List()); 116 | } 117 | 118 | wordDic[morse].Add(word); 119 | } 120 | 121 | return wordDic; 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /ParsingMp3Tags/frederic-chopin-piano-sonata-2-op35-3-funeral-march.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidwhitney/CodeDojos/64107347f8066b845cb7941e3ead782b72de1c21/ParsingMp3Tags/frederic-chopin-piano-sonata-2-op35-3-funeral-march.mp3 -------------------------------------------------------------------------------- /ParsingMp3Tags/readme.md: -------------------------------------------------------------------------------- 1 | # ID3 Tags 2 | 3 | The MP3 file format, didn't provide any means for including metadata about the song. 4 | 5 | **ID3 tags** were invented to solve this problem. 6 | 7 | * You can tell if an MP3 file includes **ID3 tags** by examining the *last 128 bytes* of the file. 8 | * If they begin with the characters TAG, you have found a ID3 tag. 9 | 10 | **Tags are fixed-width fields with no spacing between them.** 11 | 12 | `Song`, `album`, `artist`, and `comment` are **30 bytes each**. 13 | The `year` is four bytes and the `genre` just gets one, which is an index into a list of predefined genres. 14 | 15 | The format of the tag is as follows: 16 | 17 | Field | TAG | song | artist | album | year | comment | genre 18 | Byte Width | 3 | 30 | 30 | 30 | 4 | 30 | 1 19 | ------------------------------------------------------------------ 20 | 128 Bytes 21 | 22 | A minor change was later made to ID3 tags to allow them to include track numbers, creating ID3v1.1. In that format, if the 29th byte of a comment is null and the 30th is not, the 30th byte is an integer representing the track number. 23 | 24 | 25 | This is derived from a quiz posted on rubyquiz.com see: http://rubyquiz.com/quiz136.html 26 | 27 | ## Lets write a parser! 28 | 29 | Scenario 1: 30 | 31 | As a *user* 32 | When I run the program against an MP3 file 33 | Any tag present is identified 34 | 35 | Scenario 2: 36 | 37 | As a *user* 38 | When an ID3 tag is detected 39 | Tag data is output to the screen 40 | 41 | Accept: 42 | When no tag found "No tag found" outputted 43 | 44 | Scenario 3: 45 | 46 | As a *user* 47 | When an ID3 tag has a track number 48 | The track number is correctly outputted 49 | 50 | ## Test Data 51 | 52 | The file `frederic-chopin-piano-sonata-2-op35-3-funeral-march.mp3` is included in this repository - sourced from the collection at [mfiles](http://www.mfiles.co.uk/mp3-files.htm) 53 | 54 | If you open this file up in a hex editor (tip: you can rename the file to .bin and Visual Studio will happily open it) and the last 128 bytes of the file look like this 55 | 56 | TAGFuneral March (Sonata Op.35)Frederic Chopinwww.mfiles.co.uk© Music Files Ltd 57 | 58 | This is an ID3V1 tag, with no track information. 59 | 60 | ## Genre list 61 | 62 | The official ID3v1 genre list is this, and it's zero-indexed (i.e. Blues is 0, Classic Rock is 1...) 63 | 64 | Blues 65 | Classic Rock 66 | Country 67 | Dance 68 | Disco 69 | Funk 70 | Grunge 71 | Hip-Hop 72 | Jazz 73 | Metal 74 | New Age 75 | Oldies 76 | Other 77 | Pop 78 | R&B 79 | Rap 80 | Reggae 81 | Rock 82 | Techno 83 | Industrial 84 | Alternative 85 | Ska 86 | Death Metal 87 | Pranks 88 | Soundtrack 89 | Euro-Techno 90 | Ambient 91 | Trip-Hop 92 | Vocal 93 | Jazz+Funk 94 | Fusion 95 | Trance 96 | Classical 97 | Instrumental 98 | Acid 99 | House 100 | Game 101 | Sound Clip 102 | Gospel 103 | Noise 104 | AlternRock 105 | Bass 106 | Soul 107 | Punk 108 | Space 109 | Meditative 110 | Instrumental Pop 111 | Instrumental Rock 112 | Ethnic 113 | Gothic 114 | Darkwave 115 | Techno-Industrial 116 | Electronic 117 | Pop-Folk 118 | Eurodance 119 | Dream 120 | Southern Rock 121 | Comedy 122 | Cult 123 | Gangsta 124 | Top 40 125 | Christian Rap 126 | Pop/Funk 127 | Jungle 128 | Native American 129 | Cabaret 130 | New Wave 131 | Psychadelic 132 | Rave 133 | Showtunes 134 | Trailer 135 | Lo-Fi 136 | Tribal 137 | Acid Punk 138 | Acid Jazz 139 | Polka 140 | Retro 141 | Musical 142 | Rock & Roll 143 | Hard Rock 144 | Folk 145 | Folk-Rock 146 | National Folk 147 | Swing 148 | Fast Fusion 149 | Bebob 150 | Latin 151 | Revival 152 | Celtic 153 | Bluegrass 154 | Avantgarde 155 | Gothic Rock 156 | Progressive Rock 157 | Psychedelic Rock 158 | Symphonic Rock 159 | Slow Rock 160 | Big Band 161 | Chorus 162 | Easy Listening 163 | Acoustic 164 | Humour 165 | Speech 166 | Chanson 167 | Opera 168 | Chamber Music 169 | Sonata 170 | Symphony 171 | Booty Bass 172 | Primus 173 | Porn Groove 174 | Satire 175 | Slow Jam 176 | Club 177 | Tango 178 | Samba 179 | Folklore 180 | Ballad 181 | Power Ballad 182 | Rhythmic Soul 183 | Freestyle 184 | Duet 185 | Punk Rock 186 | Drum Solo 187 | A capella 188 | Euro-House 189 | Dance Hall 190 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CodeDojos 2 | ========= 3 | 4 | Code dojos 5 | -------------------------------------------------------------------------------- /Retrying/readme.md: -------------------------------------------------------------------------------- 1 | # Retrying 2 | 3 | In modern web programming, we're frequently faced with connectivity issues as we depend on many components that we can't control. 4 | 5 | In this kata, we're going to build some code to implement backed-off-retrys. 6 | 7 | Pay close attention to the API you're designing - this code should be re-usable in multiple places in your codebase. 8 | 9 | --- 10 | 11 | ## Story 1 - A basic HTTP request 12 | 13 | As a programmer 14 | I can load {url} over HTTP 15 | And it works 16 | 17 | 18 | ## Story 2 - A failed HTTP request 19 | 20 | As a programmer 21 | When a HTTP request to {url} fails 22 | It is retried 5 seconds later 23 | 24 | ## Story 3 - Backing off 25 | 26 | As a programmer 27 | When a HTTP request to {url} fails more than once 28 | The retry delay is increased for each failure 29 | 30 | Accept: 31 | Each retry delay is double the last 32 | Maximum number of retries is 10 33 | 34 | ## Story 4 - Retry filtering 35 | 36 | As a programmer 37 | When a HTTP request fails due to an expected condition 38 | It is not retried, exception is thrown 39 | 40 | Accept: 41 | Status 404 Not Found immediately throws it's exception 42 | "Expected failing condition" could be anything 43 | 44 | 45 | ## Story 5 - Configuration per-code-block 46 | 47 | As a programmer 48 | I want to be able to configure retry delays per block of code 49 | So I can easily deal with different use cases. 50 | -------------------------------------------------------------------------------- /RomanNumerals/readme.md: -------------------------------------------------------------------------------- 1 | # Roman Numerals 2 | 3 | The Romans were a clever bunch. 4 | 5 | They conquered most of Europe and ruled it for hundreds of years. They invented concrete and straight roads and even bikinis. 6 | 7 | One thing they never discovered though was the number zero. This made writing and dating extensive histories of their exploits slightly more challenging, but the system of numbers they came up with is still in use today. 8 | 9 | The Romans wrote numbers using letters: 10 | 11 | I = 1 12 | V = 5 13 | X = 10 14 | L = 50 15 | C = 100 16 | D = 500 17 | M = 1000 18 | 19 | You can combine letters to add values, by listing them largest to smallest from left to right: 20 | 21 | II = 2 22 | VIII = 8 23 | XXXI = 31 24 | 25 | However, you may only list three consecutive identical letters. A single lower value may proceed a larger value, to indicate subtraction. 26 | 27 | This rule is only used to build values not reachable by the previous rules: 28 | 29 | IV = 4 30 | CM = 900 31 | 32 | But 15 is XV, not XVX. 33 | 34 | ## Further Hints 35 | 36 | Modern Roman numerals are written by expressing each digit separately starting with the left most digit and skipping any digit with a value of zero. 37 | 38 | ## Examples 39 | 40 | **1990**: 1000=M, 900=CM, 90=XC; MCMXC. 41 | 42 | **2008**: 2000=MM, 8=VIII; MMVIII. 43 | 44 | ## Task 45 | 46 | Write a program that converts numbers to numerals. -------------------------------------------------------------------------------- /SassBasics/readme.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | The SASS CSS pre-processor is a popular way of rationalising the crazy of hand coded CSS for front end developers. 4 | 5 | For this kata, we're going to build the start of a CSS pre-processor, paying attention to how our code is factored for extensibility and maintainability. Be mindful that we'll not be building out a complete pre-processor, so presume your code should be extensible. 6 | 7 | Your program would run in the following form: 8 | 9 | > sass2css.exe my-sass-file.scss 10 | > sass2css.exe c:\some\file\path 11 | 12 | And would ouptut 13 | 14 | > my-sass-file.css generated 15 | > path.css generated 16 | 17 | The first execution would transform a single file, the second, an entire directory. 18 | 19 | We're going to be implementing the SASS basics from http://sass-lang.com/guide 20 | 21 | 22 | # Story 1 - Implement support for variables in scss files! 23 | 24 | As a developer
25 | When I use the variable syntax to declare a variable
26 | All usages of that variable are pre-processed 27 | 28 | Accept 29 | * Variables can be defined 30 | * Variables replaced in CSS block 31 | * Variables can be a portion of the outputted CSS 32 | * Whitespace characters are allowed between key / value of variable 33 | * Variable declaration terminated with ; 34 | 35 | Example: 36 | 37 | $font-stack: Helvetica, sans-serif; 38 | $primary-color: #333; 39 | 40 | body { 41 | font: 100% $font-stack; 42 | color: $primary-color; 43 | } 44 | 45 | Output: 46 | 47 | body { 48 | font: 100% Helvetica, sans-serif; 49 | color: #333; 50 | } 51 | 52 |
53 | 54 | # Story 2 - Partials 55 | 56 | As a developer
57 | When I try and process an .scss file starting with an underscore
58 | Nothing is output 59 | 60 | Accept: 61 | * Files of the form _something.scss do not get converted to _something.css 62 | 63 |
64 | 65 | # Story 3 - Imports 66 | 67 | As a developer
68 | I want to be able to import another file into my CSS file 69 | So I can re-use code 70 | 71 | Accept: Import statements replaced with contents of imported file. 72 | Relative import paths supported 73 | 74 | Example: 75 | 76 | /* reset.scss */ 77 | .class hi { 78 | color: red; 79 | } 80 | 81 | /* import-test.scss */ 82 | @import 'reset'; 83 | 84 | body { 85 | font: 100% Helvetica, sans-serif; 86 | background-color: #efefef; 87 | } 88 | 89 | Output: 90 | 91 | .class hi { 92 | color: red; 93 | } 94 | 95 | body { 96 | font: 100% Helvetica, sans-serif; 97 | background-color: #efefef; 98 | } 99 | -------------------------------------------------------------------------------- /SecretSanta/README.md: -------------------------------------------------------------------------------- 1 | # Original Description 2 | 3 | This is derived from a quiz posted on rubyquiz.com see: http://rubyquiz.com/quiz2.html 4 | 5 | ## Problem Description 6 | 7 | Secret Santa is a game played by friends around the world to add a little mystery into seasonal gift giving. 8 | 9 | To play secret santa: 10 | * All the participants names are placed in a hat 11 | * Names are drawn and allocated to other players 12 | * Gifts are bought and shared anonymously 13 | 14 | Obviously, the problem with a random hat draw is you can get yourself - so lets solve this problem with software! 15 | 16 | Here are some sample names: 17 | 18 |
19 |   Luke Skywalker   [luke@theforce.net]
20 |   Leia Skywalker   [leia@therebellion.org]
21 |   Toula Portokalos [toula@manhunter.org]
22 |   Gus Portokalos   [gus@weareallfruit.net]
23 |   Bruce Wayne      [bruce@imbatman.com]
24 |   Virgil Brigman   [virgil@rigworkersunion.org]
25 |   Lindsey Brigman  [lindsey@iseealiens.net]
26 | 
27 | 28 | ### Story 1 29 | 30 | Allocating secret santas 31 | 32 | As a user 33 | When I pass a list of names in a file 34 | Secret santas are allocated 35 | 36 | ### Story 2 37 | 38 | Families must be split up 39 | 40 | As a user 41 | When I allocate secret santas 42 | Santas are not paired when they are related 43 | 44 | ### Story 3 (Stretch goal) 45 | 46 | Email the santas 47 | 48 | As a user 49 | When I allocate secret santas 50 | The santas are emailed, so nobody can cheat 51 | -------------------------------------------------------------------------------- /Tetris/readme.md: -------------------------------------------------------------------------------- 1 | # Simple Tetris Clone 2 | 3 | Tetris (Russian: Те́трис, pronounced [ˈtɛtrʲɪs]) is a tile-matching puzzle video game, 4 | originally designed and programmed by Russian game designer Alexey Pajitnov. 5 | 6 | It was released on June 6, 1984, while he was working for the Dorodnicyn Computing 7 | Centre of the Academy of Science of the USSR in Moscow. 8 | 9 | He derived its name from the Greek numerical prefix tetra- 10 | (all of the game's pieces contain four segments) and tennis, Pajitnov's favorite sport. 11 | 12 | # Rules 13 | 14 | We're going to implement a cut down Tetris clone, following a reduced set of the Tetris Guidelines 15 | (the currentor specification that The Tetris Company enforces for making all new 16 | Tetris game products alike in form). 17 | 18 | Lovingly abridged from http://tetris.wikia.com/wiki/Tetris_Guideline 19 | 20 | ## Playfield 21 | 22 | * Playfield is 10 cells wide and at least 22 cells tall. 23 | * Rows above 20 are hidden or obstructed by the field frame 24 | 25 | ## Tetrominos 26 | 27 | All tetrominoes exist inside a bounding square and rotate about the center of this square 28 | unless obstructed. 29 | 30 | Tetrominoes of width 3 (J, L, S, T, Z) are placed in the top two rows of the bounding square 31 | and (for J, L, and T) with the flat side down. I is placed in the top middle row. 32 | 33 | Ref: http://tetris.wikia.com/wiki/Tetromino 34 | 35 | * Cyan I 36 | * Yellow O 37 | * Purple T 38 | * Green S 39 | * Red Z 40 | * Blue J 41 | * Orange L 42 | 43 | All possible rotation states, rotating around the bounding box: 44 | 45 | ![alt text](srs.png "All possibly rotations") 46 | 47 | ## Start Locations 48 | 49 | * The I and O spawn in the middle columns 50 | * The rest spawn in the left-middle columns 51 | * The tetrominoes spawn horizontally and with their flat side pointed down 52 | 53 | ## Gameplay 54 | 55 | * A Random block is drawn 56 | * It is placed in the top two lines of the grid 57 | * It `ticks` downwards as gravity is applied 58 | * The user may move the piece left and right with their arrow keys 59 | * The player may left and right `rotate` the pieces if they fit 60 | * A block may not move into a space occupied by a previous block 61 | * If gravity `ticks` when a block is obstructed, it sticks in place. 62 | * Blocks spawn until the player is defeated. 63 | * When a `tick` occures, any completed horizontal lines are cleared 64 | * If a line is cleared, all contents shift downwards. 65 | * Clearing and shifting occurrs until there is nothing left to clear 66 | 67 | ## Defeat 68 | 69 | The player `tops out` when: 70 | 71 | * A piece is spawned overlapping at least one block, 72 | * A piece locks completely above the visible portion of the playfield 73 | 74 | 75 | # Approach and Hints 76 | 77 | There are lots of discrete pieces that all join together to make "a tetris". 78 | 79 | Think about discrete: 80 | 81 | * Random generators 82 | * Lists of blocks 83 | * Block rotation in isolation of the game. 84 | * The game loop (`ticks`) 85 | * Collision detection with other blocks 86 | * Input distinct from the game 87 | 88 | 89 | # Randomiser Specification 90 | 91 | The Random Generator generates a sequence of all seven one-sided tetrominoes 92 | (I, J, L, O, S, T, Z) permuted randomly, as if they were drawn from a bag. 93 | 94 | It deals all seven tetrominoes to the piece sequence before generating another bag. 95 | 96 | It can produce a maximum of 12 tetrominoes between one I and the next I, 97 | and a run of S and Z tetrominoes is limited to a maximum of 4. -------------------------------------------------------------------------------- /Tetris/srs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidwhitney/CodeDojos/64107347f8066b845cb7941e3ead782b72de1c21/Tetris/srs.png -------------------------------------------------------------------------------- /TextImages/Ducky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidwhitney/CodeDojos/64107347f8066b845cb7941e3ead782b72de1c21/TextImages/Ducky.png -------------------------------------------------------------------------------- /TextImages/readme.md: -------------------------------------------------------------------------------- 1 | # Text Image Previews 2 | 3 | We're going to write a program that renders images as ASCII art into the console. 4 | 5 | Your program will need to read in an image, in whatever format you want to support, and respond with a text representation of the image that fits in the terminal. 6 | 7 | For example, given the following .PNG [image of a duck](Ducky.png) 8 | 9 | 10 | 11 | Your program might output something like 12 | 13 | 14 | ........--**####**::::::::::::........ 15 | ......--##oooooo\\**::::::::.......... 16 | ......**oo==oooo\\\\::::.............. 17 | ....--\\oooooooo\\$$**::.............. 18 | ....**&&$$oooo\\$$$$%%................ 19 | ....**\\oooo\\<<<<$$##................ 20 | ....!!<<<<<<<<<<\\\\##..........:::::: 21 | ....::%%<<<<<<<<\\$$^^....::**++**.... 22 | ....^^%%<<<<<<<<$$$$##**""==++++==**** 23 | ....**oo<<<<<<$$<<<<\\oo==++++++=="""" 24 | ..!!==oo<<<<<<<<$$$$oo====++++==oo#### 25 | ^^====oo\\<<$$\\oooooo==++======oo**** 26 | **++++====oooo====++++======oooo\\^^^^ 27 | ++====++++========++======oooooo**.... 28 | ""====++++==========oooooooooo##--.... 29 | ""==================oooooooooo^^...... 30 | !!oo==oo======oooooooooo\\##^^::...... 31 | ..""oooooooooooooooo\\oo""^^.......... 32 | ..::**====oooooooooo==**::............ 33 | ....::^^**""""""""!!..--::............ 34 | ....::^^**""""""""!!..--::............ 35 | 36 | 37 | The characters your choose for your ASCII art are down to you. 38 | 39 | This is derived from a quiz posted on rubyquiz.com see: http://rubyquiz.com/quiz50.html 40 | 41 | # Hints 42 | 43 | * Think greyscale 44 | * Perhaps reduce the size of the image? 45 | * There are built in image manipulation classes in .NET - GDI+ ones in System.Drawing, WPF ones in System.Windows.Media.Imaging (BitmapFrame) 46 | * There's a package called ImageResizer.NET that's slow, but works. 47 | * Can you reduce the concept of a colour to a single number? 48 | -------------------------------------------------------------------------------- /Throttling/readme.md: -------------------------------------------------------------------------------- 1 | Throttling 2 | ========== 3 | 4 | Throttling is a cloud design pattern that exists to mitigate against floods of traffic to your websites or services. 5 | There's a good outline of the pattern here - https://msdn.microsoft.com/en-gb/library/dn589798.aspx : 6 | 7 | "The load on a cloud application typically varies over time based on the number of active users or the types of activities they are performing. 8 | 9 | For example, more users are likely to be active during business hours, or the system may be required to perform computationally expensive analytics at the end of each month. There may also be sudden and unanticipated bursts in activity. 10 | 11 | If the processing requirements of the system exceed the capacity of the resources that are available, it will suffer from poor performance and may even fail. The system may be obliged to meet an agreed level of service, and such failure could be unacceptable. 12 | 13 | There are many strategies available for handling varying load in the cloud, depending on the business goals for the application. One strategy is to use autoscaling to match the provisioned resources to the user needs at any given time. This has the potential to consistently meet user demand, while optimizing running costs. 14 | 15 | However, while autoscaling may trigger the provisioning of additional resources, this provisioning is not instantaneous. If demand grows quickly, there may be a window of time where there is a resource deficit." 16 | 17 | 18 | ## Task 19 | 20 | We're going to write some code that'll allow us to throttle calls to ANY method or code block, according to a specific threshold, within a specific time window. 21 | 22 | 23 | ## Stories 24 | 25 | ### Throttling calls 26 | 27 | As a dev 28 | When I use my wrapper class or function to call a codeblock 29 | Only one single call is executed in a 5 second window 30 | 31 | Accept: Other calls rejected / throw 32 | 33 | ### Queuing throttled calls 34 | 35 | As a dev 36 | When I use my wrapper class or function to call a codeblock 37 | Any calls that would be throttled are executed after the throttle window elapses 38 | 39 | Accept: Calling code should know if execution is deferred 40 | Hint: Async / Await? 41 | 42 | ### Configuring throttling durations 43 | 44 | As a dev 45 | When I make a throttle-able call 46 | I can configure the throttling window in an idiomatic way 47 | -------------------------------------------------------------------------------- /WordChains/readme.md: -------------------------------------------------------------------------------- 1 | # Origin 2 | 3 | This kata is reformatted from http://codekata.com/kata/kata19-word-chains/ 4 | 5 | # Word Chains 6 | 7 | There's a type of puzzle where the challenge is to build a chain of words, starting with one particular word and ending with another. 8 | 9 | Successive entries in the chain must all be real words, and each can differ from the previous word by just one letter. For example, you can get from “cat” to “dog” using the following chain. 10 | 11 | cat 12 | cot 13 | cog 14 | dog 15 | 16 | The objective of this kata is to write a program that accepts start and end words and, using words from the dictionary, builds a word chain between them. 17 | 18 | # Story 1 - A simple chain 19 | 20 | As a user 21 | When I input two words 22 | A word chain is generated and output 23 | 24 | # Story 2 - Return the shortest chain 25 | 26 | As a user 27 | When I input two words 28 | The shortest possible chain is generated and output 29 | -------------------------------------------------------------------------------- /WordSearchSolver/readme.md: -------------------------------------------------------------------------------- 1 | # Word Search Solver 2 | 3 | (Adapted from http://rubyquiz.com/quiz107.html by Daniel Finnie) 4 | 5 | A word search, word find, word seek, word sleuth or mystery word puzzle is a word game that consists of the letters of words placed in a grid, which usually has a rectangular or square shape. The objective of this puzzle is to find and mark all the words hidden inside the box. The words may be placed horizontally, vertically, or diagonally. Often a list of the hidden words is provided, but more challenging puzzles may let the player figure them out. Many word search puzzles have a theme to which all the hidden words are related. The puzzles have, like crosswords and arrowords, been very popular in the United Kingdom, and - also in common with these latter puzzles - have had complete magazines devoted to them. 6 | 7 | Word searches are commonly found in daily newspapers and puzzle books. Some teachers use them as educational tools for children, the benefit being that young minds can learn new words and their spellings by intensively searching for them, letter by letter, in the puzzle. 8 | 9 | # The Kata 10 | 11 | Write a program to find all the words in a Word Search, entered in plain text. 12 | 13 | # Puzzle 14 | 15 | Input: 16 | 17 | U E W R T R B H C D 18 | C X G Z U W R Y E R 19 | R O C K S B A U C U 20 | S F K F M T Y S G E 21 | Y S O O U N M Z I M 22 | T C G P R T I D A N 23 | H Z G H Q G W T U V 24 | H Q M N D X Z B S T 25 | N T C L A T N B C E 26 | Y B U R P Z U X M S 27 | 28 | Contains: RUBY, DAN, ROCKS, MATZ 29 | 30 | Expected output: 31 | 32 | + + + R + + + + + + 33 | + + + + U + + + + + 34 | R O C K S B + + + + 35 | + + + + + + Y + + + 36 | + + + + + + + + + M 37 | + + + + + + + D A N 38 | + + + + + + + T + + 39 | + + + + + + Z + + + 40 | + + + + + + + + + + 41 | Y B U R + + + + + + 42 | 43 | 44 | # Stretch Goal 45 | 46 | Too easy? How about generating a puzzle. 47 | 48 | Input: 49 | 50 | Words: THIS, PUZZLE, ROCKS, SOCKS 51 | 52 | OUTPUT: 53 | 54 | Puzzle in the above form. 55 | 56 | Accept: 57 | 58 | - Words must be placed forwards 59 | - Words must be placed in reverse 60 | - Words must be placed in forwards diagonals 61 | - Words must be placed in backwards diagonals 62 | - Words may overlap 63 | 64 | 65 | # Notes on Strategies 66 | 67 | (Thanks Wikipedia! https://en.wikipedia.org/wiki/Word_search) 68 | 69 | A common strategy for finding all the words is to go through the puzzle left to right (or vice versa) and look for the first letter of the word (if a word list is provided). After finding the letter, one should look at the eight surrounding letters to see whether the next letter of the word is there. One can then continue this method until the entire word is found. 70 | 71 | Another strategy is to look for 'outstanding' letters within the word one is searching for (if a word list is provided). Since most word searches use capital letters, it is easiest to spot the letters that stand out from others. These letters are Q, O, U, X, and Z.[citation needed] 72 | 73 | Lastly, the strategy of looking for double letters in the word being searched for (if a word list is provided) proves helpful, because it is easier to spot two identical side-by-side letters among a large grid of random letters. 74 | 75 | If a word list is not provided, a way to find words is to go row by row. First, all the horizontal rows should be read both backwards and forwards, then the vertical, and so on. 76 | 77 | Sometimes the puzzle itself will help. The puzzles generated by a computer tend to put words in patterns. Furthermore, the bigger the words and the more words, the easier they are to spot. In some computer-generated puzzles, if the person solving the puzzle sees one word, all they have to do to find more is to look in adjacent rows, columns, or diagonals. The puzzle might use every row, column, or diagonal—or just every other row, column, or diagonal. --------------------------------------------------------------------------------