Compare commits

...

2 Commits

Author SHA1 Message Date
29cfd35fe9 Added PHPUnit 2025-06-17 13:21:13 +00:00
f622721892 Vendor exclode 2025-04-04 12:28:43 +00:00
7 changed files with 29 additions and 7 deletions

View File

@ -1 +0,0 @@
vendor/

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
output/
.*.cache/
vendor/
tools/

4
.phive/phars.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpunit" version="^12.2.2" installed="12.2.2" location="./tools/phpunit" copy="false"/>
</phive>

View File

@ -0,0 +1,9 @@
title: Multiplication table
desc: Building a multiplication table in C
solutions:
solve.c:
desc: ANSI C solution (Tested with TCC)
language: c

View File

@ -1,7 +1,7 @@
title: Sieve of Eratosthenes
url: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
desc:Generate primes from 2 to 100
desc: Generate primes from 2 to 100
solution: Do i need to say more
solutions:

View File

@ -8,12 +8,12 @@ class Numerical
{
public static function isPandigital(int $input): bool
{
return self::isDigitsPresent($input, [49 => 1, 50 => 1, 51 => 1, 52 => 1, 53 => 1, 54 => 1, 55 => 1, 56 => 1, 57 => 1]);
return self::isDigitsPresent($input, [0x31 => 1, 0x32 => 1, 0x33 => 1, 0x34 => 1, 0x35 => 1, 0x36 => 1, 0x37 => 1, 0x38 => 1, 0x39 => 1]);
}
public static function isPandigitalWithZero(int $input): bool
{
return self::isDigitsPresent($input, [48 => 0, 49 => 1, 50 => 1, 51 => 1, 52 => 1, 53 => 1, 54 => 1, 55 => 1, 56 => 1, 57 => 1]);
return self::isDigitsPresent($input, [0x30 => 1, 0x31 => 1, 0x32 => 1, 0x33 => 1, 0x34 => 1, 0x35 => 1, 0x36 => 1, 0x37 => 1, 0x38 => 1, 0x39 => 1]);
}
private static function isDigitsPresent(int $input, array $count): bool

View File

@ -12,12 +12,20 @@ use CodingTests\Prime;
#[CoversClass(Prime::class)]
final class PrimeTest extends \PHPUnit\Framework\TestCase
{
public function isPandigital(): void
static $primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97];
public function testisPrime(): void
{
$primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97];
for ($test = -100; $test <= 100; $test++) {
$ret = Prime::isPrime($test);
$this->assertEquals(in_array($test, $primes), $ret, "Testing $test");
$this->assertEquals(in_array($test, self::$primes), $ret, "Testing $test");
}
}
public function testis_prime(): void
{
for ($test = -100; $test <= 100; $test++) {
$ret = Prime::isPrime($test);
$this->assertEquals(in_array($test, self::$primes), $ret, "Testing $test");
}
}
}