tddkatas Wiki Rss Feedhttp://tddkatas.codeplex.com/tddkatas Wiki Rss DescriptionUpdated Wiki: Documentationhttps://tddkatas.codeplex.com/documentation?version=4<div class="wikidoc"><b>What is TDD-Katas?</b><br /><i>Refer to </i> : <a href="http://social.technet.microsoft.com/wiki/contents/articles/30940.learning-test-driven-development-with-tdd-katas.aspx">http://social.technet.microsoft.com/wiki/contents/articles/30940.learning-test-driven-development-with-tdd-katas.aspx</a><br /><br /><br />
<h1>TDD-Katas : <b>Get More from : </b> - <a href="https://github.com/garora/TDD-Katas">https://github.com/garora/TDD-Katas</a></h1>
<h2>String Calculator</h2>
- Create a simple String calculator with a method int Add(string numbers)<br /> - The method can take 0, 1 or 2 numbers, and will return their sum (for an empty string it will<br /> return 0) for example �� or �1� or �1,2�<br /> - Start with the simplest test case of an empty string and move to 1 and two numbers<br /> - Remember to solve things as simply as possible so that you force yourself to write tests you did<br /> not think about<br /> - Remember to refactor after each passing test<br /> - Allow the Add method to handle an unknown amount of numbers<br /> - Allow the Add method to handle new lines between numbers (instead of commas).<br /> - the following input is ok: �1\n2,3� (will equal 6)<br /> - the following input is NOT ok: �1,\n� (not need to prove it - just clarifying)<br /> - Support different delimiters<br /> to change a delimiter, the beginning of the string will contain a separate line that looks like this: <br /> �//<a href="https://tddkatas.codeplex.com/wikipage?title=delimiter&referringTitle=Documentation">delimiter</a>\n<a href="https://tddkatas.codeplex.com/wikipage?title=numbers%ef%bf%bd&referringTitle=Documentation">numbers�</a>� for example �//;\n1;2� should return three where the default delimiter is �;� .<br /> the first line is optional. all existing scenarios should still be supported<br /> - Calling Add with a negative number will throw an exception �negatives not allowed� - and the negative that was passed.<br /> if there are multiple negatives, show all of them in the exception message <br />
<hr />------------------------------------------------------------<br /> Completed first Kata example
<hr />------------------------------------------------------------<br />
<h2>The Bowling Game Kata</h2>
- Following Uncle bob post from here : http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata<br /> - Create a new project or start in the existing project by adding Game.cs and TestGame.cs<br /> - Create two public methods methods <a href="https://tddkatas.codeplex.com/wikipage?title=refer%20to%20the%20presentation%20file&referringTitle=Documentation">refer to the presentation file</a><br /> - Create Test Methods for the above Methods<br /> - This is called a 'RED' Test as it is going to fail.<br /> - Rectified both test and class methods<br /> - Write new test<br /> - This is called a 'Green' Test as it is going to pass.<br /> - Rectified TestMethods to meet total 20 frames hit.<br /> - Rectified test to accept multiple frame and pins<br /> - Test 3 is a 'Red' test<br /> - Test 4 and 5 are 'Green'<br /> - All test passed<br /> - Still there is scope of refactoring<br />
<h2>The FizzBuzz Kata</h2>
- Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" <br /> instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both <br /> three and five print "FizzBuzz".<br />
<h3>Steps:</h3>
Lets divide this into different steps so, we can easily write and test this.<br /> - Print numbers from 1 to 100<br /> - Print "Fizz" instead of number which is divisible by 3<br /> - Print "Buzz" instead of number which is divisible by 5<br /> - Print "FizzBuzz" instead of number which is divisible by both 3 and 5<br />
<h4>Make more test for accept numbers and provide results</h4>
- Create a method to accept single number<br /> - Create test to verify supplied number within the range 1 to 100<br /> - Create test to verify number and return result Fizz or Buzz or FizzBuzz per above criteria<br />
<h2>The OddEven Kata</h2>
- Write a program that prints numbers within specified range lets say 1 to 100. If number is odd print 'Odd'<br /> instead of the number. If number is even print 'Even' instead of number. Else print number <a href="https://tddkatas.codeplex.com/wikipage?title=hint%20-%20if%20number%20is%20Prime&referringTitle=Documentation">hint - if number is Prime</a>.<br />
<h3>Steps :</h3>
Lets divide into following stesp:<br /> - Prints numbers from 1 to 100<br /> - Print "Even" instead of number, if the number is even, means divisible by 2<br /> - Print "Odd" instead of number, if the number is odd, means not divisible by 2 but not divisible by itself too<br /> - Print number, if it does not meet above two conditions, means if number is Prime<br /> - Make method to accept any number of range <a href="https://tddkatas.codeplex.com/wikipage?title=currently%20%20we%20have%201%20to%20100&referringTitle=Documentation">currently we have 1 to 100</a><br /> - Create a new method to check Odd/Even/Prime of a single supplied method<br />
<h2>The PrimeFactor Kata</h2>
An awesome Kata from Uncle BoB <a href="http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata">http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata</a><br />
<hr />---------------<br />
<h2>Kata - coming next <a href="https://tddkatas.codeplex.com/wikipage?title=source%20url%3ahttp%3a%2f%2fwww.cyber-dojo.com%2f&referringTitle=Documentation">source url:http://www.cyber-dojo.com/</a></h2>
<h3>Calc Stats:</h3>
Your task is to process a sequence of integer numbers<br /> to determine the following statistics:<br /><br /> o) minimum value<br /> o) maximum value<br /> o) number of elements in the sequence<br /> o) average value<br /><br /> For example: <a href="https://tddkatas.codeplex.com/wikipage?title=6%2c%209%2c%2015%2c%20-2%2c%2092%2c%2011&referringTitle=Documentation">6, 9, 15, -2, 92, 11</a><br /><br /> o) minimum value = -2<br /> o) maximum value = 92<br /> o) number of elements in the sequence = 6<br /> o) average value = 18.166666<br />
<h3>Diversion :</h3>
Think of binary numbers: sequences of 0's and 1's. How many <br /> n-digit binary numbers are there that don't have two adjacent<br /> 1 bits? <br /><br /> For example, for three-digit numbers, Five of the possible<br /> eight combinations meet the criteria: <br /><br /> 000, 001, 010, 011, 100, 101, 110, 111. <br /><br /> What is the number for sequences of length 4, 5, 10, n?<br /><br /> Having worked out the pattern, there's a second part to the <br /> question: can you prove why that relationship exists? <br />
<h3>Game of Life :</h3>
Your task is to write a program to calculate the next<br /> generation of Conway's game of life, given any starting<br /> position. You start with a two dimensional grid of cells, <br /> where each cell is either alive or dead. The grid is finite, <br /> and no life can exist off the edges. When calculating the <br /> next generation of the grid, follow these four rules:<br /><br /> 1. Any live cell with fewer than two live neighbours dies, <br /> as if caused by underpopulation.<br /> 2. Any live cell with more than three live neighbours dies, <br /> as if by overcrowding.<br /> 3. Any live cell with two or three live neighbours lives <br /> on to the next generation.<br /> 4. Any dead cell with exactly three live neighbours becomes <br /> a live cell.<br /><br /> Examples: * indicates live cell, . indicates dead cell<br /><br /> Example input: (4 x 8 grid)<br /> 4 8<br /> ........<br /> ....*...<br /> ...<b></b>...<br /> ........<br /><br /> Example output:<br /> 4 8<br /> ........<br /> ...<b></b>...<br /> ...<b></b>...<br /> ........<br />
<h3>Harry Potter :</h3>
To try and encourage more sales of the 5 different Harry<br /> Potter books they sell, a bookshop has decided to offer <br /> discounts of multiple-book purchases. <br /><br /> One copy of any of the five books costs 8 EUR. <br /><br /> If, however, you buy two different books, you get a 5% <br /> discount on those two books.<br /><br /> If you buy 3 different books, you get a 10% discount. <br /><br /> If you buy 4 different books, you get a 20% discount.<br /><br /> If you go the whole hog, and buy all 5, you get a huge 25%<br /> discount. <br /><br /> Note that if you buy, say, four books, of which 3 are <br /> different titles, you get a 10% discount on the 3 that <br /> form part of a set, but the fourth book still costs 8 EUR. <br /><br /> Your mission is to write a piece of code to calculate the <br /> price of any conceivable shopping basket (containing only <br /> Harry Potter books), giving as big a discount as possible.<br /><br /> For example, how much does this basket of books cost?<br /><br /> 2 copies of the first book<br /> 2 copies of the second book<br /> 2 copies of the third book<br /> 1 copy of the fourth book<br /> 1 copy of the fifth book<br /><br /> Answer: 51.20 EUR<br />
<h3>LCD Digits :</h3>
Your task is to create an LCD string representation of an<br /> integer value using a 3x3 grid of space, underscore, and <br /> pipe characters for each digit. Each digit is shown below <br /> (using a dot instead of a space)<br /><br /> .<i>. ... .</i>. .<i>. ... .</i>. .<i>. .</i>. .<i>. .</i>.<br /> |.| ..| .<i>| .</i>| |<i>| |</i>. |<i>. ..| |</i>| |_|<br /> |<i>| ..| |</i>. .<i>| ..| .</i>| |<i>| ..| |</i>| ..|<br /><br /><br /> Example: 910<br /><br /> .<i>. ... .</i>.<br /> |_| ..| |.|<br /> ..| ..| |_|<br />
<h3>Leap Year :</h3>
Write a function that returns true or false depending on <br /> whether its input integer is a leap year or not.<br /><br /> A leap year is defined as one that is divisible by 4,<br /> but is not otherwise divisible by 100 unless it is<br /> also divisble by 400.<br /><br /> For example, 2001 is a typical common year and 1996<br /> is a typical leap year, whereas 1900 is an atypical<br /> common year and 2000 is an atypical leap year.<br />
<h3>Mine Fields :</h3>
A field of N x M squares is represented by N lines of <br /> exactly M characters each. The character '*' represents <br /> a mine and the character '.' represents no-mine. <br /><br /> Example input (a 4 x 3 mine-field of 12 squares, 2 of<br /> which are mines)<br /><br /> 4 3<br /> *...<br /> ..*.<br /> ....<br /><br /> Your task is to write a program to accept this input and<br /> produce as output a hint-field of identical dimensions <br /> where each square is a * for a mine or the number of <br /> adjacent mine-squares if the square does not contain a mine. <br /><br /> Example output (for the above input)<br /> *211<br /> 12*1<br /> 0111<br />
<h3>Poker Hands</h3>
A poker deck contains 52 cards - each card has a suit which<br /> is one of clubs, diamonds, hearts, or spades <br /> (denoted C, D, H, and S in the input data). <br /><br /> Each card also has a value which is one of <br /> 2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, king, ace <br /> (denoted 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, A). <br /><br /> For scoring purposes, the suits are unordered while the<br /> values are ordered as given above, with 2 being the lowest<br /> and ace the highest value.<br /><br /> A poker hand consists of 5 cards dealt from the deck. Poker<br /> hands are ranked by the following partial order from lowest<br /> to highest.<br /><br /> High Card: Hands which do not fit any higher category are<br /> ranked by the value of their highest card. If the highest<br /> cards have the same value, the hands are ranked by the next<br /> highest, and so on.<br /><br /> Pair: 2 of the 5 cards in the hand have the same value. <br /> Hands which both contain a pair are ranked by the value of<br /> the cards forming the pair. If these values are the same, <br /> the hands are ranked by the values of the cards not <br /> forming the pair, in decreasing order.<br /><br /> Two Pairs: The hand contains 2 different pairs. Hands <br /> which both contain 2 pairs are ranked by the value of <br /> their highest pair. Hands with the same highest pair <br /> are ranked by the value of their other pair. If these <br /> values are the same the hands are ranked by the value <br /> of the remaining card.<br /><br /> Three of a Kind: Three of the cards in the hand have the <br /> same value. Hands which both contain three of a kind are <br /> ranked by the value of the 3 cards.<br /><br /> Straight: Hand contains 5 cards with consecutive values. <br /> Hands which both contain a straight are ranked by their <br /> highest card.<br /><br /> Flush: Hand contains 5 cards of the same suit. Hands which <br /> are both flushes are ranked using the rules for High Card.<br /><br /> Full House: 3 cards of the same value, with the remaining 2<br /> cards forming a pair. Ranked by the value of the 3 cards.<br /><br /> Four of a kind: 4 cards with the same value. Ranked by the<br /> value of the 4 cards.<br /><br /> Straight flush: 5 cards of the same suit with consecutive<br /> values. Ranked by the highest card in the hand.<br /><br /> Your job is to rank pairs of poker hands and to indicate<br /> which, if either, has a higher rank.<br /><br /> Examples:<br /> Input: Black: 2H 3D 5S 9C KD White: 2C 3H 4S 8C AH<br /> Output: White wins - high card: Ace <br /><br /> Input: Black: 2H 4S 4C 2D 4H White: 2S 8S AS QS 3S<br /> Output: White wins - flush <br /><br /> Input: Black: 2H 3D 5S 9C KD White: 2C 3H 4S 8C KH<br /> Output: Black wins - high card: 9<br /><br /> Input: Black: 2H 3D 5S 9C KD White: 2D 3H 5C 9S KH<br /> Output: Tie<br />
<h3>Recently Used List :</h3>
Develop a recently-used-list class to hold strings <br /> uniquely in Last-In-First-Out order.<br /><br /> o) The most recently added item is first, the least<br /> recently added item is last.<br /><br /> o) Items can be looked up by index, which counts from zero.<br /><br /> o) Items in the list are unique, so duplicate insertions<br /> are moved rather than added.<br /><br /> o) A recently-used-list is initially empty.<br /><br /> Optional extras<br /><br /> o) Null insertions (empty strings) are not allowed.<br /><br /> o) A bounded capacity can be specified, so there is an upper<br /> limit to the number of items contained, with the least<br /> recently added items dropped on overflow.
<h4>I added more tests</h4>
o) While getting items by index, supplied index-value should be within the bounds of List <a href="https://tddkatas.codeplex.com/wikipage?title=eg.%0a%09if%20maximum%20item%20counts%20of%20list%20is%205%20then%20supplied%20index%20is%20less%20than%204%20as%20index%20starts%20from%200%20%28zero%29&referringTitle=Documentation">eg.<br />	if maximum item counts of list is 5 then supplied index is less than 4 as index starts from 0 (zero)</a><br /> o) Negative index value not allowed <a href="https://tddkatas.codeplex.com/wikipage?title=%3e0&referringTitle=Documentation">>0</a><br /> o) Size limit is must if not supplied make 5 as default <a href="https://tddkatas.codeplex.com/wikipage?title=0-4&referringTitle=Documentation">0-4</a><br /> o) List can be non-sizable means without upper limit list can be created <a href="https://tddkatas.codeplex.com/wikipage?title=Hint-try%20property%20or%20constructor%20initializers&referringTitle=Documentation">Hint-try property or constructor initializers</a><br />
<h3>Reversi :</h3>
Reversi is a board game for two players. The board contains<br /> 8x8 squares. The players place Black or White counters onto<br /> the board, one counter per square. More information can be<br /> found on Wikipedia en.wikipedia.org/wiki/Reversi?. Your task<br /> is to write a program that takes a current board position<br /> together with information about whose turn it is, and returns<br /> a list of the legal moves for that player. A move is only legal<br /> if it results in at least one of the opponent's counters being<br /> flipped.<br /><br /> Example input: (the final B indicates it is Black's turn)<br /> ........<br /> ........<br /> ........<br /> ...BW...<br /> ...WB...<br /> ........<br /> ........<br /> ........<br /> B<br /><br /> Example output: (each zero indicates a legal move for Black)<br /> ........<br /> ........<br /> ....0...<br /> ...BW0..<br /> ..0WB...<br /> ...0....<br /> ........<br /> ........<br /> B<br />
<h3>Yehtzee :</h3>
The game of yahtzee is a simple dice game. Each player rolls five<br /> six-sided dice. They can re-roll some or all of the dice up to three<br /> times (including the original roll).<br /><br /> For example, suppose a players rolls<br /> 3,4,5,5,2<br /> They hold the two fives and re-roll the other three dice (3,4,2)<br /> 5,1,5,5,3<br /> They hold the three fives and re-roll the other two dice (1,3)<br /> 5,6,5,5,2<br /><br /> The player then places the roll in a category, such as ones, twos, fives, <br /> pair, two pairs etc (see below). If the roll is compatible with the category, <br /> the player gets a score for the roll according to the rules. If the roll is not <br /> compatible with the category, the player scores zero for the roll.<br /><br /> For example, suppose a player scores 5,6,5,5,2 in the fives category they<br /> would score 15 (three fives). The score for that go is then added to their <br /> total and the category cannot be used again in the remaining goes for that game. <br /> A full game consists of one go for each category. Thus, for their last go in<br /> a game, a player must choose their only remaining category.<br /><br /> Your task is to score a GIVEN roll in a GIVEN category.<br /> You do NOT have to program the random dice rolling.<br /> The game is NOT played by letting the computer choose the highest scoring<br /> category for a given roll.<br /> <br /><br /> Yahzee Categories and Scoring Rules<br /> ===================================<br /><br /> Chance: <br /> The player scores the sum of all dice, no matter what they read.<br /> For example,<br /> 1,1,3,3,6 placed on "chance" scores 14 (1<u>1</u>3<u>3</u>6)<br /> 4,5,5,6,1 placed on "chance" scores 21 (4<u>5</u>5<u>6</u>1) <br /><br /> Yahtzee: <br /> If all dice have the same number, the player scores 50 points. <br /> For example,<br /> 1,1,1,1,1 placed on "yahtzee" scores 50<br /> 1,1,1,2,1 placed on "yahtzee" scores 0<br /><br /> Ones, Twos, Threes, Fours, Fives, Sixes: <br /> The player scores the sum of the dice that reads one, <br /> two, three, four, five or six, respectively. <br /> For example, <br /> 1,1,2,4,4 placed on "fours" scores 8 (4+4)<br /> 2,3,2,5,1 placed on "twos" scores 4 (2+2)<br /> 3,3,3,4,5 placed on "ones" scores 0<br /><br /> Pair: <br /> The player scores the sum of the two highest matching dice.<br /> For example, when placed on "pair" <br /> 3,3,3,4,4 scores 8 (4+4)<br /> 1,1,6,2,6 scores 12 (6+6)<br /> 3,3,3,4,1 scores 0<br /> 3,3,3,3,1 scores 0<br /><br /> Two pairs: <br /> If there are two pairs of dice with the same number, the<br /> player scores the sum of these dice. <br /> For example, when placed on "two pairs"<br /> 1,1,2,3,3 scores 8 (1<u>1</u>3+3)<br /> 1,1,2,3,4 scores 0<br /> 1,1,2,2,2 scores 0<br /><br /> Three of a kind: <br /> If there are three dice with the same number, the player<br /> scores the sum of these dice. <br /> For example, when placed on "three of a kind" <br /> 3,3,3,4,5 scores 9 (3<u>3</u>3)<br /> 3,3,4,5,6 scores 0<br /> 3,3,3,3,1 scores 0<br /><br /> Four of a kind: <br /> If there are four dice with the same number, the player<br /> scores the sum of these dice. <br /> For example, when placed on "four of a kind" <br /> 2,2,2,2,5 scores 8 (2<u>2</u>2+2)<br /> 2,2,2,5,5 scores 0<br /> 2,2,2,2,2 scores 0<br /><br /> Small straight: <br /> When placed on "small straight", if the dice read <br /> 1,2,3,4,5, the player scores 15 (the sum of all the dice.<br /><br /> Large straight: <br /> When placed on "large straight", if the dice read <br /> 2,3,4,5,6, the player scores 20 (the sum of all the dice).<br /><br /> Full house: <br /> If the dice are two of a kind and three of a kind, the<br /> player scores the sum of all the dice. <br /> For example, when placed on "full house" <br /> 1,1,2,2,2 scores 8 (1<u>1</u>2<u>2</u>2) <br /> 2,2,3,3,4 scores 0<br /> 4,4,4,4,4 scores 0
<hr />-----------------------------------------------------------------<br />
<h2>Many more from <a href="https://tddkatas.codeplex.com/wikipage?title=url%20%3a%20http%3a%2f%2fcodekata.pragprog.com%2f2007%2f01%2fcode_kata_backg.html&referringTitle=Documentation&ANCHOR#more">url : http://codekata.pragprog.com/2007/01/code_kata_backg.html</a></h2>
<hr />------------------------------------------------------------------<br />
<h2>The Word Wrap Kata <a href="https://tddkatas.codeplex.com/wikipage?title=http%3a%2f%2fcodingdojo.org%2fcgi-bin%2fwiki.pl%3fKataWordWrap&referringTitle=Documentation">http://codingdojo.org/cgi-bin/wiki.pl?KataWordWrap</a></h2>
Create a function which breaks words on specified space with new line. Its nothing but merely similar to word-processor.<br />
<h3>Steps:</h3>
1. Create a public class named WordWrap<br /> 2. Create a method 'wrap' it can be a static method<br /> 3. Create a function which count the number of spliter words of non-space<br /> 4. check for if words already having newline <a href="https://tddkatas.codeplex.com/wikipage?title=%27%5cn%27&referringTitle=Documentation">'\n'</a> characters - ignore in counts<br /> 5. Check for multiple lines<br /> 6. Remove blank spaces if any in new line eg. Actual - "this is a test" WrappedText = "this\n is a t\nest"<br />
<hr />----------------------------------------------------------------------------------------------------------------------
<h2>Natural Order String Sorting</h2>
<hr />----------------------------------------------------------------------------------------------------------------------
<h2>There is no built-in feature available in .Net to provide us Natural String Order Soring.</h2>
<h3>What is Natural Order String Sorting?</h3>
Almost all framework provided ASCII order Sorting so, in case of string list : 1,2,3...,1A,2S the result would be as per ASCII order<br /> But in Natural Order String this should be : 1,1A,2,2S,3... etc.<br /><br /></div><div class="ClearBoth"></div>g_aroraWed, 27 May 2015 09:39:19 GMTUpdated Wiki: Documentation 20150527093919AUpdated Wiki: Documentationhttp://tddkatas.codeplex.com/documentation?version=3<div class="wikidoc"><b>What is TDD-Katas?</b><br /><i>Refer to </i> : <a href="http://stuff4mdesktop.blogspot.com/2011/10/what-is-tdd-kata.html" class="externalLink">http://stuff4mdesktop.blogspot.com/2011/10/what-is-tdd-kata.html<span class="externalLinkIcon"></span></a><br /><br /><br />
<h1>TDD-Katas : <b>Get More from : </b> - <a href="https://github.com/garora/TDD-Katas" class="externalLink">https://github.com/garora/TDD-Katas<span class="externalLinkIcon"></span></a></h1>
<h2>String Calculator</h2>
- Create a simple String calculator with a method int Add(string numbers)<br /> - The method can take 0, 1 or 2 numbers, and will return their sum (for an empty string it will<br /> return 0) for example �� or �1� or �1,2�<br /> - Start with the simplest test case of an empty string and move to 1 and two numbers<br /> - Remember to solve things as simply as possible so that you force yourself to write tests you did<br /> not think about<br /> - Remember to refactor after each passing test<br /> - Allow the Add method to handle an unknown amount of numbers<br /> - Allow the Add method to handle new lines between numbers (instead of commas).<br /> - the following input is ok: �1\n2,3� (will equal 6)<br /> - the following input is NOT ok: �1,\n� (not need to prove it - just clarifying)<br /> - Support different delimiters<br /> to change a delimiter, the beginning of the string will contain a separate line that looks like this: <br /> �//<a href="http://tddkatas.codeplex.com/wikipage?title=delimiter&referringTitle=Documentation">delimiter</a>\n<a href="http://tddkatas.codeplex.com/wikipage?title=numbers%ef%bf%bd&referringTitle=Documentation">numbers�</a>� for example �//;\n1;2� should return three where the default delimiter is �;� .<br /> the first line is optional. all existing scenarios should still be supported<br /> - Calling Add with a negative number will throw an exception �negatives not allowed� - and the negative that was passed.<br /> if there are multiple negatives, show all of them in the exception message <br />
<hr />------------------------------------------------------------<br /> Completed first Kata example
<hr />------------------------------------------------------------<br />
<h2>The Bowling Game Kata</h2>
- Following Uncle bob post from here : http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata<br /> - Create a new project or start in the existing project by adding Game.cs and TestGame.cs<br /> - Create two public methods methods <a href="http://tddkatas.codeplex.com/wikipage?title=refer%20to%20the%20presentation%20file&referringTitle=Documentation">refer to the presentation file</a><br /> - Create Test Methods for the above Methods<br /> - This is called a 'RED' Test as it is going to fail.<br /> - Rectified both test and class methods<br /> - Write new test<br /> - This is called a 'Green' Test as it is going to pass.<br /> - Rectified TestMethods to meet total 20 frames hit.<br /> - Rectified test to accept multiple frame and pins<br /> - Test 3 is a 'Red' test<br /> - Test 4 and 5 are 'Green'<br /> - All test passed<br /> - Still there is scope of refactoring<br />
<h2>The FizzBuzz Kata</h2>
- Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" <br /> instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both <br /> three and five print "FizzBuzz".<br />
<h3>Steps:</h3>
Lets divide this into different steps so, we can easily write and test this.<br /> - Print numbers from 1 to 100<br /> - Print "Fizz" instead of number which is divisible by 3<br /> - Print "Buzz" instead of number which is divisible by 5<br /> - Print "FizzBuzz" instead of number which is divisible by both 3 and 5<br />
<h4>Make more test for accept numbers and provide results</h4>
- Create a method to accept single number<br /> - Create test to verify supplied number within the range 1 to 100<br /> - Create test to verify number and return result Fizz or Buzz or FizzBuzz per above criteria<br />
<h2>The OddEven Kata</h2>
- Write a program that prints numbers within specified range lets say 1 to 100. If number is odd print 'Odd'<br /> instead of the number. If number is even print 'Even' instead of number. Else print number <a href="http://tddkatas.codeplex.com/wikipage?title=hint%20-%20if%20number%20is%20Prime&referringTitle=Documentation">hint - if number is Prime</a>.<br />
<h3>Steps :</h3>
Lets divide into following stesp:<br /> - Prints numbers from 1 to 100<br /> - Print "Even" instead of number, if the number is even, means divisible by 2<br /> - Print "Odd" instead of number, if the number is odd, means not divisible by 2 but not divisible by itself too<br /> - Print number, if it does not meet above two conditions, means if number is Prime<br /> - Make method to accept any number of range <a href="http://tddkatas.codeplex.com/wikipage?title=currently%20%20we%20have%201%20to%20100&referringTitle=Documentation">currently we have 1 to 100</a><br /> - Create a new method to check Odd/Even/Prime of a single supplied method<br />
<h2>The PrimeFactor Kata</h2>
An awesome Kata from Uncle BoB <a href="http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata" class="externalLink">http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata<span class="externalLinkIcon"></span></a><br />
<hr />---------------<br />
<h2>Kata - coming next <a href="http://tddkatas.codeplex.com/wikipage?title=source%20url%3ahttp%3a%2f%2fwww.cyber-dojo.com%2f&referringTitle=Documentation">source url:http://www.cyber-dojo.com/</a></h2>
<h3>Calc Stats:</h3>
Your task is to process a sequence of integer numbers<br /> to determine the following statistics:<br /><br /> o) minimum value<br /> o) maximum value<br /> o) number of elements in the sequence<br /> o) average value<br /><br /> For example: <a href="http://tddkatas.codeplex.com/wikipage?title=6%2c%209%2c%2015%2c%20-2%2c%2092%2c%2011&referringTitle=Documentation">6, 9, 15, -2, 92, 11</a><br /><br /> o) minimum value = -2<br /> o) maximum value = 92<br /> o) number of elements in the sequence = 6<br /> o) average value = 18.166666<br />
<h3>Diversion :</h3>
Think of binary numbers: sequences of 0's and 1's. How many <br /> n-digit binary numbers are there that don't have two adjacent<br /> 1 bits? <br /><br /> For example, for three-digit numbers, Five of the possible<br /> eight combinations meet the criteria: <br /><br /> 000, 001, 010, 011, 100, 101, 110, 111. <br /><br /> What is the number for sequences of length 4, 5, 10, n?<br /><br /> Having worked out the pattern, there's a second part to the <br /> question: can you prove why that relationship exists? <br />
<h3>Game of Life :</h3>
Your task is to write a program to calculate the next<br /> generation of Conway's game of life, given any starting<br /> position. You start with a two dimensional grid of cells, <br /> where each cell is either alive or dead. The grid is finite, <br /> and no life can exist off the edges. When calculating the <br /> next generation of the grid, follow these four rules:<br /><br /> 1. Any live cell with fewer than two live neighbours dies, <br /> as if caused by underpopulation.<br /> 2. Any live cell with more than three live neighbours dies, <br /> as if by overcrowding.<br /> 3. Any live cell with two or three live neighbours lives <br /> on to the next generation.<br /> 4. Any dead cell with exactly three live neighbours becomes <br /> a live cell.<br /><br /> Examples: * indicates live cell, . indicates dead cell<br /><br /> Example input: (4 x 8 grid)<br /> 4 8<br /> ........<br /> ....*...<br /> ...<b></b>...<br /> ........<br /><br /> Example output:<br /> 4 8<br /> ........<br /> ...<b></b>...<br /> ...<b></b>...<br /> ........<br />
<h3>Harry Potter :</h3>
To try and encourage more sales of the 5 different Harry<br /> Potter books they sell, a bookshop has decided to offer <br /> discounts of multiple-book purchases. <br /><br /> One copy of any of the five books costs 8 EUR. <br /><br /> If, however, you buy two different books, you get a 5% <br /> discount on those two books.<br /><br /> If you buy 3 different books, you get a 10% discount. <br /><br /> If you buy 4 different books, you get a 20% discount.<br /><br /> If you go the whole hog, and buy all 5, you get a huge 25%<br /> discount. <br /><br /> Note that if you buy, say, four books, of which 3 are <br /> different titles, you get a 10% discount on the 3 that <br /> form part of a set, but the fourth book still costs 8 EUR. <br /><br /> Your mission is to write a piece of code to calculate the <br /> price of any conceivable shopping basket (containing only <br /> Harry Potter books), giving as big a discount as possible.<br /><br /> For example, how much does this basket of books cost?<br /><br /> 2 copies of the first book<br /> 2 copies of the second book<br /> 2 copies of the third book<br /> 1 copy of the fourth book<br /> 1 copy of the fifth book<br /><br /> Answer: 51.20 EUR<br />
<h3>LCD Digits :</h3>
Your task is to create an LCD string representation of an<br /> integer value using a 3x3 grid of space, underscore, and <br /> pipe characters for each digit. Each digit is shown below <br /> (using a dot instead of a space)<br /><br /> .<i>. ... .</i>. .<i>. ... .</i>. .<i>. .</i>. .<i>. .</i>.<br /> |.| ..| .<i>| .</i>| |<i>| |</i>. |<i>. ..| |</i>| |_|<br /> |<i>| ..| |</i>. .<i>| ..| .</i>| |<i>| ..| |</i>| ..|<br /><br /><br /> Example: 910<br /><br /> .<i>. ... .</i>.<br /> |_| ..| |.|<br /> ..| ..| |_|<br />
<h3>Leap Year :</h3>
Write a function that returns true or false depending on <br /> whether its input integer is a leap year or not.<br /><br /> A leap year is defined as one that is divisible by 4,<br /> but is not otherwise divisible by 100 unless it is<br /> also divisble by 400.<br /><br /> For example, 2001 is a typical common year and 1996<br /> is a typical leap year, whereas 1900 is an atypical<br /> common year and 2000 is an atypical leap year.<br />
<h3>Mine Fields :</h3>
A field of N x M squares is represented by N lines of <br /> exactly M characters each. The character '*' represents <br /> a mine and the character '.' represents no-mine. <br /><br /> Example input (a 4 x 3 mine-field of 12 squares, 2 of<br /> which are mines)<br /><br /> 4 3<br /> *...<br /> ..*.<br /> ....<br /><br /> Your task is to write a program to accept this input and<br /> produce as output a hint-field of identical dimensions <br /> where each square is a * for a mine or the number of <br /> adjacent mine-squares if the square does not contain a mine. <br /><br /> Example output (for the above input)<br /> *211<br /> 12*1<br /> 0111<br />
<h3>Poker Hands</h3>
A poker deck contains 52 cards - each card has a suit which<br /> is one of clubs, diamonds, hearts, or spades <br /> (denoted C, D, H, and S in the input data). <br /><br /> Each card also has a value which is one of <br /> 2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, king, ace <br /> (denoted 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, A). <br /><br /> For scoring purposes, the suits are unordered while the<br /> values are ordered as given above, with 2 being the lowest<br /> and ace the highest value.<br /><br /> A poker hand consists of 5 cards dealt from the deck. Poker<br /> hands are ranked by the following partial order from lowest<br /> to highest.<br /><br /> High Card: Hands which do not fit any higher category are<br /> ranked by the value of their highest card. If the highest<br /> cards have the same value, the hands are ranked by the next<br /> highest, and so on.<br /><br /> Pair: 2 of the 5 cards in the hand have the same value. <br /> Hands which both contain a pair are ranked by the value of<br /> the cards forming the pair. If these values are the same, <br /> the hands are ranked by the values of the cards not <br /> forming the pair, in decreasing order.<br /><br /> Two Pairs: The hand contains 2 different pairs. Hands <br /> which both contain 2 pairs are ranked by the value of <br /> their highest pair. Hands with the same highest pair <br /> are ranked by the value of their other pair. If these <br /> values are the same the hands are ranked by the value <br /> of the remaining card.<br /><br /> Three of a Kind: Three of the cards in the hand have the <br /> same value. Hands which both contain three of a kind are <br /> ranked by the value of the 3 cards.<br /><br /> Straight: Hand contains 5 cards with consecutive values. <br /> Hands which both contain a straight are ranked by their <br /> highest card.<br /><br /> Flush: Hand contains 5 cards of the same suit. Hands which <br /> are both flushes are ranked using the rules for High Card.<br /><br /> Full House: 3 cards of the same value, with the remaining 2<br /> cards forming a pair. Ranked by the value of the 3 cards.<br /><br /> Four of a kind: 4 cards with the same value. Ranked by the<br /> value of the 4 cards.<br /><br /> Straight flush: 5 cards of the same suit with consecutive<br /> values. Ranked by the highest card in the hand.<br /><br /> Your job is to rank pairs of poker hands and to indicate<br /> which, if either, has a higher rank.<br /><br /> Examples:<br /> Input: Black: 2H 3D 5S 9C KD White: 2C 3H 4S 8C AH<br /> Output: White wins - high card: Ace <br /><br /> Input: Black: 2H 4S 4C 2D 4H White: 2S 8S AS QS 3S<br /> Output: White wins - flush <br /><br /> Input: Black: 2H 3D 5S 9C KD White: 2C 3H 4S 8C KH<br /> Output: Black wins - high card: 9<br /><br /> Input: Black: 2H 3D 5S 9C KD White: 2D 3H 5C 9S KH<br /> Output: Tie<br />
<h3>Recently Used List :</h3>
Develop a recently-used-list class to hold strings <br /> uniquely in Last-In-First-Out order.<br /><br /> o) The most recently added item is first, the least<br /> recently added item is last.<br /><br /> o) Items can be looked up by index, which counts from zero.<br /><br /> o) Items in the list are unique, so duplicate insertions<br /> are moved rather than added.<br /><br /> o) A recently-used-list is initially empty.<br /><br /> Optional extras<br /><br /> o) Null insertions (empty strings) are not allowed.<br /><br /> o) A bounded capacity can be specified, so there is an upper<br /> limit to the number of items contained, with the least<br /> recently added items dropped on overflow.
<h4>I added more tests</h4>
o) While getting items by index, supplied index-value should be within the bounds of List <a href="http://tddkatas.codeplex.com/wikipage?title=eg.%0a%09if%20maximum%20item%20counts%20of%20list%20is%205%20then%20supplied%20index%20is%20less%20than%204%20as%20index%20starts%20from%200%20%28zero%29&referringTitle=Documentation">eg.<br />	if maximum item counts of list is 5 then supplied index is less than 4 as index starts from 0 (zero)</a><br /> o) Negative index value not allowed <a href="http://tddkatas.codeplex.com/wikipage?title=%3e0&referringTitle=Documentation">>0</a><br /> o) Size limit is must if not supplied make 5 as default <a href="http://tddkatas.codeplex.com/wikipage?title=0-4&referringTitle=Documentation">0-4</a><br /> o) List can be non-sizable means without upper limit list can be created <a href="http://tddkatas.codeplex.com/wikipage?title=Hint-try%20property%20or%20constructor%20initializers&referringTitle=Documentation">Hint-try property or constructor initializers</a><br />
<h3>Reversi :</h3>
Reversi is a board game for two players. The board contains<br /> 8x8 squares. The players place Black or White counters onto<br /> the board, one counter per square. More information can be<br /> found on Wikipedia en.wikipedia.org/wiki/Reversi?. Your task<br /> is to write a program that takes a current board position<br /> together with information about whose turn it is, and returns<br /> a list of the legal moves for that player. A move is only legal<br /> if it results in at least one of the opponent's counters being<br /> flipped.<br /><br /> Example input: (the final B indicates it is Black's turn)<br /> ........<br /> ........<br /> ........<br /> ...BW...<br /> ...WB...<br /> ........<br /> ........<br /> ........<br /> B<br /><br /> Example output: (each zero indicates a legal move for Black)<br /> ........<br /> ........<br /> ....0...<br /> ...BW0..<br /> ..0WB...<br /> ...0....<br /> ........<br /> ........<br /> B<br />
<h3>Yehtzee :</h3>
The game of yahtzee is a simple dice game. Each player rolls five<br /> six-sided dice. They can re-roll some or all of the dice up to three<br /> times (including the original roll).<br /><br /> For example, suppose a players rolls<br /> 3,4,5,5,2<br /> They hold the two fives and re-roll the other three dice (3,4,2)<br /> 5,1,5,5,3<br /> They hold the three fives and re-roll the other two dice (1,3)<br /> 5,6,5,5,2<br /><br /> The player then places the roll in a category, such as ones, twos, fives, <br /> pair, two pairs etc (see below). If the roll is compatible with the category, <br /> the player gets a score for the roll according to the rules. If the roll is not <br /> compatible with the category, the player scores zero for the roll.<br /><br /> For example, suppose a player scores 5,6,5,5,2 in the fives category they<br /> would score 15 (three fives). The score for that go is then added to their <br /> total and the category cannot be used again in the remaining goes for that game. <br /> A full game consists of one go for each category. Thus, for their last go in<br /> a game, a player must choose their only remaining category.<br /><br /> Your task is to score a GIVEN roll in a GIVEN category.<br /> You do NOT have to program the random dice rolling.<br /> The game is NOT played by letting the computer choose the highest scoring<br /> category for a given roll.<br /> <br /><br /> Yahzee Categories and Scoring Rules<br /> ===================================<br /><br /> Chance: <br /> The player scores the sum of all dice, no matter what they read.<br /> For example,<br /> 1,1,3,3,6 placed on "chance" scores 14 (1<u>1</u>3<u>3</u>6)<br /> 4,5,5,6,1 placed on "chance" scores 21 (4<u>5</u>5<u>6</u>1) <br /><br /> Yahtzee: <br /> If all dice have the same number, the player scores 50 points. <br /> For example,<br /> 1,1,1,1,1 placed on "yahtzee" scores 50<br /> 1,1,1,2,1 placed on "yahtzee" scores 0<br /><br /> Ones, Twos, Threes, Fours, Fives, Sixes: <br /> The player scores the sum of the dice that reads one, <br /> two, three, four, five or six, respectively. <br /> For example, <br /> 1,1,2,4,4 placed on "fours" scores 8 (4+4)<br /> 2,3,2,5,1 placed on "twos" scores 4 (2+2)<br /> 3,3,3,4,5 placed on "ones" scores 0<br /><br /> Pair: <br /> The player scores the sum of the two highest matching dice.<br /> For example, when placed on "pair" <br /> 3,3,3,4,4 scores 8 (4+4)<br /> 1,1,6,2,6 scores 12 (6+6)<br /> 3,3,3,4,1 scores 0<br /> 3,3,3,3,1 scores 0<br /><br /> Two pairs: <br /> If there are two pairs of dice with the same number, the<br /> player scores the sum of these dice. <br /> For example, when placed on "two pairs"<br /> 1,1,2,3,3 scores 8 (1<u>1</u>3+3)<br /> 1,1,2,3,4 scores 0<br /> 1,1,2,2,2 scores 0<br /><br /> Three of a kind: <br /> If there are three dice with the same number, the player<br /> scores the sum of these dice. <br /> For example, when placed on "three of a kind" <br /> 3,3,3,4,5 scores 9 (3<u>3</u>3)<br /> 3,3,4,5,6 scores 0<br /> 3,3,3,3,1 scores 0<br /><br /> Four of a kind: <br /> If there are four dice with the same number, the player<br /> scores the sum of these dice. <br /> For example, when placed on "four of a kind" <br /> 2,2,2,2,5 scores 8 (2<u>2</u>2+2)<br /> 2,2,2,5,5 scores 0<br /> 2,2,2,2,2 scores 0<br /><br /> Small straight: <br /> When placed on "small straight", if the dice read <br /> 1,2,3,4,5, the player scores 15 (the sum of all the dice.<br /><br /> Large straight: <br /> When placed on "large straight", if the dice read <br /> 2,3,4,5,6, the player scores 20 (the sum of all the dice).<br /><br /> Full house: <br /> If the dice are two of a kind and three of a kind, the<br /> player scores the sum of all the dice. <br /> For example, when placed on "full house" <br /> 1,1,2,2,2 scores 8 (1<u>1</u>2<u>2</u>2) <br /> 2,2,3,3,4 scores 0<br /> 4,4,4,4,4 scores 0
<hr />-----------------------------------------------------------------<br />
<h2>Many more from <a href="http://tddkatas.codeplex.com/wikipage?title=url%20%3a%20http%3a%2f%2fcodekata.pragprog.com%2f2007%2f01%2fcode_kata_backg.html&referringTitle=Documentation&ANCHOR#more">url : http://codekata.pragprog.com/2007/01/code_kata_backg.html</a></h2>
<hr />------------------------------------------------------------------<br />
<h2>The Word Wrap Kata <a href="http://tddkatas.codeplex.com/wikipage?title=http%3a%2f%2fcodingdojo.org%2fcgi-bin%2fwiki.pl%3fKataWordWrap&referringTitle=Documentation">http://codingdojo.org/cgi-bin/wiki.pl?KataWordWrap</a></h2>
Create a function which breaks words on specified space with new line. Its nothing but merely similar to word-processor.<br />
<h3>Steps:</h3>
1. Create a public class named WordWrap<br /> 2. Create a method 'wrap' it can be a static method<br /> 3. Create a function which count the number of spliter words of non-space<br /> 4. check for if words already having newline <a href="http://tddkatas.codeplex.com/wikipage?title=%27%5cn%27&referringTitle=Documentation">'\n'</a> characters - ignore in counts<br /> 5. Check for multiple lines<br /> 6. Remove blank spaces if any in new line eg. Actual - "this is a test" WrappedText = "this\n is a t\nest"<br />
<hr />----------------------------------------------------------------------------------------------------------------------
<h2>Natural Order String Sorting</h2>
<hr />----------------------------------------------------------------------------------------------------------------------
<h2>There is no built-in feature available in .Net to provide us Natural String Order Soring.</h2>
<h3>What is Natural Order String Sorting?</h3>
Almost all framework provided ASCII order Sorting so, in case of string list : 1,2,3...,1A,2S the result would be as per ASCII order<br /> But in Natural Order String this should be : 1,1A,2,2S,3... etc.<br /><br /></div><div class="ClearBoth"></div>g_aroraSat, 28 Jan 2012 09:50:29 GMTUpdated Wiki: Documentation 20120128095029AUpdated Wiki: Documentationhttp://tddkatas.codeplex.com/documentation?version=2<div class="wikidoc"><b>What is TDD-Katas?</b><br /><i>Refer to </i> : <a href="http://stuff4mdesktop.blogspot.com/2011/10/what-is-tdd-kata.html" class="externalLink">http://stuff4mdesktop.blogspot.com/2011/10/what-is-tdd-kata.html<span class="externalLinkIcon"></span></a><br /><br /><b>Documents : </b> - <a href="https://github.com/garora/TDD-Katas" class="externalLink">https://github.com/garora/TDD-Katas<span class="externalLinkIcon"></span></a></div><div class="ClearBoth"></div>g_aroraSun, 11 Dec 2011 19:33:15 GMTUpdated Wiki: Documentation 20111211073315PUpdated Wiki: Homehttp://tddkatas.codeplex.com/wikipage?version=5<div class="wikidoc"><b>Project Description</b><br />*TDD-Katas* simply defines the Test Driven Development Katas. In this, I tried to create most famous katas to understand what is exactly Kata.<br /><br />So, get into the code and let us know for any improvement<br /><br /><b>Latest version</b><br />Available at : <a href="https://github.com/garora/TDD-Katas" class="externalLink">https://github.com/garora/TDD-Katas<span class="externalLinkIcon"></span></a><br /><br />Updated nightly build<br /><br /><b>Whats next ?</b><br />Next Kata is <b>Roman Numeral</b> <a href="http://codingdojo.org/cgi-bin/wiki.pl?KataRomanNumerals" class="externalLink">http://codingdojo.org/cgi-bin/wiki.pl?KataRomanNumerals<span class="externalLinkIcon"></span></a><br /></div><div class="ClearBoth"></div>g_aroraSun, 11 Dec 2011 19:28:26 GMTUpdated Wiki: Home 20111211072826PUpdated Wiki: Homehttp://tddkatas.codeplex.com/wikipage?version=4<div class="wikidoc"><b>Project Description</b><br />*TDD-Katas* simply defines the Test Driven Development Katas. In this, I tried to create most famous katas to understand what is exactly Kata.<br /><br />So, get into the code and let us know for any improvement<br /><br /><b>Latest version</b><br />Available at : <a href="https://github.com/garora/TDD-Katas" class="externalLink">https://github.com/garora/TDD-Katas<span class="externalLinkIcon"></span></a><br /><br />Updated nightly build<br /><br /><b>Whats next ?</b><br />Next Kata is <b>Roman Numeral</b> <a href="http://codingdojo.org/cgi-bin/wiki.pl?KataRomanNumerals" class="externalLink">http://codingdojo.org/cgi-bin/wiki.pl?KataRomanNumerals<span class="externalLinkIcon"></span></a><br /></div><div class="ClearBoth"></div>g_aroraSun, 11 Dec 2011 19:27:40 GMTUpdated Wiki: Home 20111211072740PUpdated Wiki: Documentationhttp://tddkatas.codeplex.com/documentation?version=1<div class="wikidoc"><b>What is TDD-Katas?</b><br /><i>Refer to </i> : <a href="http://stuff4mdesktop.blogspot.com/2011/10/what-is-tdd-kata.html" class="externalLink">http://stuff4mdesktop.blogspot.com/2011/10/what-is-tdd-kata.html<span class="externalLinkIcon"></span></a></div><div class="ClearBoth"></div>g_aroraWed, 07 Dec 2011 20:50:06 GMTUpdated Wiki: Documentation 20111207085006PUpdated Wiki: Homehttp://tddkatas.codeplex.com/wikipage?version=3<div class="wikidoc"><b>Project Description</b><br />*TDD-Katas* simply defines the Test Driven Development Katas. In this, I tried to create most famous katas to understand what is exactly Kata.<br /><br />So, get into the code and let us know for any improvement<br /><br /><b>Latest version</b><br />Available at : <a href="https://github.com/garora/TDD-Katas" class="externalLink">https://github.com/garora/TDD-Katas<span class="externalLinkIcon"></span></a><br /><br /><b>Whats next ?</b><br />Next Kata is <b>Roman Numeral</b> <a href="http://codingdojo.org/cgi-bin/wiki.pl?KataRomanNumerals" class="externalLink">http://codingdojo.org/cgi-bin/wiki.pl?KataRomanNumerals<span class="externalLinkIcon"></span></a><br /></div><div class="ClearBoth"></div>g_aroraWed, 07 Dec 2011 20:48:10 GMTUpdated Wiki: Home 20111207084810P