Skip to content

Commit

Permalink
Solve sum
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg-vr committed Aug 2, 2024
1 parent 2af1bbc commit ef13853
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tested/manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from tested.main import run
from tested.testsuite import SupportedLanguage

exercise_dir = "/home/jorg/Documents/universal-judge/tests/exercises/remove"
exercise_dir = "/home/jorg/Documents/universal-judge/tests/exercises/sum"


def read_config() -> DodonaConfig:
Expand All @@ -24,10 +24,10 @@ def read_config() -> DodonaConfig:
programming_language=SupportedLanguage("cpp"),
natural_language="nl",
resources=Path(exercise_dir, "evaluation"),
source=Path(exercise_dir, "solution/wrong.cpp"),
source=Path(exercise_dir, "solution/correct.cpp"),
judge=Path("."),
workdir=Path("workdir"),
test_suite="full.tson",
test_suite="plan.tson",
options=Options(
linter=False,
),
Expand Down
20 changes: 20 additions & 0 deletions tests/exercises/sum/solution/correct.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
#include <cstdlib>

int main(int argc, char* argv[]) {
int som = 0;

for (int i = 1; i < argc; i++) {
int r = std::atoi(argv[i]);
if (r == 0 && argv[i][0] != '0') {
std::cerr << "som: ongeldige argumenten" << std::endl;
return 1;
} else {
som += r;
}
}

std::cout << som << std::endl;

return 0;
}

0 comments on commit ef13853

Please sign in to comment.