Ad
  • Custom User Avatar

    Could you add using namespace std; to your hidden tests so people aren't forced to add it to their code if they don't want to (C++ Version)?

  • Custom User Avatar

    That's how you define an extension method in C#.

    See: https://msdn.microsoft.com/en-us/library/bb383977.aspx

  • Custom User Avatar

    I'd say that this Kata could probably need some more tests. Maybe you could test that the Uncle Method is used and not just the same string returned.

  • Custom User Avatar

    It's probably because someone marked it with "Major Issues" without adding a comment. Which leads to this behaviour.

  • Custom User Avatar

    Maybe some tests with some null values in the List could be added? Or do you think this would be too much?

    Nice Kata btw. :)

  • Custom User Avatar

    Looks good, thank you. :-)

    Cheers

  • Custom User Avatar

    It'd probaby be a good idea to add some tests to verify that GetY(x) is correctly implemented.

  • Custom User Avatar

    Well it's actually the example [TestCase(222222222222, Result=1)] which requires a long. In the final tests it's been replaced with [TestCase(222222222, Result=1)] so I guess you can just replace this one example test with the one of the final tests.

    But what needs changing is the given starting code:

    public class Kata
    {
      public static void TwoCount(int n)
      {
        // your code here
      }
    }
    

    As a void return type is clearly wrong.

  • Custom User Avatar

    Issues with the C# version.

    Replace the given code with:

    public class Kata
    {
      public static int TwoCount(long n)
      {
        // your code here
      }
    }
    

    And also replace the given tests with:

    using NUnit.Framework;
    
    [TestFixture]
    public class Tests
    {
      [Test]
      [TestCase(24, Result=3)]
      [TestCase(17280, Result=7)]
      [TestCase(222222222222, Result=1)]
      [TestCase(256, Result=8)]
      [TestCase(1, Result=0)]
      [TestCase(2, Result=1)]
      [TestCase(7, Result=0)]
      [TestCase(84934656, Result=20)]
      public static int FixedTest(long num)
      {
        return Kata.TwoCount(num);
      }
    }
    
  • Custom User Avatar

    Maybe you should define the given input a little more, for example that the input will never be smaller than 3 (-> no prime is smaller than 2). :)

  • Custom User Avatar

    It fails, because you convert the string to PascalCase.

    With your solution the input "this-is-a-string" results in "ThisIsAString" but actually should be "thisIsAString" on the other hand if the input were "This-is-a-string" then the result should be "ThisIsAString".

    Hope this helps you out. :-)

  • Custom User Avatar

    Looks good. Actually you could even move the interface into the preloaded section and just show its code in the description. :)

  • Custom User Avatar

    There are some small issues with the given tests in C# just replace them with:

    using System;
    using System.Collections.Generic;
    using NUnit.Framework;
    
    [TestFixture]
    public static class Tests
    {
      [Test]
      public static void EmptyTree()
      {
        Pre sol = new Pre();
        Tree happy = new Tree();
        Console.WriteLine(happy.Description());
        Assert.AreEqual(sol.sol1,happy.Description());
      }
      [Test]
      public static void BadTree()
      {
        Pre sol = new Pre();
        Tree happy = new Tree();
        happy.GrowBranches();
        happy.Ouch(1);
        happy.GrowTrunk();
        Console.WriteLine(happy.Description());
        Assert.AreEqual(sol.sol2,happy.Description());
      }
      
      [Test]
      public static void GrownTree()
      {
        Pre sol = new Pre();
        Tree happy = new Tree();
        happy.NewBranch();
        happy.GrowTrunk();
        happy.GrowBranches();
        happy.GrowTrunk();
        happy.NewBranch();
        happy.NewBranch();
        happy.NewBranch();
        happy.NewBranch();
        happy.GrowBranches();
        happy.Ouch(3);
        happy.GrowTrunk();
        happy.GrowTrunk();
        happy.NewBranch();
        happy.GrowBranches();
        Console.WriteLine(happy.Description());
        Assert.AreEqual(sol.sol3,happy.Description());
      }
    }
    

    Also maybe you could add what the return type for the required functions or give a interface which needs to be implemented for example:

    public interface ITree
    {
      void GrowTrunk();
      void GrowBranches();
      void NewBranch();
      void Ouch(int n);
      string Description();
    }
    
    public class Tree : ITree
    {
      // your awesome code here =)
    }
    
  • Custom User Avatar

    So here are some things for the C# version:

    Replace your starting code with:

    public static class Kata
    {
      public static string[] CapMe(string[] strings)
      {
        // your awesome code here.
      }
    }
    

    For some example tests use:

    using NUnit.Framework;
    
    [TestFixture]
    public class CapitaliseTest
    {
      [Test]
      public void TestAllLower()
      {
        Assert.AreEqual(new[] { "Jo", "Nelson", "Jurie" }, Kata.CapMe(new[] { "jo", "nelson", "jurie" }));
      }
      
      [Test]
      public void TestAllUpper()
      {
        Assert.AreEqual(new[] { "Jo", "Nelson", "Jurie" }, Kata.CapMe(new[] { "JO", "NELSON", "JURIE" }));
      }
      
      [Test]
      public void TestMixedCase()
      {
        Assert.AreEqual(new[] { "Jo", "Nelson", "Jurie" }, Kata.CapMe(new[] { "jO", "NelSoN", "jUrIE" }));
      }
      
      [Test]
      public void TestInverseCase()
      {
        Assert.AreEqual(new[] { "Jo", "Nelson", "Jurie" }, Kata.CapMe(new[] { "jO", "nELSON", "jURIE" }));
      }
    }
    
  • Custom User Avatar

    Looks good. :-)

  • Loading more items...