Move History

Rooted by: Are there three
Fork Selected
  • Description

    If x contains the digit 3 return true, otherwise return false

    Code
    using System.Linq;
    
    public class Kumite {
      public static bool IsThree(int x) =>
        $"{x}".Any(x => x == '3');
    }
    Test Cases
    using NUnit.Framework;
    
    namespace Tests {
      
      [TestFixture]
      class TestsClass {
      
        [Test]
        public void Tests() {
          Assert.IsFalse(Kumite.IsThree(525458));
          Assert.IsFalse(Kumite.IsThree(2222));
          
          Assert.IsTrue(Kumite.IsThree(354523));
          Assert.IsTrue(Kumite.IsThree(748504231));
        }
      }
      
      
    }
  • Code
    • fn solution(x: i32) -> bool {
    • x.to_string().chars().any(|x| x == '3')
    • using System.Linq;
    • public class Kumite {
    • public static bool IsThree(int x) =>
    • $"{x}".Any(x => x == '3');
    • }
    Test Cases
    • // Add your tests here.
    • // See https://doc.rust-lang.org/stable/rust-by-example/testing/unit_testing.html
    • using NUnit.Framework;
    • #[cfg(test)]
    • mod tests {
    • use super::*;
    • #[test]
    • fn test_add() {
    • assert_eq!(solution(525458), false);
    • assert_eq!(solution(2222), false);
    • assert_eq!(solution(354523), true)
    • namespace Tests {
    • [TestFixture]
    • class TestsClass {
    • [Test]
    • public void Tests() {
    • Assert.IsFalse(Kumite.IsThree(525458));
    • Assert.IsFalse(Kumite.IsThree(2222));
    • Assert.IsTrue(Kumite.IsThree(354523));
    • Assert.IsTrue(Kumite.IsThree(748504231));
    • }
    • }
    • }
    • }