File size: 1,243 Bytes
f91a684 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | import { codingQuestions, type CodingQuestion } from '@/data/codingQuestions';
export const TOTAL_CODING_QUESTIONS = codingQuestions.length;
export const DIFFICULTY_TOTALS = {
Easy: codingQuestions.filter((question) => question.difficulty === 'Easy').length,
Medium: codingQuestions.filter((question) => question.difficulty === 'Medium').length,
Hard: codingQuestions.filter((question) => question.difficulty === 'Hard').length,
} as const;
const rewardByDifficulty: Record<CodingQuestion['difficulty'], number> = {
Easy: 10,
Medium: 25,
Hard: 50,
};
export function getQuestionReward(difficulty: CodingQuestion['difficulty']) {
return rewardByDifficulty[difficulty];
}
export function getQuestionCaseCount(question: CodingQuestion) {
return question.testCases.length + question.hiddenTestCases.length;
}
export function getSolvedDifficultyCounts(solvedQuestionIds: string[]) {
const solvedSet = new Set(solvedQuestionIds);
return codingQuestions.reduce(
(counts, question) => {
if (solvedSet.has(question.id)) {
counts[question.difficulty] += 1;
}
return counts;
},
{
Easy: 0,
Medium: 0,
Hard: 0,
} as Record<CodingQuestion['difficulty'], number>,
);
}
|