math618

41 Reputation

5 Badges

19 years, 171 days

MaplePrimes Activity


These are answers submitted by math618

there is another problem:the symbols in s can not take the corresponding value assigned before!

>   IM:= proc (a::string)
>   uses group, StringTools;
>   local b,d,i,ans,s,M,M2,M3,M4,M5,M6,M7,M8,M9,M10,X;
>  
>   i:=0:b:=Explode(a);
>   for d in b do
>     i:=i+1;
>     if d>"0" and d<="9" then i:=i-1;s[i]:=Join(["M",d],"");
>       elif d="0" then i:=i-1;s[i]:="M10";
>       elif d="I" then s[i]:="X";
>       else s[i]:="M";
>     end if;
>   end do:
>   s:=convert(s,list);
>   s:=map(convert, s, symbol);
>   X:=[[1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]:
>   M10:=[[2, 12, 7, 4, 11, 6, 10, 8, 9, 5, 3]]:
>   M2:=[[2, 5, 8, 6, 4, 12, 3, 9, 10, 11, 7]]:
>   M8:=[[2, 4, 10, 5, 12, 11, 8, 3, 7, 6, 9]]:
>   M6:=[[2, 6, 3, 11, 5, 4, 9, 7, 8, 12, 10]]:
>   M7:=[[2, 11, 9, 12, 6, 5, 7, 10, 3, 4, 8]]:
>   M:=[[2, 3, 5, 9, 8, 10, 6, 11, 4, 7, 12]]:
>   M9:=[[2, 7, 11, 10, 9, 3, 12, 4, 6, 8, 5]]:
>   M3:=[[2, 9, 6, 7, 3, 8, 11, 12, 5, 10, 4]]:
>   M4:=[[2, 8, 4, 3, 10, 7, 5, 6, 12, 9, 11]]:
>   M5:=[[2, 10, 12, 8, 7, 9, 4, 5, 11, 3, 6]]:
>   print(X,s[1]);#this output can tell us s[1] cannot take [[1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]],why?
>   s:=op(s):
>   foldl(`mulperms`,s);
> end proc:
 

> IM("IMIM3IM2IM9IM7IM8");
        [[1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]], X

Error, (in convert/plist) bad index into Array

 

I'm sorry.In proc,I forgot to add "return" before foldl(`mulperms`,s);

> with(Maplets):
> a:=GetInput("Input a integer");
> n:=length(a);
> a:=convert(a,'bytes');
> a0:=0:
> for i from 1 to n do
       a0:=(a[i]-48)*10^(n-i)+a0:
   end do:
> a0;

Page 1 of 1