diff --git a/README.md b/README.md index 8c24549..d25f02e 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,11 @@ export PATH=$(pwd)/bin:$PATH Each tool specifies mandatory config variables. It is not necessary to fill in the others. -Put your config file in `~/.config/algolymp/config.json`. If you are using Windows, put it in `%APPDATA%/algolymp/config.json`. +Put your config file in OS specific config directory: + +- `~/.config/algolymp/config.json` on Linux; +- `~/Library/Application Support/algolymp/config.json` on Mac OS; +- `%APPDATA%/algolymp/config.json` on Windows. Here is an example of a fully filled config: @@ -515,11 +519,12 @@ Valeria supports several textable types. - `universal` - Moscow summer olympiad school format. Works both in PDF and HTML. - `moscow` - Moscow olympiads format. Works both in PDF and HTML if no variables are passed, otherwise works only in PDF. +- `kaluga` - Kaluga town olympiad format. Works both in PDF and HTML. ### Flags - `-i` - problem id (required) - `-v` - print valuer.cfg in stderr -- `-t` - textable type (universal | moscow, default: universal) +- `-t` - textable type (universal | moscow | kaluga, default: universal) - `-c` - variables list, useful for some textables (default: nil) ### Config @@ -535,6 +540,7 @@ valeria -i 318511 > scoring.tex valeria -i 318882 | bat -l tex valeria -i 285375 -t moscow valeria -i 285375 -t moscow -c n -c m -c k +valeria -i 396578 -t kaluga ``` ![valeria logo](https://algolymp.ru/static/img/valeria.png) diff --git a/cmd/valeria/main.go b/cmd/valeria/main.go index fc8a9fa..58ba8fa 100644 --- a/cmd/valeria/main.go +++ b/cmd/valeria/main.go @@ -16,6 +16,7 @@ import ( const ( universalTag = "universal" moscowTag = "moscow" + kalugaTag = "kaluga" ) var ( @@ -35,6 +36,7 @@ func main() { tableTyp := parser.Selector("t", "textable-type", []string{ universalTag, moscowTag, + kalugaTag, }, &argparse.Options{ Required: false, Default: universalTag, @@ -60,6 +62,8 @@ func main() { table = new(textables.UniversalTable) case moscowTag: table = textables.NewMoscowTable(*vars) + case kalugaTag: + table = new(textables.KalugaTable) } if table == nil { logrus.WithError(ErrUnknownTexTable).Fatal("failed to get textable") diff --git a/polygon/valeria/textables/kaluga.go b/polygon/valeria/textables/kaluga.go new file mode 100644 index 0000000..88af9f0 --- /dev/null +++ b/polygon/valeria/textables/kaluga.go @@ -0,0 +1,46 @@ +package textables + +import ( + "fmt" + "strings" +) + +// Works both in HTML and PDF render. +type KalugaTable struct { + groups []string +} + +var _ Table = &KalugaTable{} + +func (t *KalugaTable) AddGroup(info GroupInfo) { + var limits string + switch info.Type { + case Group0: + return + case GroupLast: + limits = "Ограничения из условия" + case GroupRegular: + } + row := fmt.Sprintf("%s & %d & %s \\\\ \\hline", + info.Name, + info.Score, + limits, + ) + t.groups = append(t.groups, row) +} + +func (t *KalugaTable) String() string { + table := []string{ + "\\begin{center}", + "\\begin{tabular}{|c|c|c|}", + "\\hline", + "\\bf{Подзадача} &", + "\\bf{Баллы} &", + "\\bf{Ограничения}", + "\\\\ \\hline", + } + table = append(table, t.groups...) + table = append(table, "\\end{tabular}", "\\end{center}") + + return strings.Join(table, "\n") +}