-
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)); } } }
Output:
-
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));
- }
}- }
- }
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}