Skip to content

Commit

Permalink
chore: add kaluga textable for valeria (#48)
Browse files Browse the repository at this point in the history
* chore: add kaluga textable for valeria

* docs: fix macos config dir

* docs: add kaluga

* docs: add more kaluga
  • Loading branch information
Gornak40 authored Nov 2, 2024
1 parent 2b95bf6 commit 1eb6583
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions cmd/valeria/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
const (
universalTag = "universal"
moscowTag = "moscow"
kalugaTag = "kaluga"
)

var (
Expand All @@ -35,6 +36,7 @@ func main() {
tableTyp := parser.Selector("t", "textable-type", []string{
universalTag,
moscowTag,
kalugaTag,
}, &argparse.Options{
Required: false,
Default: universalTag,
Expand All @@ -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")
Expand Down
46 changes: 46 additions & 0 deletions polygon/valeria/textables/kaluga.go
Original file line number Diff line number Diff line change
@@ -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")
}

0 comments on commit 1eb6583

Please sign in to comment.