-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92f33c0
commit 52f42ce
Showing
8 changed files
with
4,625 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(ns main | ||
(:require [clojure.string :as str])) | ||
|
||
(defn retake-exam [average] | ||
(println "Aluno em exame.") | ||
(let [retake-grade (Double/parseDouble (read-line)) | ||
final-average (/ (+ retake-grade average) 2.0)] | ||
(printf "Nota exame: %.1f%n" retake-exam) | ||
(if (> final-average 5.0) | ||
(println "Aluno aprovado.") | ||
(println "Aluno reprovado.")) | ||
(printf "Media final: %.1f%n" final-average))) | ||
|
||
(defn grade [n1 n2 n3 n4] | ||
(let [average (/ (+ (* n1 2) (* n2 3) (* n3 4) n4) 10)] | ||
(printf "Media: %.1f%n" average) | ||
(cond (>= average 7.0) | ||
(println "Aluno aprovado.") | ||
(>= average 5.0) | ||
(retake-exam average) | ||
:else | ||
(println "Aluno reprovado.")))) | ||
|
||
(defn main [] | ||
(loop [line (read-line)] | ||
(when line | ||
(let [[n1 n2 n3 n4] (->> (str/split line #" ") | ||
(map #(Double/parseDouble %)))] | ||
(grade n1 n2 n3 n4)) | ||
(recur (read-line))))) | ||
|
||
(main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
n1, n2, n3, n4 = map(float, input().split()) | ||
import sys | ||
|
||
average = (n1 * 2 + n2 * 3 + n3 * 4 + n4) / 10 | ||
for line in sys.stdin: | ||
n1, n2, n3, n4 = map(float, line.split()) | ||
|
||
print(f'Media: {average:.1f}') | ||
if average >= 7.0: | ||
print('Aluno aprovado.') | ||
elif average >= 5.0: | ||
print('Aluno em exame.') | ||
average = (n1 * 2 + n2 * 3 + n3 * 4 + n4) / 10 | ||
|
||
final_test = float(input()) | ||
|
||
print(f'Nota do exame: {final_test:.1f}') | ||
if (final_test + average) / 2.0 > 5.0: | ||
print(f'Media: {average:.1f}') | ||
if average >= 7.0: | ||
print('Aluno aprovado.') | ||
elif average >= 5.0: | ||
print('Aluno em exame.') | ||
|
||
final_test = float(input()) | ||
|
||
print(f'Nota do exame: {final_test:.1f}') | ||
if (final_test + average) / 2.0 > 5.0: | ||
print('Aluno aprovado.') | ||
else: | ||
print('Aluno reprovado.') | ||
print(f'Media final: {(final_test + average) / 2.0:.1f}') | ||
else: | ||
print('Aluno reprovado.') | ||
print(f'Media final: {(final_test + average) / 2.0:.1f}') | ||
else: | ||
print('Aluno reprovado.') |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
TESTCASES=1000 | ||
CURRENT_PATH=$(dirname -- "${BASH_SOURCE[0]}") | ||
|
||
function get_random_grade { | ||
if [[ $((RANDOM % 100)) -eq 0 ]]; then | ||
echo "10.0" | ||
else | ||
echo "$((RANDOM % 10)).$((RANDOM % 10))" | ||
fi | ||
} | ||
|
||
for i in $(seq "${TESTCASES}"); do | ||
n1=$(get_random_grade) | ||
n2=$(get_random_grade) | ||
n3=$(get_random_grade) | ||
n4=$(get_random_grade) | ||
average_py=$(python3 -c "print(f\"{(${n1} * 2.0 + ${n2} * 3.0 + ${n3} * 4.0 + ${n4}) / 10.0:.1f}\")") | ||
|
||
{ | ||
echo "${n1} ${n2} ${n3} ${n4}" | ||
if (( $(echo "${average_py} >= 5.0" | bc -l) )) && (( $(echo "${average_py} <= 6.9" | bc -l) )); then | ||
get_random_grade | ||
fi | ||
} >> "${CURRENT_PATH}/in-$(printf "%04d" "${i}")".txt | ||
done |
Oops, something went wrong.