function GetProblemLetter($contest_id, $problem_id) { if ($contest_id < 0) { $contest_id = $_SESSION['WT_contest_id']; } if (isset($this->cache['letters'][$contest_id][$problem_id])) { return $this->cache['letters'][$contest_id][$problem_id]; } $this->UpdateTasksCache($contest_id, $problem_id); $arr = $this->cache['tasks'][$contest_id]; $n = count($arr); for ($i = 0; $i < $n; $i++) { if ($arr[$i]['problem_id'] == $problem_id) { $res = core_alpha($arr[$i]['letter']); } } $this->cache['letters'][$contest_id][$problem_id] = $res; return $res; }
function core_alpha($a) { $arr = " ABCDEFGHIJKLMNOPQRSTUVWXYZ"; if ($a < 27) { return $arr[$a]; } else { $b = $a; $tmp = 0; while ($b > 0) { $tmp++; $b -= 26; } return core_alpha($tmp - 1) . $arr[$b + 26]; } }