示例#1
0
文件: 8.php 项目: tomzx/project-euler
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450
';
    $greatestProduct = 0;
    for ($i = 0; $i < strlen($digitSequence) - 5; ++$i) {
        $result = $digitSequence[$i] * $digitSequence[$i + 1] * $digitSequence[$i + 2] * $digitSequence[$i + 3] * $digitSequence[$i + 4];
        if ($greatestProduct < $result) {
            $greatestProduct = $result;
        }
    }
    return $greatestProduct;
}
echo q8();
/**
This function modifies the $endpoint_arr and adds each 
of the statistics found here https://github.com/bio2rdf/bio2rdf-scripts/wiki/Bio2RDF-Dataset-Metrics
to the array
**/
function retrieveStatistics(&$endpoint_arr)
{
    $warn = "";
    if (count($endpoint_arr)) {
        foreach ($endpoint_arr as $name => $details) {
            $endpoint_url = $details["endpoint_url"];
            $graph_uri = $details["graph_uri"];
            if (strlen($endpoint_url) != 0 && strlen($graph_uri) != 0) {
                //now retrieve each of the stats
                //nsns counts
                $nsnsJSON = trim(@file_get_contents(nsQ($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["nsnscounts"] = getNSNSCounts($nsnsJSON);
                //numOfTriples
                $numOfTriplesJson = trim(@file_get_contents(q1($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["triples"] = getNumOfTriples($numOfTriplesJson);
                //get the date
                $dateJson = trim(@file_get_contents(getDatasetDateQuery($endpoint_url)));
                $endpoint_arr[$name]['date'] = getDate2($dateJson);
                //numOfSubjects
                $numOfSubjectsJson = trim(@file_get_contents(q2($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["unique_subjects"] = getNumOfSubjects($numOfSubjectsJson);
                //numOfPredicates
                $numOfPredicatesJson = trim(@file_get_contents(q3($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["unique_predicates"] = getNumOfPredicates($numOfPredicatesJson);
                //numOfUniqueObjects
                $numOfObjectsJson = trim(@file_get_contents(q4($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["unique_objects"] = getNumOfObjects($numOfObjectsJson);
                //numOfTypes
                $numOfTypesJson = trim(@file_get_contents(q5($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["unique_types"] = getNumOfTypes($numOfTypesJson);
                //unique predicate-object links and their frequencies
                $numOfPredObjectFreqsJson = trim(@file_get_contents(q6($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["predicate_object_links"] = getPredObjFreq($numOfPredObjectFreqsJson);
                //unique predicate-literal links and their frequencies
                $numOfUniquePredicateLiteralLinksandFreqsJson = trim(@file_get_contents(q7($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["predicate_literals"] = getPredLitLinks($numOfUniquePredicateLiteralLinksandFreqsJson);
                //unique subject-predicate-unique object links and their frequencies
                $numOfSubjectPredicateUniqueObjectJson = trim(@file_get_contents(q8($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["subject_count_predicate_object_count"] = getSubPredObjLinks($numOfSubjectPredicateUniqueObjectJson);
                //unique subject-predicate-unique literal links and their frequencies
                $numOfSubjectPredUniqueLitJson = trim(@file_get_contents(q9($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["subject_count_predicate_literal_count"] = getSubPredLitLinks($numOfSubjectPredUniqueLitJson);
                //unique subject type-predicate-object type links and their frequencies
                $numOfSubjectTypePredicateObjectJson = trim(@file_get_contents(q10($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["subject_type_predicate_object_type"] = getSubTypePredObjType($numOfSubjectTypePredicateObjectJson);
            } else {
                $warn .= "WARNING :: Endpoint " . $name . " does not have all of required information! (missing either the endpoint or graph uri!)!\n";
            }
        }
        if (strlen($warn)) {
            echo $warn;
        }
    }
    return $endpoint_arr;
}
/**
This function modifies the $endpoint_arr and adds each 
of the statistics found here https://github.com/bio2rdf/bio2rdf-scripts/wiki/Bio2RDF-Dataset-Metrics
to the array
**/
function retrieveStatistics(&$endpoint_arr)
{
    if (count($endpoint_arr)) {
        foreach ($endpoint_arr as $name => $details) {
            $endpoint_url = $details["endpoint_url"];
            $graph_uri = $details["graph_uri"];
            if (strlen($endpoint_url) != 0 && strlen($graph_uri) != 0) {
                //now retrieve each of the stats
                //numOfTriples
                $numOfTriplesJson = trim(@file_get_contents(q1($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["triples"] = getNumOfTriples($numOfTriplesJson);
                //numOfSubjects
                $numOfSubjectsJson = trim(@file_get_contents(q2($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["unique_subjects"] = getNumOfSubjects($numOfSubjectsJson);
                //numOfPredicates
                $numOfPredicatesJson = trim(@file_get_contents(q3($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["unique_predicates"] = getNumOfPredicates($numOfPredicatesJson);
                //numOfUniqueObjects
                $numOfObjectsJson = trim(@file_get_contents(q4($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["unique_objects"] = getNumOfObjects($numOfObjectsJson);
                //numOfTypes
                $numOfTypesJson = trim(@file_get_contents(q5($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["unique_types"] = getNumOfTypes($numOfTypesJson);
                //unique predicate-object links and their frequencies
                $numOfPredObjectFreqsJson = trim(@file_get_contents(q6($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["predicate_object_links"] = getPredObjFreq($numOfPredObjectFreqsJson);
                //unique predicate-literal links and their frequencies
                $numOfUniquePredicateLiteralLinksandFreqsJson = trim(@file_get_contents(q7($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["predicate_literals"] = getPredLitLinks($numOfUniquePredicateLiteralLinksandFreqsJson);
                //unique subject-predicate-unique object links and their frequencies
                $numOfSubjectPredicateUniqueObjectJson = trim(@file_get_contents(q8($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["subject_count_predicate_object_count"] = getSubPredObjLinks($numOfSubjectPredicateUniqueObjectJson);
                //unique subject-predicate-unique literal links and their frequencies
                $numOfSubjectPredUniqueLitJson = trim(@file_get_contents(q9($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["subject_count_predicate_literal_count"] = getSubPredLitLinks($numOfSubjectPredUniqueLitJson);
                //unique subject type-predicate-object type links and their frequencies
                $numOfSubjectTypePredicateObjectJson = trim(@file_get_contents(q10($endpoint_url, $graph_uri)));
                $endpoint_arr[$name]["subject_type_predicate_object_type"] = getSubTypePredObjType($numOfSubjectTypePredicateObjectJson);
            }
        }
    }
    return $endpoint_arr;
}
示例#4
0
	<?php 
q6();
?>
	</div>
	
	<div class="container">
	<h3><a href="#">Query 7 <br>Display the theatre (s) that has the most online ticket sales.</a></h3>
	<?php 
q7();
?>
	</div>
	
	<div class="container">
	<h3><a href="#">Query 8 <br>Display the list of all employees who are on duty on Monday on a specific theatre. Display also their jobs and time table.</a></h3>
	<?php 
q8();
?>
	<div id="theatre"> </div>
	</div>

</div> </div>

<script>
function Q1(str) {
    if (str == "" || str =="0") {
        document.getElementById("threadcontent").innerHTML = "";
        //return;
    } else { 
        if (window.XMLHttpRequest) {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();