Created
March 24, 2017 23:00
-
-
Save saltandvinegarcrisps/56cbafed03d3997ee2a3022176af4863 to your computer and use it in GitHub Desktop.
QuantBet Developer Challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require __DIR__ . '/vendor/autoload.php'; | |
$client = new \GuzzleHttp\Client(); | |
$jar = new \GuzzleHttp\Cookie\CookieJar(); | |
$res = $client->request('GET', 'http://quantbet.com/quiz/dev', [ | |
'cookies' => $jar, | |
]); | |
preg_match_all('#<strong>([0-9]+)</strong>#', $res->getBody()->getContents(), $matches); | |
$gmp = gmp_gcd($matches[1][0], $matches[1][1]); | |
$answer = gmp_strval($gmp); | |
$res = $client->request('POST', 'http://www.quantbet.com/submit', [ | |
'cookies' => $jar, | |
'form_params' => [ | |
'divisor' => $answer, | |
], | |
]); | |
echo $res->getBody()->getContents(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@physicsboy assuming you have composer and php installed, something like