/** * * User: Shikhar Subedi * Date: 9/26/14 * Time: 3:58 PM * * for more information : www.spoj.com/problems/ARITH * problem code :ARITH * * * */ function spojARITH() { $stringArray = takeInput(); foreach ($stringArray as $string) { displayArith($string); } }
/** * reverser polish notation * Input: * 3 * (a+(b*c)) * ((a+b)*(z+x)) * ((a+t)*((b+(a+c))^(c+d))) * a-b+c-d * * Output: * abc*+ * ab+zx+* * at+bac++cd+^* * ab-cd-+ * * * Author : Shikhar Subedi * * Problem code :ONP * * */ function spojONP() { $stringArray = takeInput(); foreach ($stringArray as $string) { $outputStack = reversePolish($string); printOutput($outputStack); } }
/** * User: Shikhar Subedi * Date: 9/16/14 * Time: 10:42 AM * detected the next smallest palindrome greater than the given number * Problem code : PALIN * Input: * 2 * 808 * 2133 * Output: * 818 * 2222 * */ function spojPALIN() { $stringArray = takeInput(); foreach ($stringArray as $string) { if (strlen($string) == 1) { echo "11" . PHP_EOL; continue; } $firstResult = firstPalindrome($string); $output = secondPalindrome($firstResult, $string); echo $output . PHP_EOL; } }