Skip to content

Instantly share code, notes, and snippets.

@saltandvinegarcrisps
Created March 24, 2017 23:00
Show Gist options
  • Save saltandvinegarcrisps/56cbafed03d3997ee2a3022176af4863 to your computer and use it in GitHub Desktop.
Save saltandvinegarcrisps/56cbafed03d3997ee2a3022176af4863 to your computer and use it in GitHub Desktop.
QuantBet Developer Challenge
<?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();
@physicsboy
Copy link

How would I run the PHP script to enable me to get the result for the test? - Adam

@saltandvinegarcrisps
Copy link
Author

@physicsboy assuming you have composer and php installed, something like

composer require guzzle/guzzle
php quantbet-dev-challenge.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment