• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP solve函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中solve函数的典型用法代码示例。如果您正苦于以下问题:PHP solve函数的具体用法?PHP solve怎么用?PHP solve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了solve函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: calculatePoints

function calculatePoints($formula, $data)
{
    var_dump($formula);
    var_dump($data);
    $formula = str_replace('=', '', $formula);
    if (count($data) == 0) {
        $data['valor_informado'] = 0;
        $data['classif_informado'] = 0;
    }
    if (isset($data['valor_informado'])) {
        $formula = str_replace('valor_informado', $data['valor_informado'], $formula);
    }
    if (isset($data['classif_informado'])) {
        $formula = str_replace('classif_informado', $data['classif_informado'], $formula);
    }
    if (isset($data['decorrente_informado'])) {
        if (count($data['decorrente_informado']) == 1) {
            $formula = str_replace('decorrente_informado', $data['decorrente_informado'][0], $formula);
        } else {
            if (count($data['decorrente_informado']) == 2) {
                $formula = str_replace('decorrente_informado_1', $data['decorrente_informado'][0], $formula);
                $formula = str_replace('decorrente_informado_2', $data['decorrente_informado'][1], $formula);
            }
        }
    } else {
        $formula = str_replace('decorrente_informado_1', '0', $formula);
        $formula = str_replace('decorrente_informado_2', '0', $formula);
        $formula = str_replace('decorrente_informado', '0', $formula);
    }
    var_dump($formula);
    return solve($formula);
    return -1;
}
开发者ID:sidneyaraujomelo,项目名称:sigprog,代码行数:33,代码来源:pointcalc_helper.php


示例2: main

function main()
{
    global $argv, $argc, $TEST;
    // for testing purposes
    if ($argc == 2 and $argv[1] == "test") {
        $stream = fopen('php://memory', 'r+');
        fwrite($stream, $TEST);
        rewind($stream);
        solve($stream);
        return;
    }
    solve(STDIN);
}
开发者ID:kdar,项目名称:challenges,代码行数:13,代码来源:p0020_factorial_digit_sum.php


示例3: solve

function solve($wire)
{
    global $wires;
    if (is_numeric($wire)) {
        return (int) $wire;
    } else {
        if (is_numeric($wires[$wire])) {
            return (int) $wires[$wire];
        } else {
            switch ($wires[$wire]['op']) {
                case 'SET':
                    $value = solve($wires[$wire]['ref']);
                    break;
                case 'NOT':
                    $value = ~solve($wires[$wire]['ref']) & 65535;
                    break;
                case 'AND':
                    $value = solve($wires[$wire]['ref'][0]) & solve($wires[$wire]['ref'][1]);
                    break;
                case 'OR':
                    $value = solve($wires[$wire]['ref'][0]) | solve($wires[$wire]['ref'][1]);
                    break;
                case 'XOR':
                    $value = solve($wires[$wire]['ref'][0]) ^ solve($wires[$wire]['ref'][1]);
                    break;
                case 'RSHIFT':
                    $value = solve($wires[$wire]['ref'][0]) >> solve($wires[$wire]['ref'][1]);
                    break;
                case 'LSHIFT':
                    $value = solve($wires[$wire]['ref'][0]) << solve($wires[$wire]['ref'][1]);
                    break;
            }
            $wires[$wire] = $value;
            return $value;
        }
    }
}
开发者ID:Korko,项目名称:adventofcode,代码行数:37,代码来源:day7_2.php


示例4: solve

<?php

function solve($string)
{
    list($letters, $numbers) = explode("|", $string);
    foreach (explode(" ", $numbers) as $number) {
        echo $letters[$number - 1];
    }
    echo "\n";
}
foreach (file($argv[1]) as $line) {
    if (trim($line) != "") {
        solve(trim($line));
    }
}
开发者ID:eandbsoftware,项目名称:CodeEval-1,代码行数:15,代码来源:FindAWriter.php


示例5: foreach

                    case 'OR':
                        $solved[$var] = $values[0] | $values[1];
                        break;
                    case 'NOT':
                        $solved[$var] = ~$values[0];
                        break;
                    case '->':
                        $solved[$var] = $values[0];
                        break;
                }
                // substitute obtained value
                foreach ($eqs as $var2 => $eq2) {
                    if (isset($solved[$var2])) {
                        continue;
                    }
                    for ($j = 0; $j < count($eqs[$var2]['values']); $j++) {
                        if ($eqs[$var2]['values'][$j] === $var) {
                            $eqs[$var2]['values'][$j] = $solved[$var];
                        }
                    }
                }
            }
        }
    }
    return $solved;
}
$vars = solve($eqs);
printf('ans#7.1: %u' . PHP_EOL, $vars['a']);
$eqs['b']['values'] = [$vars['a']];
$vars = solve($eqs);
printf('ans#7.2: %u' . PHP_EOL, $vars['a']);
开发者ID:zoem,项目名称:adventofcode,代码行数:31,代码来源:day07.php


示例6: login_chk

<?php

include "./config.php";
login_chk();
dbconnect();
if (preg_match('/prob|_|\\.|\\(\\)/i', $_GET[no])) {
    exit("No Hack ~_~");
}
if (preg_match('/\'/i', $_GET[pw])) {
    exit("HeHe");
}
if (preg_match('/\'|substr|ascii|=|or|and| |like|0x/i', $_GET[no])) {
    exit("HeHe");
}
$query = "select id from prob_bugbear where id='guest' and pw='{$_GET[pw]}' and no={$_GET[no]}";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['id']) {
    echo "<h2>Hello {$result[id]}</h2>";
}
$_GET[pw] = addslashes($_GET[pw]);
$query = "select pw from prob_bugbear where id='admin' and pw='{$_GET[pw]}'";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['pw'] && $result['pw'] == $_GET['pw']) {
    solve("bugbear");
}
highlight_file(__FILE__);
开发者ID:webhacking,项目名称:los,代码行数:27,代码来源:bugbear_19ebf8c8106a5323825b5dfa1b07ac1f.php


示例7: login_chk

<?php

include "./config.php";
login_chk();
dbconnect();
if (preg_match('/\'/i', $_GET[pw])) {
    exit("No Hack ~_~");
}
$query = "select id from prob_assassin where pw like '{$_GET[pw]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['id']) {
    echo "<h2>Hello {$result[id]}</h2>";
}
if ($result['id'] == 'admin') {
    solve("assassin");
}
highlight_file(__FILE__);
开发者ID:webhacking,项目名称:los,代码行数:18,代码来源:assassin_14a1fd552c61c60f034879e5d4171373.php


示例8: solve

function solve($aPoss, $nTotal, $aNo)
{
    $aRes = [];
    //Last Cell
    if (count($aPoss) == 1) {
        if ($nTotal < 10 && !in_array($nTotal, $aNo)) {
            $p = array_search($nTotal, $aPoss[0]);
            if ($p !== false) {
                $aRes[] = str_repeat(' ', $p) . $nTotal . str_repeat(' ', count($aPoss[0]) - $p);
            }
        }
        return $aRes;
    }
    $aPossB = $aPoss;
    $aMyPoss = array_shift($aPossB);
    $nMyCnt = count($aMyPoss);
    foreach ($aMyPoss as $i => $n) {
        if ($n >= $nTotal || in_array($n, $aNo)) {
            continue;
        }
        $aMyNo = $aNo;
        $aMyNo[] = $n;
        $str = str_repeat(' ', $i) . $n . str_repeat(' ', $nMyCnt - $i);
        $aNewPoss = solve($aPossB, $nTotal - $n, $aMyNo);
        foreach ($aNewPoss as $cP) {
            $aRes[] = $str . $cP;
        }
    }
    return $aRes;
}
开发者ID:barrygilbert,项目名称:puzzle-solvers,代码行数:30,代码来源:line-solver.php


示例9: fopen

<?php

$inputFile = $_SERVER['argv'][1];
$outputFile = $inputFile . '.out';
$fin = fopen($inputFile, 'r');
$fout = fopen($outputFile, 'w+');
$cases = fgets($fin);
$case = 0;
while (!feof($fin)) {
    $case++;
    $in = fgets($fin);
    if ($case > $cases) {
        break;
    }
    list($combs, $opps, $inv) = parse($in);
    $out = solve($combs, $opps, $inv);
    $res = sprintf("Case #%d: %s\n", $case, format($out));
    fputs($fout, $res);
    echo "{$res}";
}
function parse($in)
{
    $in = explode(' ', $in);
    $numComb = (int) $in[0];
    $combs = array_slice($in, 1, $numComb);
    $in = array_slice($in, $numComb + 1);
    $numOpp = (int) $in[0];
    $opps = array_slice($in, 1, $numOpp);
    $in = array_slice($in, $numOpp + 1);
    $numInv = (int) $in[0];
    $inv = array();
开发者ID:blerou,项目名称:gcj,代码行数:31,代码来源:b.php


示例10: next_step

function next_step($new_position, $val, $status)
{
    $answer = array();
    if ($status[$new_position] == 1) {
        // new_positionはすでに踏んでるので調査終了
        //$answer[][0] = 999;
    } else {
        $status[$new_position] = 1;
        if (!in_array(0, $status)) {
            // new_positionでゴール
            $answer[][0] = $new_position;
        }
        // new_positionではゴールも終了もしないで調査続行
        $answer = array_merge($answer, solve($new_position, $val, $status));
    }
    return $answer;
}
开发者ID:kidaa,项目名称:ff_puzzle,代码行数:17,代码来源:solve.php


示例11: login_chk

<?php

include "./config.php";
login_chk();
dbconnect();
if (strlen($_GET[shit]) > 1) {
    exit("No Hack ~_~");
}
if (preg_match('/ |\\n|\\r|\\t/i', $_GET[shit])) {
    exit("HeHe");
}
$query = "select 1234 from{$_GET[shit]}prob_giant where 1";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysql_fetch_array(mysql_query($query));
if ($result[1234]) {
    solve("giant");
}
highlight_file(__FILE__);
开发者ID:webhacking,项目名称:los,代码行数:18,代码来源:giant_18a08c3be1d1753de0cb157703f75a5e.php


示例12: login_chk

<?php

include "./config.php";
login_chk();
dbconnect();
if (preg_match('/_|\\.|\\(\\)/i', $_GET[limit])) {
    exit("No Hack ~_~");
}
if (preg_match('/union|where|hellfire/i', $_GET[limit])) {
    exit("hehe");
}
if ($_GET[limit]) {
    $limit = $_GET[limit];
} else {
    $limit = 1;
}
$query = "select id from probevilwizard where id='admin' limit {$limit}";
$result = @mysql_fetch_array(mysql_query($query));
if (mysql_error()) {
    exit;
}
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$_GET[pw] = addslashes($_GET[pw]);
$query = "select pw from probevilwizard where id='admin' and pw='{$_GET[pw]}'";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['pw'] && $result['pw'] == $_GET['pw']) {
    solve("evil_wizard");
}
highlight_file(__FILE__);
开发者ID:webhacking,项目名称:los,代码行数:29,代码来源:evil_wizard_32e3d35835aa4e039348712fb75169ad.php


示例13: login_chk

<?php

include "./config.php";
login_chk();
dbconnect();
if (preg_match('/_|\\.|\\(\\)/i', $_GET[limit])) {
    exit("No Hack ~_~");
}
if (preg_match('/union|where|evilwizard/i', $_GET[limit])) {
    exit("hehe");
}
if ($_GET[limit]) {
    $limit = $_GET[limit];
} else {
    $limit = 1;
}
$query = "select id from probhellfire where id='admin' limit {$limit}";
$result = @mysql_fetch_array(mysql_query($query));
if (mysql_error()) {
    exit(mysql_error());
}
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$_GET[pw] = addslashes($_GET[pw]);
$query = "select pw from probhellfire where id='admin' and pw='{$_GET[pw]}'";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['pw'] && $result['pw'] == $_GET['pw']) {
    solve("hell_fire");
}
highlight_file(__FILE__);
开发者ID:webhacking,项目名称:los,代码行数:29,代码来源:hell_fire_309d5f471fbdd4722d221835380bb805.php


示例14: login_chk

<?php

include "./config.php";
login_chk();
dbconnect();
if (preg_match('/prob|_|\\.|\\(\\)/i', $_GET[no])) {
    exit("No Hack ~_~");
}
if (preg_match('/\'|\\"|\\`/i', $_GET[no])) {
    exit("No Quotes ~_~");
}
$query = "select id from prob_goblin where id='guest' and no={$_GET[no]}";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['id']) {
    echo "<h2>Hello {$result[id]}</h2>";
}
if ($result['id'] == 'admin') {
    solve("goblin");
}
highlight_file(__FILE__);
开发者ID:webhacking,项目名称:los,代码行数:21,代码来源:goblin_e5afb87a6716708e3af46a849517afdc.php


示例15: login_chk

<?php

include "./config.php";
login_chk();
dbconnect();
if (preg_match('/prob|_|\\.|\\(\\)/i', $_GET[id])) {
    exit("No Hack ~_~");
}
// do not try to attack another table, database!
if (preg_match('/prob|_|\\.|\\(\\)/i', $_GET[pw])) {
    exit("No Hack ~_~");
}
$query = "select id from prob_gremlin where id='{$_GET[id]}' and pw='{$_GET[pw]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['id']) {
    solve("gremlin");
}
highlight_file(__FILE__);
开发者ID:webhacking,项目名称:los,代码行数:19,代码来源:gremlin_280c5552de8b681110e9287421b834fd.php


示例16: array_sum

    return array_sum(array_map($work, $vs));
}
function solve()
{
    fscanf(STDIN, '%d%d', $b, $n);
    $ms = array_map('intval', explode(' ', fgets(STDIN)));
    $x = 0;
    $y = 100000000000001;
    while ($x < $y) {
        $z = (int) (($x + $y) / 2);
        if (simulate($ms, $z) < $n) {
            $x = $z + 1;
        } else {
            $y = $z;
        }
    }
    $n_ = $x ? simulate($ms, $x - 1) : 0;
    foreach ($ms as $i => $m) {
        if ($x % $m == 0) {
            $n_ += 1;
            if ($n_ == $n) {
                return $i + 1;
            }
        }
    }
    return -1;
}
fscanf(STDIN, '%d', $cases);
for ($num = 1; $num <= $cases; $num++) {
    printf("Case #%d: %d\n", $num, solve());
}
开发者ID:vrnss,项目名称:competitions,代码行数:31,代码来源:haircut.php


示例17: login_chk

<?php

include "./config.php";
login_chk();
dbconnect();
if (preg_match('/prob|_|\\.|\\(\\)/i', $_GET[pw])) {
    exit("No Hack ~_~");
}
if (preg_match('/ /i', $_GET[pw])) {
    exit("No whitespace ~_~");
}
$query = "select id from prob_wolfman where id='guest' and pw='{$_GET[pw]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['id']) {
    echo "<h2>Hello {$result[id]}</h2>";
}
if ($result['id'] == 'admin') {
    solve("wolfman");
}
highlight_file(__FILE__);
开发者ID:webhacking,项目名称:los,代码行数:21,代码来源:wolfman_4fdc56b75971e41981e3d1e2fbe9b7f7.php


示例18: login_chk

<?php

include "./config.php";
login_chk();
dbconnect();
if (preg_match('/prob|_|\\.|\\(\\)/i', $_GET[pw])) {
    exit("No Hack ~_~");
}
if (preg_match('/or|and/i', $_GET[pw])) {
    exit("HeHe");
}
$query = "select id from prob_orge where id='guest' and pw='{$_GET[pw]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['id']) {
    echo "<h2>Hello {$result[id]}</h2>";
}
$_GET[pw] = addslashes($_GET[pw]);
$query = "select pw from prob_orge where id='admin' and pw='{$_GET[pw]}'";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['pw'] && $result['pw'] == $_GET['pw']) {
    solve("orge");
}
highlight_file(__FILE__);
开发者ID:webhacking,项目名称:los,代码行数:24,代码来源:orge_bad2f25db233a7542be75844e314e9f3.php


示例19: login_chk

<?php

include "./config.php";
login_chk();
dbconnect();
if (preg_match('/\'/i', $_GET[id])) {
    exit("No Hack ~_~");
}
$_GET[id] = str_replace("admin", "", $_GET[id]);
$query = "select id from prob_vampire where id='{$_GET[id]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysql_fetch_array(mysql_query($query));
if ($result['id'] == 'admin') {
    solve("vampire");
}
highlight_file(__FILE__);
开发者ID:webhacking,项目名称:los,代码行数:16,代码来源:vampire_e3f1ef853da067db37f342f3a1881156.php


示例20: reverseOf

<?php

function reverseOf($number)
{
    $result = 0;
    while ($number > 0) {
        $lastDigit = $number % 10;
        $result = 10 * $result + $lastDigit;
        $number = ($number - $lastDigit) / 10;
    }
    return $result;
}
function solve($number)
{
    $it = 0;
    $reverse = reverseOf($number);
    while ($number != $reverse) {
        $number += $reverse;
        $reverse = reverseOf($number);
        $it++;
    }
    return "{$it} {$number}";
}
foreach (file($argv[1]) as $line) {
    $number = trim($line);
    echo solve($number) . "\n";
}
开发者ID:eandbsoftware,项目名称:CodeEval-1,代码行数:27,代码来源:ReverseAndAdd.php



注:本文中的solve函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP somaParcela函数代码示例发布时间:2022-05-23
下一篇:
PHP solution函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap