Skip to content

Commit

Permalink
novos exercícios
Browse files Browse the repository at this point in the history
  • Loading branch information
luizchaves committed Apr 5, 2023
1 parent 3c82924 commit 51e4d60
Show file tree
Hide file tree
Showing 85 changed files with 1,568 additions and 126 deletions.
12 changes: 9 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ for f in src/pages/exercises/*; do
exercise="${f/src\/pages\/exercises\//}"

if ! [[ "$exercise" =~ ^_.* ]]; then
originPath="src/pages/exercises/${exercise}/_codes"
codeOriginPath="src/pages/exercises/${exercise}/_codes"

if [ -d $originPath ]; then
cp -r $originPath "dist/problems/${exercise}/_codes"
if [ -d $codeOriginPath ]; then
cp -r $codeOriginPath "dist/problems/${exercise}/_codes"
fi

exampleOriginPath="src/pages/exercises/${exercise}/_examples"

if [ -d $exampleOriginPath ]; then
cp -r $exampleOriginPath "dist/problems/${exercise}/_examples"
fi
fi
done
16 changes: 8 additions & 8 deletions src/pages/exercises/array-fibonacci-sequence/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Sequência de Fibonacci
title: Sequência de Fibonacci (Array)
subjects:
- algoritmo
areas:
Expand All @@ -20,10 +20,10 @@ Para analisar mais exemplos veja a _Tabela 1_.

_Tabela 1:_

| Entrada | Saída |
| ------- | ------------------ |
| `0` | |
| `1` | `0` |
| `2` | `0, 1` |
| `4` | `0, 1, 1, 2` |
| `6` | `0, 1, 1, 2, 3, 5` |
| Entrada | Saída |
| ------- | -------------------- |
| `0` | |
| `1` | `(0)` |
| `2` | `(0, 1)` |
| `4` | `(0, 1, 1, 2)` |
| `6` | `(0, 1, 1, 2, 3, 5)` |
2 changes: 1 addition & 1 deletion src/pages/exercises/array-min-withdraw/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Saque mínimo
title: Saque Mínimo
subjects:
- algoritmo
areas:
Expand Down
2 changes: 1 addition & 1 deletion src/pages/exercises/function-fibonacci-sequence/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Sequência de Fibonacci
title: Sequência de Fibonacci (String)
subjects:
- algoritmo
areas:
Expand Down

This file was deleted.

39 changes: 39 additions & 0 deletions src/pages/exercises/object-company/_codes/js/response/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const companies = [
{
name: 'Amazon',
founded: 1994,
industry: ['E-Commerce', 'Cloud'],
},
{
name: 'Facebook',
founded: 2004,
industry: ['Social'],
},
{
name: 'Alphabet Inc.',
founded: 2015,
industry: ['Search', 'Cloud', 'Advertising'],
},
];

companies.sort((a, b) => a.name.localeCompare(b.name));

companies.forEach((company) => {
company.kind = 'Internet company';
});

const MAX_NAME_LENGHT = Math.max(
...companies.map((company) => company.name.length)
);

function show(companies) {
return companies
.map(
(company) =>
company.name.padEnd(MAX_NAME_LENGHT + 3, '.') + company.founded
)
.join('\n');
}

// console.table(companies);
console.log(show(companies));

This file was deleted.

27 changes: 27 additions & 0 deletions src/pages/exercises/object-entity/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Objeto HTML Entity
subjects:
- algoritmo
areas:
- objeto
---

import { Image } from '@astrojs/image/components';
import objectHtmlEntity from './_assets/object-html-entity.svg';

## Descrição

Estruture a informação desta coleção de Entidades do HTML com algum tipo de dados, usando objeto:

| Char | Entity | Decimal | Hexa | Description |
| ------ | -------- | -------- | -------- | -------------- |
| & | `&` | `&` | `&` | ampersand |
| < | `<` | `<` | `<` | less than |
| > | `>` | `>` | `>` | greater than |
| © | `©` | `©` | `©` | copyright sign |

Para facilitar o processo, observe este diagrama da _Figura 1_:

_Figura 1 - Objeto Entidade do HTML_

<Image src={objectHtmlEntity} alt="Objeto Entidade do HTML" class="border p-4" />
13 changes: 13 additions & 0 deletions src/pages/exercises/object-entity/_assets/object-html-entity.pu
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@startuml
skinparam classAttributeIconSize 0
skinparam monochrome true
hide circle

class Entity {
char: String
entity: String
decimal: String
hexa: String
description: String
}
@enduml
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=http://www.plantuml.com/plantuml/svg/LOux3W8n34Hxdy97eAPQ2WhgFO7nMiGYSLQE8_4HTmUsGA6SDs-acLgGHoyPsbLj9QU2dAcrGuJhkOUSkDgi3y7Te9HgbPFN8XZU1P8kWgpEMG2sFHujDExu14HEv7kSmzKkdoXRCu15M0lbWIIvqP_Gs7KDhVQZBvZ4bk_pDm00
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"char": "&",
"entity": "&amp;",
"decimal": "&#38;",
"hexa": "&#x26;",
"description": "ampersan"
},
{
"char": "<",
"entity": "&lt;",
"decimal": "&#60;",
"hexa": "&#x3C;",
"description": "less than"
},
{
"char": ">",
"entity": "&gt;",
"decimal": "&#62;",
"hexa": "&#x3E;",
"description": "greater than"
},
{
"char": "©",
"entity": "&copy;",
"decimal": "&#169;",
"hexa": "&#xA9;",
"description": "copyright sign"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"amp": {
"char": "&",
"entity": "&amp;",
"decimal": "&#38;",
"hexa": "&#x26;",
"description": "ampersan"
},
"lt": {
"char": "<",
"entity": "&lt;",
"decimal": "&#60;",
"hexa": "&#x3C;",
"description": "less than"
},
"gt": {
"char": ">",
"entity": "&gt;",
"decimal": "&#62;",
"hexa": "&#x3E;",
"description": "greater than"
},
"copy": {
"char": "©",
"entity": "&copy;",
"decimal": "&#169;",
"hexa": "&#xA9;",
"description": "copyright sign"
}
}
38 changes: 38 additions & 0 deletions src/pages/exercises/object-exam/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Objeto Exames
subjects:
- algoritmo
areas:
- objeto
---

import { Image } from '@astrojs/image/components';
import objectExams from './_assets/object-exams.svg';

## Descrição

Considere que um professor está construindo um sistema de avaliações no qual as questões possuem peso, então dado que foi criado uma avaliação com estas questões:

| Questões | Peso | Resposta |
| -------- | ---- | -------- |
| 1 | 2 | a |
| 2 | 2 | b |
| 3 | 2 | a |
| 4 | 2 | c |
| 5 | 2 | d |

Então se um aluno respondeu a prova com as seguintes alternativas o resultado da nota será 4,0.

| Questões | Peso | Resposta | Aluno |
| -------- | ---- | -------- | ----- |
| 1 | 2 | a | a |
| 2 | 2 | b | b |
| 3 | 2 | a | b |
| 4 | 2 | c | b |
| 5 | 2 | d | b |

Para facilitar a criação deste sistema tente criar a classe `Exams` com esta estrutura:

_Figura 1 - Instância da Empresa_

<Image src={objectExams} alt="Instância da Empresa" class="border p-4" />
18 changes: 18 additions & 0 deletions src/pages/exercises/object-exam/_assets/object-exams.pu
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@startuml
skinparam classAttributeIconSize 0
skinparam monochrome true
hide circle

class Exams {
-weight: Weight
-answer: Answer
-exams: Exam
+__construct(answer: Answer, weight: Weight)
+add(exam: Exam): void
+avg(): float
+min([count: float]): Array<float>
+max([count: float]): Array<float>
+lt([limit: float]): Array<float>
+gt([limit: float]): Array<float>
}
@enduml
1 change: 1 addition & 0 deletions src/pages/exercises/object-exam/_assets/object-exams.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/pages/exercises/object-exam/_codes/js/code/exam-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ExamCheck {
// TODO
}

export { ExamCheck };
5 changes: 5 additions & 0 deletions src/pages/exercises/object-exam/_codes/js/code/exam-stats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ExamStats {
// TODO
}

export { ExamStats };
47 changes: 47 additions & 0 deletions src/pages/exercises/object-exam/_codes/js/code/exam.print.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { ExamCheck } from "./exam-check.js";
import { ExamStats } from "./exam-stats.js";

// Exam Tool

// calculating grade by weighted average
let weight = { q1: 2, q2: 2, q3: 2, q4: 2, q5: 2 };
let answer = { q1: "a", q2: "b", q3: "a", q4: "c", q5: "d" };
let examCheck = new ExamCheck(answer, weight);

let student = { q1: "a", q2: "b", q3: "b", q4: "b", q5: "b" };
console.log(examCheck.grade(student));
console.log(4);

// calculating grade by weighted average
weight = { q1: 2, q2: 2, q3: 2, q4: 2, q5: 2 };
answer = { q1: "a", q2: "b", q3: "a", q4: "c", q5: "d" };
examCheck = new ExamCheck(answer, weight);

student = { q1: "c", q2: "b", q3: "a", q4: "c", q5: "d" };
console.log(examCheck.grade(student));
console.log(8);

// calculating exam values
let examStats = new ExamStats([
{ student: "Fulano", grade: 10 },
{ student: "Sicrano", grade: 5 },
{ student: "Beltrano", grade: 7 }
]);

console.log(examStats.avg());
console.log(7.333333333333333);

console.log(examStats.min());
console.log([5]);

console.log(examStats.min(2));
console.log([5, 7]);

console.log(examStats.max());
console.log([10]);

console.log(examStats.lt(6));
console.log([5]);

console.log(examStats.gt(6));
console.log([7, 10]);
Loading

0 comments on commit 51e4d60

Please sign in to comment.