Guest User

Untitled

a guest
Dec 9th, 2016
213
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. permstring = char(nchoosek(toascii("1234567890+-*%."),5));
  4.  
  5. largest = 0;
  6.  
  7. for s=1:length(permstring)
  8.  
  9. number_of_errors = 0;
  10. number_of_bigs = 0;
  11. number_of_floats = 0;
  12.  
  13. results = zeros(120,1);
  14. arrperm = perms(permstring(s,:));
  15.  
  16. for i=1:length(arrperm)
  17.     try
  18.         results(i) = eval(arrperm(i,:));
  19.         if ((results(i) > 120) || (results(i) < 0))
  20. #           printf("%d,%s,%s\n",i,"too big",arrperm(i,:))
  21.             number_of_bigs++;
  22.             results(i) = -1;
  23.         elseif (abs(mod(results(i),1)))
  24. #           printf("%d,%s,%s\n",i,"float",arrperm(i,:))
  25.             number_of_floats++;
  26.             results(i) = -1;
  27.         else
  28. #           printf("%d,%d,%s\n",i,results(i),arrperm(i,:))
  29.         endif
  30.     catch
  31. #       printf("%d,%s,%s\n",i,"error",arrperm(i,:))
  32.         number_of_errors++;
  33.         results(i) = -1;
  34.     end_try_catch
  35. endfor
  36.  
  37. good_results = size(unique(results));
  38.  
  39. #printf("%s,%d,%d,%d,%d\n",permstring(s,:),number_of_errors,number_of_bigs,number_of_floats,good_results(1))
  40.  
  41. if (good_results(1) > largest)
  42.     largest=good_results(1);
  43.     printf("%s,%d\n",permstring(s,:),good_results(1))
  44. endif
  45.  
  46. endfor
RAW Paste Data