import { SubmissionType , QuestionMapType } from 'types' ; param returns const getQuestionsMap = ( questionList ) : QuestionMapType => { let QuestionMap = { } ; questionList . forEach ( ( attempt , idx ) => { const key = attempt . problem . contestId + "-" + attempt . problem . index ; if ( attempt . verdict === "OK" ) { let value = 0 ; if ( QuestionMap [ key ] && QuestionMap [ key ] . incorrectSubmissions ) value = QuestionMap [ key ] . incorrectSubmissions ; QuestionMap [ key ] = { ... attempt . problem , solved : true , incorrectSubmissions : value , } ; } else { if ( QuestionMap [ key ] === undefined ) QuestionMap [ key ] = { ... attempt . problem , solved : false , incorrectSubmissions : 1 , } ; else { QuestionMap [ key ] . incorrectSubmissions += 1 ; } } } ) ; return QuestionMap ; } ; export default getQuestionsMap ;