File tree 1 file changed +17
-3
lines changed
examples/used-in-papers/sacs2024
1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ print(result) // Output: 66
29
29
30
30
// First attempt
31
31
32
+ /*
32
33
computeSum(n, m) {
33
34
lst = <2..n>; // Initialize the lst with numbers 2 to n
34
35
for (round = 1; round <= m; ++round) {
@@ -44,9 +45,16 @@ computeSum(n, m) {
44
45
sum = sum + lst.at(i); // Compute the sum of all numbers in the lst
45
46
return sum;
46
47
}
48
+ // Example usage
49
+ n = 5;
50
+ m = 3;
51
+ result = computeSum(n, m);
52
+ print(result); // Expected output: 66
53
+ //Error at [37:16]: The position in the list is out of bounds.
54
+ */
47
55
48
56
// Fixed version
49
- /*
57
+
50
58
computeSum(n, m){
51
59
lst = <2..n>; // Initialize the lst with numbers 2 to n
52
60
for (round = 1; round <= m; ++round) {
@@ -62,9 +70,15 @@ computeSum(n, m){
62
70
sum = sum + lst.at(i-1); // Compute the sum of all numbers in the lst
63
71
return sum;
64
72
}
65
- */
73
+
66
74
// Example usage
67
75
n = 5;
68
76
m = 3;
69
77
result = computeSum(n, m);
70
- print(result); // Output: 66
78
+ print(result); // Expected output: 66
79
+ /*
80
+ 26
81
+ result |-> 26
82
+ m |-> 3
83
+ n |-> 5
84
+ */
You can’t perform that action at this time.
0 commit comments