Click here to Skip to main content
14,547,071 members
   

C#

 
GeneralRe: problem to make a second recording Pin
ago248619-Mar-20 0:59
Memberago248619-Mar-20 0:59 
GeneralRe: problem to make a second recording Pin
ago248619-Mar-20 2:06
Memberago248619-Mar-20 2:06 
GeneralRe: problem to make a second recording Pin
OriginalGriff19-Mar-20 2:26
mveOriginalGriff19-Mar-20 2:26 
GeneralRe: problem to make a second recording Pin
ago248619-Mar-20 3:04
Memberago248619-Mar-20 3:04 
GeneralRe: problem to make a second recording Pin
OriginalGriff19-Mar-20 3:22
mveOriginalGriff19-Mar-20 3:22 
GeneralRe: problem to make a second recording Pin
ago248619-Mar-20 3:27
Memberago248619-Mar-20 3:27 
QuestionRe: problem to make a second recording Pin
ZurdoDev19-Mar-20 3:51
mveZurdoDev19-Mar-20 3:51 
QuestionHow to solve 100 Doors Kata using TDD in C# Pin
User-862169518-Mar-20 5:30
MemberUser-862169518-Mar-20 5:30 
Hi Guys,

I'm trying to write 100 Doors Kata using TDD. I have created the logic like below
// Logic Behind this Kata
   // 1, 2,....100
   // take first example 36- 36 is a perfect square of 6 and it is divisble by 36,18,12,9,6,4,3,2,1 which is 9 Odd
   // take first example 25- 25 is a perfect square of 5 and it is divisble by 25,5,1 which is 3 Odd
   // If we talk about not perfect square then - 50 is divisble by 50,25,10,5,2,1 which is 6 Even
   // If we talk about not perfect square then - 8 is divisble by 8,4,2,1 which is 4 Even
   // Now take example of 25 => 25 (Open), 5(Close), 1 (Open)
   // Now 36 => 36(Open),18(Close),12(Open),9(Close),6(Open),4(Close),3(Open),2(Close),1 (Open)
   // It means every perfect square has Open door
   // And Every non perfect square has Closed Door


But not sure from where I should start to write the Test. I've written 2 test cases like
[TestMethod]
      public void TestIfAllDoorsAreClosedAtBiginning()
      {
          bool[] result = _100DoorsKata.CheckDoorState(0);
          for (int i = 1; i <= 100; i++)
          {
              Assert.IsFalse(result[i]);
          }
      }

      [TestMethod]
      public void TestIfAllDoorsAreOpenedAfterFirstRound()
      {
          bool[] result = _100DoorsKata.CheckDoorState(1);
          for (int i = 1; i <= 100; i++)
          {
              Assert.IsTrue(result[i]);
          }
      }



And code seems to be:
public bool[] CheckDoorState(int pass)
       {
           bool[] doors = new bool[101];
           for (int i = 1; i <= 100; i++)
           {
               if (pass == 0)
               {
                   doors[i] = false;
               }
               else
               {

                   doors[i] = true;

               }

           }
           return doors;

       }

Can someone please help me to complete it.

Thanks

modified 18-Mar-20 11:37am.

AnswerRe: How to solve 100 Doors Kata using TDD in C# Pin
Bohdan Stupak19-Mar-20 5:12
professionalBohdan Stupak19-Mar-20 5:12 
Questionproblem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 3:13
Memberago248618-Mar-20 3:13 
AnswerRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 3:50
mveOriginalGriff18-Mar-20 3:50 
GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 4:11
Memberago248618-Mar-20 4:11 
GeneralRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 4:17
mveOriginalGriff18-Mar-20 4:17 
GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 4:24
Memberago248618-Mar-20 4:24 
GeneralRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 5:01
mveOriginalGriff18-Mar-20 5:01 
GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 5:12
Memberago248618-Mar-20 5:12 
GeneralRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 5:13
mveOriginalGriff18-Mar-20 5:13 
GeneralRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 5:16
mveOriginalGriff18-Mar-20 5:16 
GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 5:30
Memberago248618-Mar-20 5:30 
GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 5:33
Memberago248618-Mar-20 5:33 
GeneralRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 5:39
mveOriginalGriff18-Mar-20 5:39 
GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 5:42
Memberago248618-Mar-20 5:42 
GeneralRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 5:52
mveOriginalGriff18-Mar-20 5:52 
GeneralRe: problem retrieving info from one table to insert it into another Pin
ago248618-Mar-20 5:56
Memberago248618-Mar-20 5:56 
GeneralRe: problem retrieving info from one table to insert it into another Pin
OriginalGriff18-Mar-20 6:01
mveOriginalGriff18-Mar-20 6:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.