| 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>, |
| ); |
| } |
|
|