2021-05-03 16:47:33 +03:00
|
|
|
/*
|
|
|
|
namespace: Compile
|
|
|
|
expectation: Pass
|
2021-05-05 18:29:44 +03:00
|
|
|
input_file: input/dummy.in
|
2021-05-03 16:47:33 +03:00
|
|
|
*/
|
|
|
|
|
2020-12-09 00:00:12 +03:00
|
|
|
// Swap two elements of an array.
|
2021-03-19 18:30:24 +03:00
|
|
|
function swap(a: [u32; 2], const i: u32, const j: u32) -> [u32; 2] {
|
2021-05-06 14:27:42 +03:00
|
|
|
let t = a[i];
|
2020-12-09 00:00:12 +03:00
|
|
|
a[i] = a[j];
|
|
|
|
a[j] = t;
|
2021-04-14 23:59:07 +03:00
|
|
|
return a;
|
2020-12-09 00:00:12 +03:00
|
|
|
}
|
|
|
|
|
2021-05-03 16:47:33 +03:00
|
|
|
function main(arr: [u32; 2]) -> bool {
|
2021-03-18 22:19:07 +03:00
|
|
|
const expected: [u32; 2] = [1, 0];
|
2021-05-06 14:27:42 +03:00
|
|
|
let actual = swap(arr, 0, 1);
|
2021-05-03 16:47:33 +03:00
|
|
|
|
|
|
|
// Do swap.
|
|
|
|
return expected[0] == actual[0] && expected[1] == actual[1];
|
2021-05-05 18:29:44 +03:00
|
|
|
}
|