2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
19
Task/Middle-three-digits/Maple/middle-three-digits.maple
Normal file
19
Task/Middle-three-digits/Maple/middle-three-digits.maple
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
middleDigits := proc(n)
|
||||
local nList, start;
|
||||
nList := [seq(parse(i), i in convert (abs(n), string))];
|
||||
if numelems(nList) < 3 then
|
||||
printf ("%9a: Error: Not enough digits.", n);
|
||||
elif numelems(nList) mod 2 = 0 then
|
||||
printf ("%9a: Error: Even number of digits.", n);
|
||||
else
|
||||
start := (numelems(nList)-1)/2;
|
||||
printf("%9a: %a%a%a", n, op(nList[start..start+2]));
|
||||
end if;
|
||||
end proc:
|
||||
|
||||
a := [123, 12345, 1234567, 987654321, 10001, -10001, -123, -100, 100, -12345,
|
||||
1, 2, -1, -10, 2002, -2002, 0]:
|
||||
for i in a do
|
||||
middleDigits(i);
|
||||
printf("\n");
|
||||
end do;
|
||||
Loading…
Add table
Add a link
Reference in a new issue