Bladeren bron

Removing PHP cause God knows that i'm not strong enough

Vinicius Teshima 1 maand geleden
bovenliggende
commit
6bd54cdf74
3 gewijzigde bestanden met toevoegingen van 0 en 99 verwijderingen
  1. 0 64
      PHP/1200.php
  2. 0 31
      PHP/2315.php
  3. 0 4
      PHP/build.sh

+ 0 - 64
PHP/1200.php

@@ -1,64 +0,0 @@
-<?php
-# 1200. Minimum Absolute Difference
-
-# Failed
-class Solution {
-
-    /**
-     * @param Integer[] $arr
-     * @return Integer[][]
-     */
-    function minimumAbsDifference($arr) {
-        $abs_arr = array_map('abs', $arr);
-        asort($abs_arr);
-        $abs_arr_keys = array_keys($abs_arr);
-
-        $matchs = [];
-
-        $min_diff = 99999999999;
-
-        $limit = count($abs_arr) - 1;
-        $f = current($abs_arr);
-        for ( $i = 0; $i < $limit; ++$i) {
-            $s = next($abs_arr);
-            $diff = $s - $f;
-            $f = $s;
-
-            $fo = $arr[$abs_arr_keys[$i]];
-            $so = $arr[$abs_arr_keys[$i+1]];
-            if ( $fo >= $so ) { continue; }
-
-            if ( $diff < $min_diff ) { $min_diff = $diff; }
-            if ( ! array_key_exists($diff, $matchs) ) {
-                $matchs[$diff] = [[$i, $i+1]]; continue;
-            }
-            array_push($matchs[$diff], [$i, $i+1]);
-        }
-
-        $res = [];
-
-        foreach ( $matchs[$min_diff] as $t ) {
-            $f = $arr[$abs_arr_keys[$t[0]]];
-            $s = $arr[$abs_arr_keys[$t[1]]];
-            array_push($res, [$f, $s]);
-        }
-
-        return $res;
-    }
-}
-
-function main() {
-    function r($a, $exp) {
-        $S = new Solution;
-        $r = $S->minimumAbsDifference($a);
-        $str_a   = json_encode($a);
-        $str_r   = json_encode($r);
-        $str_exp = json_encode($exp);
-        echo "Solution().minimumAbsDifference(\"$str_a\") = $str_r | exp: $str_exp\n";
-    }
-    r([4,2,1,3], [[1,2],[2,3],[3,4]]);
-    r([1,3,6,10,15], [[1,3]]);
-    r([3,8,-10,23,19,-4,-14,27], [[-14,-10],[19,23],[23,27]]);
-}
-
-main();

+ 0 - 31
PHP/2315.php

@@ -1,31 +0,0 @@
-<?php
-
-class Solution {
-    /**
-     * @param String $s
-     * @return Integer
-     */
-    function countAsterisks($s) {
-        $in = false;
-        $count = 0;
-        foreach ( str_split($s) as $c ) {
-            if ( $c == '|' ) { $in = !$in; }
-            if ( $in == false && $c == '*' ) { ++$count; }
-        }
-        return $count;
-    }
-}
-
-function main() {
-    function r($s) {
-        $S = new Solution;
-        $t = $S->countAsterisks($s);
-        echo "Solution().countAsterisks(\"$s\") = $t\n";
-    }
-
-    r("l|*e*et|c**o|*de|");
-    r("iamprogrammer");
-    r("yo|uar|e**|b|e***au|tifu|l");
-}
-
-main();

+ 0 - 4
PHP/build.sh

@@ -1,4 +0,0 @@
-newest_file="$(find ./ -type f -printf "%T@ %p\n" | sort -n | cut -d' ' -f 2- | tail -n 1)"
-
-set -x
-php $newest_file