Cody

Problem 816. Global usage

Solution 3002236

Submitted on 28 Sep 2020 at 13:55 by Rafael S.T. Vieira
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
global gOffset global_x gOffset=4; global_x=1024; a=2; b=4; [a_off b_times] = use_global(a,b); gOffset=4; global_x=1024; assert(isequal(a_off,gOffset+a)) assert(isequal(b_times,global_x*b))

2   Pass
global gOffset global_x gOffset=-8; global_x=-2; a=50; b=-21; [a_off b_times] = use_global(a,b); assert(isequal(a_off,gOffset+a)) assert(isequal(b_times,global_x*b))

3   Pass
global gOffset global_x gOffset=2^12; global_x=3; a=randi(128); b=randi(8); [a_off b_times] = use_global(a,b); assert(isequal(a_off,gOffset+a)) assert(isequal(b_times,global_x*b))