Skip to content

Commit

Permalink
Atualização problemas resolvidos
Browse files Browse the repository at this point in the history
  • Loading branch information
lrlucena committed Dec 15, 2024
1 parent c8e4e48 commit 437d769
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 49 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
/src/*/*[a-z].poti
/src/*/*.txt
/*.poti
/src/*.poti
/bin/*.poti
.metals/
.metals/*
.vscode/launch.json
/*.scala
/src/*/*.scala
/src/*.scala
*.java
*.py
/*.sh
Expand All @@ -16,3 +19,4 @@
/null/
/.vscode/
*.bak
.*/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Join the chat at https://gitter.im/potigol/Potigol](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/potigol/Potigol?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Follow us](https://img.shields.io/twitter/follow/potigol.svg?style=social)](http://twitter.com/potigol)
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/potigol/beecrowd)
[![Soluções](https://img.shields.io/badge/Problemas%20Resolvidos-828-blue)](https://github.com/potigol/beecrowd/commits/master)
[![Soluções](https://img.shields.io/badge/Problemas%20Resolvidos-834-blue)](https://github.com/potigol/beecrowd/commits/master)

<!-- a href="https://potigol.github.io/docs/hacktoberfest"><img src="https://hacktoberfest.digitalocean.com/_nuxt/img/logo-hacktoberfest-full.f42e3b1.svg" width=250></a -->

Expand Down
84 changes: 48 additions & 36 deletions bin/Build.scala
Original file line number Diff line number Diff line change
@@ -1,28 +1,47 @@
import java.io.PrintWriter
import java.io.File

case class Problem(number: Int, name: String, category: String):
override def toString = s"${number}\t${name}\t${category}"
case class Problem(number: Int, name: String, category: String)
// override def toString: String = s"${number}\t${name}\t${category}"

case class Category(name: String):
var problems: List[Problem] = Nil

case class Competition(name: String):
var years: List[Year] = Nil

case class Year(year: Int):
var rounds: List[Round] = Nil

case class Round(name: String):
var problems: List[Problem] = Nil

object Text:
def unsolved(p: Problem, showCategory: Boolean = true): String =
s"- [ ] [${p.number}](${prefix}${p.number}.html) - ${p.name}${if(showCategory) s" *${p.category}*" else ""}"
def solved(p: Problem, showCategory: Boolean = true): String =
s"- [x] [${p.number}](${prefix}${p.number}.html) - [${p.name}](${code}/${dir(p.number)}/${p.number}.${extension})${if(showCategory) s" *${p.category}*" else ""}"
def absent: String = s"- [ ] ~~xxxx~~"

// lowercase letters of a string
def clean(s: String) = s.toLowerCase.filter(p => p >= 'a' && p <= 'z')
def clean(s: String): String = s.toLowerCase.filter(p => p >= 'a' && p <= 'z')

// Checks whether a problem file exists
def exists(extension: String, path: String = "../src")(problem: Int) =
def exists(extension: String, path: String = "../src")(problem: Int): Boolean =
File(s"${path}/${dir(problem)}/${problem}.${extension}").exists

// Folder of a problem
def dir(problem: Int) = s"${problem / 100 * 100}"
def dir(problem: Int): String = s"${problem / 100 * 100}"

// Save the content to a file
def save(name: String, title: String, content: String) = new PrintWriter(name) {
def save(name: String, title: String, content: String): Unit = new PrintWriter(name) {
write(s"# ${title}\n\n${content}")
close
}

// Get the list of problems
def getContest(file: String): Map[Int, List[Int]] =
io.Source.fromFile(file).getLines().map { a =>
getLines(file).map { a =>
val b = a.split(" ")
val c = b(1).split(",")
val d = for c1 <- c
Expand All @@ -36,7 +55,7 @@ def listContest(contest: Map[Int, List[Int]], year: Int, problems: Map[Int, Prob
}.mkString("\n")

// Generates a problem list for a two phases competition
def duasfases(problems: Map[Int, Problem], c1: String, c2: String, file: String, title: String) =
def duasfases(problems: Map[Int, Problem], c1: String, c2: String, file: String, title: String): Unit =
val contest1 = getContest(c1)
val contest2 = getContest(c2)
val s = for year <- contest2.keys.toList.sorted.reverse yield
Expand All @@ -57,7 +76,7 @@ def duasfases(problems: Map[Int, Problem], c1: String, c2: String, file: String,
save(file, s"$title ($solved / $total)", str)

// Generates a problem list for a one phase competition
def umafase(problems: Map[Int, Problem], c1: String, file: String, title: String) =
def umafase(problems: Map[Int, Problem], c1: String, file: String, title: String): Unit =
val contest = getContest(c1)
var s = ""
for year <- contest.keys.toList.sorted.reverse do
Expand All @@ -69,17 +88,13 @@ def umafase(problems: Map[Int, Problem], c1: String, file: String, title: String
save(file, s"$title ($solved / $total)", s)

// One line for each problem
def line(problem: Option[Problem], showCategory: Boolean = true) = problem match
case None => s"- [ ] ~~xxxx~~"
// case Some(p) if p.category == "SQL" =>
// s"- [ ] ~~${p.number}~~ - *${p.category}*"
case Some(p) if (exists(extension)(p.number)) =>
s"- [x] [${p.number}](${prefix}${p.number}.html) - [${p.name}](${code}/${dir(p.number)}/${p.number}.${extension}) *${if(showCategory) p.category else " "}*"
case Some(p) =>
s"- [ ] [${p.number}](${prefix}${p.number}.html) - ${p.name} *${if(showCategory) p.category else " "}*"

val config = {
for l <- io.Source.fromFile("config.txt").getLines()
def line(problem: Option[Problem], showCategory: Boolean = true): String = problem match
case None => Text.absent
case Some(p) if (exists(extension)(p.number)) => Text.solved(p)
case Some(p) => Text.unsolved(p)

val config: Map[String, String] = {
for l <- getLines("config.txt")
List(a, b) = l.split("=").toList
yield (a, b)
}.toMap
Expand All @@ -88,7 +103,7 @@ val code = config("code")
val extension = config("extension")

// Lista Geral
def listaGeral(paginaFinal: Int, problems: Map[Int, Problem], path: String = "../src/") =
def listaGeral(paginaFinal: Int, problems: Map[Int, Problem], path: String = "../src/"): Unit =
for i <- 10 to paginaFinal do
val d = for j <- 0 to 99
x = i * 100 + j
Expand All @@ -100,27 +115,21 @@ def listaGeral(paginaFinal: Int, problems: Map[Int, Problem], path: String = "..
save(s"${path}${dir(i*100)}/README.md", s"Problemas ${dir(i*100).replace("-", " a ")} (${solved * 100 / total}%)", s)

// Lista por categoria
def listaCategoria(problems: Map[Int, Problem], path: String = "../categorias/") =
def listaCategoria(problems: Map[Int, Problem], path: String = "../categorias/"): Unit =
val problemsByCategory = problems.values.toList.groupBy(_.category)
val categories = problemsByCategory.keySet.toList
for d <- categories do
val bd = problemsByCategory(d)
var count = 0

val (f, g) = bd.partition(p => exists(extension)(p.number))
val resolvidos = f.map {p =>
s"- [x] [${p.number}](${prefix}${p.number}.html) - [${p.name}](${code}/${dir(p.number)}/${p.number}.${extension})"
}.sorted

val naoresolvidos = g.map {p =>
s"- [ ] [${p.number}](${prefix}${p.number}.html) - ${p.name}"
}.sorted
val resolvidos = f.map {p => Text.solved(p, false)}.sorted
val naoresolvidos = g.map {p => Text.unsolved(p, false)}.sorted

val h = ("\n\n## Problemas resolvidos\n" :: resolvidos).mkString("\n") +
("\n\n## Problemas não resolvidos\n" :: naoresolvidos).mkString("\n")
save(s"${path}${clean(d)}.md", s"${d} (${resolvidos.length} / ${bd.length})", h)

def save(problems: Map[Int, Problem], files: String*) = {
def save(problems: Map[Int, Problem], files: String*): Map[Int, Problem] = {
val contest = files.map(getContest)
.foldLeft(Map[Int, List[Int]]())(_ ++ _)
.values
Expand All @@ -129,23 +138,26 @@ def save(problems: Map[Int, Problem], files: String*) = {
}.toMap

def problemList(file: String): Map[Int, Problem] =
val problemList1 = io.Source.fromFile(file).getLines()
val problemList1 = getLines(file)
problemList1.map { a =>
val x = a.split("\\t")
Problem(x(0).toInt, x(1), x(2))
}.map {p => p.number -> p}.toMap

def getLines(file: String) = io.Source.fromFile(file).getLines()

// Principal
@main def main() =
val problems = problemList("problems.txt")
listaGeral(34, problems)
@main def main(): Unit =
val problems: Map[Int, Problem] = problemList("problems.txt")
val categories: Map[Category, Iterable[Problem]] =
problems.values.groupBy(_.category).map((a,b) => Category(a) -> b.toList)
listaGeral(35, problems)
listaCategoria(problems)
listaCategoria(save(problems, "obi.txt"), "../competicoes/obi/")
listaCategoria(save(problems, "maratona1.txt", "maratona2.txt"), "../competicoes/maratona/")
listaCategoria(save(problems, "olip.txt"), "../competicoes/outras/olip/")
listaCategoria(save(problems, "maratona0.txt"), "../competicoes/outras/fasezero/")


// Lista por competição
duasfases(problems, "maratona1.txt", "maratona2.txt", "../competicoes/maratona/README.md", "Maratona de Programação")
umafase(problems, "obi.txt", "../competicoes/obi/README.md", "Olimpíada de Informática")
Expand Down
4 changes: 2 additions & 2 deletions categorias/adhoc.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Ad-Hoc (264 / 892)
# Ad-Hoc (265 / 892)



Expand Down Expand Up @@ -86,6 +86,7 @@
- [x] [1890](https://www.beecrowd.com.br/repository/UOJ_1890.html) - [Emplacando os Tuk-tuks](https://github.com/potigol/beecrowd/blob/master/src/1800/1890.poti)
- [x] [1893](https://www.beecrowd.com.br/repository/UOJ_1893.html) - [Fases da Lua](https://github.com/potigol/beecrowd/blob/master/src/1800/1893.poti)
- [x] [1901](https://www.beecrowd.com.br/repository/UOJ_1901.html) - [Borboletas](https://github.com/potigol/beecrowd/blob/master/src/1900/1901.poti)
- [x] [1919](https://www.beecrowd.com.br/repository/UOJ_1919.html) - [Ajude Nhonho](https://github.com/potigol/beecrowd/blob/master/src/1900/1919.poti)
- [x] [1936](https://www.beecrowd.com.br/repository/UOJ_1936.html) - [Fatorial](https://github.com/potigol/beecrowd/blob/master/src/1900/1936.poti)
- [x] [1943](https://www.beecrowd.com.br/repository/UOJ_1943.html) - [Top N](https://github.com/potigol/beecrowd/blob/master/src/1900/1943.poti)
- [x] [1953](https://www.beecrowd.com.br/repository/UOJ_1953.html) - [Roberto e a Sala Desenfreada](https://github.com/potigol/beecrowd/blob/master/src/1900/1953.poti)
Expand Down Expand Up @@ -404,7 +405,6 @@
- [ ] [1916](https://www.beecrowd.com.br/repository/UOJ_1916.html) - Banco de Horas de Jaiminho
- [ ] [1917](https://www.beecrowd.com.br/repository/UOJ_1917.html) - Ajude o Chapolin Colorado!
- [ ] [1918](https://www.beecrowd.com.br/repository/UOJ_1918.html) - Viagem para Acapulco
- [ ] [1919](https://www.beecrowd.com.br/repository/UOJ_1919.html) - Ajude Nhonho
- [ ] [1920](https://www.beecrowd.com.br/repository/UOJ_1920.html) - Fonte dos Desejos
- [ ] [1934](https://www.beecrowd.com.br/repository/UOJ_1934.html) - Quebra-cabeça
- [ ] [1935](https://www.beecrowd.com.br/repository/UOJ_1935.html) - Espiral
Expand Down
4 changes: 2 additions & 2 deletions categorias/matemtica.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Matemática (96 / 269)
# Matemática (97 / 269)



Expand Down Expand Up @@ -58,6 +58,7 @@
- [x] [2066](https://www.beecrowd.com.br/repository/UOJ_2066.html) - [amelborP mU](https://github.com/potigol/beecrowd/blob/master/src/2000/2066.poti)
- [x] [2084](https://www.beecrowd.com.br/repository/UOJ_2084.html) - [Eleições](https://github.com/potigol/beecrowd/blob/master/src/2000/2084.poti)
- [x] [2129](https://www.beecrowd.com.br/repository/UOJ_2129.html) - [Fatorial](https://github.com/potigol/beecrowd/blob/master/src/2100/2129.poti)
- [x] [2149](https://www.beecrowd.com.br/repository/UOJ_2149.html) - [Sequência do Tio Phill Bonati](https://github.com/potigol/beecrowd/blob/master/src/2100/2149.poti)
- [x] [2154](https://www.beecrowd.com.br/repository/UOJ_2154.html) - [Derivada de Polinômios](https://github.com/potigol/beecrowd/blob/master/src/2100/2154.poti)
- [x] [2170](https://www.beecrowd.com.br/repository/UOJ_2170.html) - [Juros do Projeto](https://github.com/potigol/beecrowd/blob/master/src/2100/2170.poti)
- [x] [2180](https://www.beecrowd.com.br/repository/UOJ_2180.html) - [Viagem à Marte na Velocidade de Primo](https://github.com/potigol/beecrowd/blob/master/src/2100/2180.poti)
Expand Down Expand Up @@ -214,7 +215,6 @@
- [ ] [2135](https://www.beecrowd.com.br/repository/UOJ_2135.html) - Recuperação
- [ ] [2145](https://www.beecrowd.com.br/repository/UOJ_2145.html) - A Vida Amorosa dos Números
- [ ] [2148](https://www.beecrowd.com.br/repository/UOJ_2148.html) - Banco de Dados
- [ ] [2149](https://www.beecrowd.com.br/repository/UOJ_2149.html) - Sequência do Tio Phill Bonati
- [ ] [2177](https://www.beecrowd.com.br/repository/UOJ_2177.html) - Rio 2016
- [ ] [2222](https://www.beecrowd.com.br/repository/UOJ_2222.html) - Brincando com Conjuntos
- [ ] [2291](https://www.beecrowd.com.br/repository/UOJ_2291.html) - Números Divinos
Expand Down
4 changes: 2 additions & 2 deletions competicoes/outras/olip/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Olimpíada IFSULDEMINAS (79 / 143)
# Olimpíada IFSULDEMINAS (80 / 143)



Expand Down Expand Up @@ -154,7 +154,7 @@
- [x] [2146](https://www.beecrowd.com.br/repository/UOJ_2146.html) - [Senha](https://github.com/potigol/beecrowd/blob/master/src/2100/2146.poti) *Iniciante*
- [x] [2147](https://www.beecrowd.com.br/repository/UOJ_2147.html) - [Galopeira](https://github.com/potigol/beecrowd/blob/master/src/2100/2147.poti) *Iniciante*
- [ ] [2148](https://www.beecrowd.com.br/repository/UOJ_2148.html) - Banco de Dados *Matemática*
- [ ] [2149](https://www.beecrowd.com.br/repository/UOJ_2149.html) - Sequência do Tio Phill Bonati *Matemática*
- [x] [2149](https://www.beecrowd.com.br/repository/UOJ_2149.html) - [Sequência do Tio Phill Bonati](https://github.com/potigol/beecrowd/blob/master/src/2100/2149.poti) *Matemática*
- [x] [2150](https://www.beecrowd.com.br/repository/UOJ_2150.html) - [Vogais Alienígenas](https://github.com/potigol/beecrowd/blob/master/src/2100/2150.poti) *Strings*
- [ ] [2151](https://www.beecrowd.com.br/repository/UOJ_2151.html) - Soco do Rulk *Ad-Hoc*
- [x] [2152](https://www.beecrowd.com.br/repository/UOJ_2152.html) - [Pepe, Já Tirei a Vela!](https://github.com/potigol/beecrowd/blob/master/src/2100/2152.poti) *Iniciante*
Expand Down
4 changes: 2 additions & 2 deletions competicoes/outras/olip/matemtica.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Matemática (9 / 19)
# Matemática (10 / 19)



## Problemas resolvidos

- [x] [1869](https://www.beecrowd.com.br/repository/UOJ_1869.html) - [Base 32](https://github.com/potigol/beecrowd/blob/master/src/1800/1869.poti)
- [x] [2149](https://www.beecrowd.com.br/repository/UOJ_2149.html) - [Sequência do Tio Phill Bonati](https://github.com/potigol/beecrowd/blob/master/src/2100/2149.poti)
- [x] [2154](https://www.beecrowd.com.br/repository/UOJ_2154.html) - [Derivada de Polinômios](https://github.com/potigol/beecrowd/blob/master/src/2100/2154.poti)
- [x] [2584](https://www.beecrowd.com.br/repository/UOJ_2584.html) - [Pentágono](https://github.com/potigol/beecrowd/blob/master/src/2500/2584.poti)
- [x] [2864](https://www.beecrowd.com.br/repository/UOJ_2864.html) - [Qual é a Altura?](https://github.com/potigol/beecrowd/blob/master/src/2800/2864.poti)
Expand All @@ -19,7 +20,6 @@
- [ ] [1872](https://www.beecrowd.com.br/repository/UOJ_1872.html) - Palíndromo Real
- [ ] [2145](https://www.beecrowd.com.br/repository/UOJ_2145.html) - A Vida Amorosa dos Números
- [ ] [2148](https://www.beecrowd.com.br/repository/UOJ_2148.html) - Banco de Dados
- [ ] [2149](https://www.beecrowd.com.br/repository/UOJ_2149.html) - Sequência do Tio Phill Bonati
- [ ] [2589](https://www.beecrowd.com.br/repository/UOJ_2589.html) - Maior Distância Entre Primos Consecutivos
- [ ] [2873](https://www.beecrowd.com.br/repository/UOJ_2873.html) - Pirâmide
- [ ] [2953](https://www.beecrowd.com.br/repository/UOJ_2953.html) - Mais um Joguinho
Expand Down
4 changes: 2 additions & 2 deletions src/1900/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Problemas 1900 (27%)
# Problemas 1900 (28%)

- [ ] [1900](https://www.beecrowd.com.br/repository/UOJ_1900.html) - Sequências Nulas *Paradigmas*
- [x] [1901](https://www.beecrowd.com.br/repository/UOJ_1901.html) - [Borboletas](https://github.com/potigol/beecrowd/blob/master/src/1900/1901.poti) *Ad-Hoc*
Expand All @@ -19,7 +19,7 @@
- [ ] [1916](https://www.beecrowd.com.br/repository/UOJ_1916.html) - Banco de Horas de Jaiminho *Ad-Hoc*
- [ ] [1917](https://www.beecrowd.com.br/repository/UOJ_1917.html) - Ajude o Chapolin Colorado! *Ad-Hoc*
- [ ] [1918](https://www.beecrowd.com.br/repository/UOJ_1918.html) - Viagem para Acapulco *Ad-Hoc*
- [ ] [1919](https://www.beecrowd.com.br/repository/UOJ_1919.html) - Ajude Nhonho *Ad-Hoc*
- [x] [1919](https://www.beecrowd.com.br/repository/UOJ_1919.html) - [Ajude Nhonho](https://github.com/potigol/beecrowd/blob/master/src/1900/1919.poti) *Ad-Hoc*
- [ ] [1920](https://www.beecrowd.com.br/repository/UOJ_1920.html) - Fonte dos Desejos *Ad-Hoc*
- [x] [1921](https://www.beecrowd.com.br/repository/UOJ_1921.html) - [Guilherme e Suas Pipas](https://github.com/potigol/beecrowd/blob/master/src/1900/1921.poti) *Matemática*
- [ ] [1922](https://www.beecrowd.com.br/repository/UOJ_1922.html) - Diego e o Jogo do Martelo *Paradigmas*
Expand Down
4 changes: 2 additions & 2 deletions src/2100/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Problemas 2100 (37%)
# Problemas 2100 (38%)

- [ ] [2100](https://www.beecrowd.com.br/repository/UOJ_2100.html) - Cinema de Xing Tzen Zu *Matemática*
- [ ] [2101](https://www.beecrowd.com.br/repository/UOJ_2101.html) - Combinações de Dias *Matemática*
Expand Down Expand Up @@ -49,7 +49,7 @@
- [x] [2146](https://www.beecrowd.com.br/repository/UOJ_2146.html) - [Senha](https://github.com/potigol/beecrowd/blob/master/src/2100/2146.poti) *Iniciante*
- [x] [2147](https://www.beecrowd.com.br/repository/UOJ_2147.html) - [Galopeira](https://github.com/potigol/beecrowd/blob/master/src/2100/2147.poti) *Iniciante*
- [ ] [2148](https://www.beecrowd.com.br/repository/UOJ_2148.html) - Banco de Dados *Matemática*
- [ ] [2149](https://www.beecrowd.com.br/repository/UOJ_2149.html) - Sequência do Tio Phill Bonati *Matemática*
- [x] [2149](https://www.beecrowd.com.br/repository/UOJ_2149.html) - [Sequência do Tio Phill Bonati](https://github.com/potigol/beecrowd/blob/master/src/2100/2149.poti) *Matemática*
- [x] [2150](https://www.beecrowd.com.br/repository/UOJ_2150.html) - [Vogais Alienígenas](https://github.com/potigol/beecrowd/blob/master/src/2100/2150.poti) *Strings*
- [ ] [2151](https://www.beecrowd.com.br/repository/UOJ_2151.html) - Soco do Rulk *Ad-Hoc*
- [x] [2152](https://www.beecrowd.com.br/repository/UOJ_2152.html) - [Pepe, Já Tirei a Vela!](https://github.com/potigol/beecrowd/blob/master/src/2100/2152.poti) *Iniciante*
Expand Down

0 comments on commit 437d769

Please sign in to comment.