public function solvableChallenges()
{
if (empty($this->challenges)) {
$this->receiveChallenges();
}
$domains = array_merge((array) $this->domain->getDomain(), $this->subdomains);
foreach ($domains as $domain) {
$this->solvableChallenges[$domain] = [];
foreach ($this->challenges[$domain] as $i => $challenge) {
if ($challenge->solvable()) {
$this->solvableChallenges[$domain][] = $i;
}
}
foreach ($this->solvableChallenges[$domain] as $i => $challenge) {
if (!in_array([$challenge], $this->combinations[$domain])) {
unset($this->solvableChallenges[$domain][$i]);
}
}
if (empty($this->solvableChallenges[$domain])) {
throw new \Exception('We didn\'t receive any challenge we can solve for ' . $domain);
}
}
return $this->solvableChallenges;
}