func importStatement(archive *formats.ProblemArchiveReader, problem *model.Problem, statement *Statement) { data, err := archive.ReadFile(statement.Path) PanicIf(err, "Cannot read statement %s: %s", statement.Path, err) getTeX := func(src []byte) model.FormattedText { return model.RawText(src) } if match := statementRe.FindSubmatch(data); match != nil { problem.Statement = getTeX(match[1]) problem.InputFormat = getTeX(match[2]) problem.OutputFormat = getTeX(match[3]) } matches := exampleRe.FindAllSubmatch(data, -1) problem.Samples = make([]model.Sample, len(matches)) for i, match := range matches { problem.Samples[i].Input = string(match[1]) problem.Samples[i].Output = string(match[2]) } }