Cody

Solution 1579503

Submitted on 9 Jul 2018 by J. S. Kowontan
  • Size: 54
  • This is the leading solution.
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
m=[0.270000 0.550000 0.910000 0.330000 0.520000 0.300000 ;0.850000 0.450000 0.060000 0.240000 0.120000 0.880000 ]; Wexp=[5 3]; W=War(m); assert(isequal(Wexp,W))

2   Pass
m=[0.164000 0.255000 0.009000 0.445000 0.209000 0.100000 0.391000 0.536000 0.027000 0.118000 ;0.673000 0.782000 0.582000 0.882000 0.591000 0.855000 0.745000 0.955000 0.991000 0.600000 ]; Wexp=[0 0]; W=War(m); assert(isequal(Wexp,W))

3   Pass
m=[0.800000 0.480000 0.760000 0.680000 0.160000 0.640000 0.360000 ;0.200000 0.440000 0.960000 0.280000 0.880000 0.520000 0.120000 ]; Wexp=[5 2]; W=War(m); assert(isequal(Wexp,W))

4   Pass
m=[0.170000 0.100000 0.120000 0.200000 0.540000 0.150000 ;0.490000 0.070000 0.240000 0.680000 0.610000 0.340000 ]; Wexp=[2 1]; W=War(m); assert(isequal(Wexp,W))

5   Pass
m=[0.780000 0.770000 0.900000 0.810000 0.880000 0.840000 0.600000 0.730000 0.930000 0.990000 ;0.270000 0.150000 0.260000 0.510000 0.570000 0.310000 0.170000 0.140000 0.400000 0.040000 ]; Wexp=[10 10]; W=War(m); assert(isequal(Wexp,W))

6   Pass
m=[0.320000 0.820000 0.350000 0.770000 0.020000 0.550000 0.040000 0.990000 0.610000 0.190000 ;0.730000 0.530000 0.750000 0.800000 0.670000 0.870000 0.330000 0.250000 0.080000 0.680000 ]; Wexp=[7 1]; W=War(m); assert(isequal(Wexp,W))

7   Pass
m=[0.510000 0.100000 0.380000 0.050000 0.210000 0.130000 0.440000 0.180000 ;0.560000 0.920000 0.540000 0.900000 0.670000 0.790000 0.820000 0.970000 ]; Wexp=[0 0]; W=War(m); assert(isequal(Wexp,W))

8   Pass
m=[0.420000 ;0.080000 ]; Wexp=[1 1]; W=War(m); assert(isequal(Wexp,W))

9   Pass
m=[0.690000 0.310000 0.540000 0.230000 0.710000 0.030000 0.490000 0.600000 0.510000 0.860000 ;0.830000 0.340000 0.370000 0.740000 0.430000 0.200000 0.090000 0.170000 0.910000 0.400000 ]; Wexp=[8 4]; W=War(m); assert(isequal(Wexp,W))

10   Pass
m=[0.300000 0.920000 0.710000 0.130000 0.230000 0.620000 0.140000 0.260000 0.360000 0.310000 ;0.440000 0.010000 0.640000 0.350000 0.820000 0.550000 0.780000 0.790000 0.060000 0.570000 ]; Wexp=[6 2]; W=War(m); assert(isequal(Wexp,W))

11   Pass
m=[0.504000 0.218000 0.479000 0.101000 0.050000 0.445000 0.471000 0.084000 0.034000 0.008000 ;0.992000 0.546000 0.647000 0.849000 0.891000 0.739000 0.765000 0.555000 0.613000 0.748000 ]; Wexp=[0 0]; W=War(m); assert(isequal(Wexp,W))

12   Pass
m=[0.570000 0.470000 0.640000 0.550000 0.060000 0.430000 0.040000 0.280000 0.130000 0.510000 ;0.700000 0.740000 0.770000 0.810000 0.870000 0.790000 0.940000 0.910000 0.850000 0.660000 ]; Wexp=[0 0]; W=War(m); assert(isequal(Wexp,W))

13   Pass
m=[0.200000 0.020000 0.510000 0.120000 0.220000 0.250000 0.100000 0.490000 0.530000 0.350000 ;0.800000 0.960000 0.760000 0.820000 0.710000 0.570000 0.940000 0.690000 0.900000 0.550000 ]; Wexp=[0 0]; W=War(m); assert(isequal(Wexp,W))

14   Pass
m=[0.260000 0.030000 0.360000 0.410000 0.330000 0.430000 0.540000 0.300000 0.280000 0.100000 ;0.770000 0.910000 0.700000 0.550000 0.590000 0.780000 0.650000 0.860000 0.750000 0.990000 ]; Wexp=[0 0]; W=War(m); assert(isequal(Wexp,W))

15   Pass
m=[0.920000 0.370000 0.900000 0.200000 0.150000 0.020000 0.530000 0.860000 0.250000 0.190000 ;0.170000 0.980000 0.140000 0.680000 0.830000 0.470000 0.950000 0.340000 0.880000 0.540000 ]; Wexp=[7 0]; W=War(m); assert(isequal(Wexp,W))

16   Pass
m=[0.510000 0.020000 0.490000 0.280000 0.080000 0.830000 0.170000 0.140000 0.850000 ;0.420000 0.650000 0.950000 0.890000 0.030000 0.580000 0.380000 0.060000 0.370000 ]; Wexp=[6 1]; W=War(m); assert(isequal(Wexp,W))

17   Pass
m=[0.670000 0.050000 0.590000 0.330000 0.820000 0.030000 0.740000 0.560000 0.950000 0.620000 ;0.210000 0.380000 0.770000 0.080000 0.260000 0.640000 0.460000 0.790000 0.310000 0.410000 ]; Wexp=[8 4]; W=War(m); assert(isequal(Wexp,W))

18   Pass
m=[0.840000 0.800000 0.420000 0.580000 0.670000 0.070000 0.360000 ;0.690000 0.870000 0.310000 0.600000 0.760000 0.200000 0.380000 ]; Wexp=[6 1]; W=War(m); assert(isequal(Wexp,W))

19   Pass
m=[0.450000 0.380000 0.280000 0.590000 0.620000 0.230000 0.810000 ;0.320000 0.190000 0.680000 0.140000 0.090000 0.940000 0.170000 ]; Wexp=[6 4]; W=War(m); assert(isequal(Wexp,W))

20   Pass
m=[0.207000 0.288000 0.180000 0.595000 0.748000 0.459000 0.802000 0.387000 0.027000 0.090000 ;0.450000 0.982000 0.694000 0.613000 0.486000 0.423000 0.685000 0.847000 0.432000 0.604000 ]; Wexp=[4 0]; W=War(m); assert(isequal(Wexp,W))

21   Pass
m=[0.750000 0.970000 0.820000 0.840000 0.680000 0.780000 0.730000 0.270000 0.220000 0.150000 ;0.130000 0.920000 0.390000 0.320000 0.230000 0.080000 0.800000 0.330000 0.720000 0.590000 ]; Wexp=[10 4]; W=War(m); assert(isequal(Wexp,W))

22   Pass
m=[0.260000 0.140000 0.600000 0.950000 0.160000 0.650000 0.580000 0.910000 0.230000 0.020000 ;0.120000 0.510000 0.530000 0.280000 0.350000 0.070000 0.400000 0.930000 0.490000 0.090000 ]; Wexp=[8 4]; W=War(m); assert(isequal(Wexp,W))

23   Pass
m=[0.545000 0.527000 0.500000 0.727000 0.018000 0.400000 0.191000 0.982000 0.409000 0.591000 ;0.945000 0.745000 0.355000 0.673000 0.045000 0.118000 0.682000 0.827000 0.645000 0.482000 ]; Wexp=[6 1]; W=War(m); assert(isequal(Wexp,W))

24   Pass
m=[0.930000 0.980000 0.470000 0.810000 0.830000 0.460000 0.510000 0.540000 ;0.490000 0.640000 0.170000 0.290000 0.140000 0.440000 0.590000 0.760000 ]; Wexp=[8 4]; W=War(m); assert(isequal(Wexp,W))

25   Pass
m=[0.580000 ;0.330000 ]; Wexp=[1 1]; W=War(m); assert(isequal(Wexp,W))

26   Pass
m=[0.640000 0.820000 0.700000 0.480000 0.520000 0.610000 0.060000 0.240000 0.300000 ;0.550000 0.450000 0.090000 0.030000 0.850000 0.670000 0.760000 0.360000 0.790000 ]; Wexp=[7 1]; W=War(m); assert(isequal(Wexp,W))

27   Pass
m=[0.800000 ;0.900000 ]; Wexp=[0 0]; W=War(m); assert(isequal(Wexp,W))

28   Pass
m=[0.340000 0.100000 0.040000 0.110000 0.650000 0.250000 0.570000 0.480000 0.150000 0.800000 ;0.550000 0.020000 0.920000 0.080000 0.700000 0.360000 0.910000 0.710000 0.820000 0.850000 ]; Wexp=[5 1]; W=War(m); assert(isequal(Wexp,W))

29   Pass
m=[0.340000 0.890000 0.060000 0.090000 0.750000 0.730000 0.810000 0.950000 0.660000 0.390000 ;0.530000 0.970000 0.610000 0.670000 0.690000 0.380000 0.590000 0.300000 0.720000 0.110000 ]; Wexp=[8 4]; W=War(m); assert(isequal(Wexp,W))

30   Pass
m=[0.870000 0.600000 0.860000 0.830000 0.680000 0.810000 0.700000 0.920000 0.760000 ;0.170000 0.510000 0.330000 0.050000 0.240000 0.030000 0.410000 0.480000 0.520000 ]; Wexp=[9 9]; W=War(m); assert(isequal(Wexp,W))

31   Pass
m=[0.940000 0.720000 0.810000 0.220000 0.280000 0.530000 0.440000 0.160000 0.880000 0.970000 ;0.120000 0.030000 0.470000 0.560000 0.380000 0.340000 0.690000 0.090000 0.250000 0.750000 ]; Wexp=[10 4]; W=War(m); assert(isequal(Wexp,W))

32   Pass
m=[0.410000 0.360000 0.230000 0.140000 0.180000 0.050000 0.500000 0.270000 0.090000 0.450000 ;0.680000 0.950000 0.910000 0.860000 0.730000 0.550000 0.590000 0.820000 0.640000 0.770000 ]; Wexp=[0 0]; W=War(m); assert(isequal(Wexp,W))

33   Pass
m=[0.278000 0.852000 0.370000 0.824000 0.389000 0.704000 0.546000 0.204000 0.296000 0.056000 ;0.833000 0.315000 0.991000 0.028000 0.907000 0.630000 0.361000 0.037000 0.065000 0.954000 ]; Wexp=[7 2]; W=War(m); assert(isequal(Wexp,W))

34   Pass
m=[0.713000 0.657000 0.778000 0.435000 0.565000 0.870000 0.963000 0.343000 0.481000 0.593000 ;0.287000 0.333000 0.454000 0.130000 0.370000 0.759000 0.176000 0.611000 0.231000 0.398000 ]; Wexp=[10 6]; W=War(m); assert(isequal(Wexp,W))

35   Pass
m=[0.590000 0.750000 0.650000 0.900000 0.740000 0.880000 0.850000 ;0.400000 0.070000 0.540000 0.380000 0.570000 0.150000 0.490000 ]; Wexp=[7 7]; W=War(m); assert(isequal(Wexp,W))

36   Pass
m=[0.110000 0.920000 0.540000 0.840000 0.380000 0.770000 0.900000 0.490000 0.870000 0.750000 ;0.620000 0.480000 0.330000 0.440000 0.890000 0.130000 0.430000 0.080000 0.340000 0.560000 ]; Wexp=[10 5]; W=War(m); assert(isequal(Wexp,W))

37   Pass
m=[0.480000 0.650000 0.770000 0.690000 0.720000 0.560000 0.660000 0.550000 0.510000 0.730000 ;0.310000 0.440000 0.300000 0.060000 0.200000 0.420000 0.030000 0.070000 0.110000 0.140000 ]; Wexp=[10 10]; W=War(m); assert(isequal(Wexp,W))

38   Pass
m=[0.900000 0.680000 0.600000 0.800000 ;0.350000 0.050000 0.170000 0.880000 ]; Wexp=[4 3]; W=War(m); assert(isequal(Wexp,W))

39   Pass
m=[0.730000 0.910000 0.450000 0.640000 0.090000 ;0.550000 0.360000 0.270000 0.820000 0.180000 ]; Wexp=[4 2]; W=War(m); assert(isequal(Wexp,W))

40   Pass
m=[0.530000 0.740000 0.410000 0.320000 0.820000 0.970000 0.620000 0.500000 0.710000 0.090000 ;0.180000 0.760000 0.380000 0.150000 0.470000 0.210000 0.560000 0.120000 0.590000 0.440000 ]; Wexp=[9 4]; W=War(m); assert(isequal(Wexp,W))

41   Pass
m=[0.487000 0.092000 0.714000 0.160000 0.504000 0.277000 0.479000 0.605000 0.462000 0.832000 ;0.210000 0.824000 0.118000 0.387000 0.664000 0.874000 0.445000 0.739000 0.546000 0.017000 ]; Wexp=[8 2]; W=War(m); assert(isequal(Wexp,W))

42   Pass
m=[0.100000 ;0.400000 ]; Wexp=[0 0]; W=War(m); assert(isequal(Wexp,W))

43   Pass
m=[0.688000 0.872000 0.615000 0.477000 0.734000 0.624000 0.394000 0.532000 0.954000 0.817000 ;0.193000 0.119000 0.349000 0.073000 0.037000 0.009000 0.128000 0.303000 0.046000 0.064000 ]; Wexp=[10 10]; W=War(m); assert(isequal(Wexp,W))

44   Pass
m=[0.910000 0.550000 0.300000 0.570000 0.920000 0.400000 0.450000 0.150000 0.110000 0.190000 ;0.090000 0.790000 0.890000 0.740000 0.850000 0.940000 0.340000 0.380000 0.720000 0.260000 ]; Wexp=[6 1]; W=War(m); assert(isequal(Wexp,W))

45   Pass
m=[0.723000 0.639000 0.824000 0.697000 0.840000 0.882000 0.437000 0.782000 0.588000 0.218000 ;0.345000 0.151000 0.067000 0.849000 0.815000 0.235000 0.521000 0.765000 0.950000 0.681000 ]; Wexp=[9 3]; W=War(m); assert(isequal(Wexp,W))

46   Pass
m=[0.200000 0.150000 0.350000 0.090000 0.110000 0.330000 0.220000 ;0.390000 0.460000 0.850000 0.700000 0.570000 0.610000 0.500000 ]; Wexp=[0 0]; W=War(m); assert(isequal(Wexp,W))

47   Pass
m=[0.850000 0.790000 0.550000 0.380000 0.300000 0.400000 0.770000 0.740000 0.320000 0.570000 ;0.260000 0.210000 0.110000 0.130000 0.020000 0.040000 0.230000 0.190000 0.090000 0.060000 ]; Wexp=[10 10]; W=War(m); assert(isequal(Wexp,W))

48   Pass
m=[0.961000 0.330000 0.010000 0.816000 0.583000 0.913000 0.893000 0.951000 0.126000 0.398000 ;0.767000 0.029000 0.262000 0.641000 0.175000 0.544000 0.359000 0.932000 0.680000 0.476000 ]; Wexp=[9 4]; W=War(m); assert(isequal(Wexp,W))

49   Pass
m=[0.300000 ;0.700000 ]; Wexp=[0 0]; W=War(m); assert(isequal(Wexp,W))

50   Pass
m=[0.240000 0.050000 0.190000 0.110000 0.920000 0.590000 0.730000 0.380000 0.780000 0.950000 ;0.860000 0.700000 0.430000 0.620000 0.220000 0.540000 0.410000 0.890000 0.680000 0.490000 ]; Wexp=[6 2]; W=War(m); assert(isequal(Wexp,W))

51   Pass
% function GJam_Qual_2014d % % % %War % fn='D-small-attempt0.in'; % %fn='D-large.in'; % [data] = read_file(fn); % % % fidG = fopen('D-small-output.out', 'w'); % %fidG = fopen('D-large-output001.out', 'w'); % tic % % for i=1:size(data,2) % Cell array has N rows of cases % % m=sort(data{i},2); % m=data{i}; % dw = dWar(m) ;% % w = War(m) ;% % % fprintf('Case #%i: %i %i\n',i,dw,w); % fprintf(fidG,'Case #%i: %i %i\n',i,dw,w); % % end % toc % % fclose(fidG); % % end % % function dw=dWar(m) % % Post contest % % Lie to burn opponent best pieces % N=sort(m(1,:)); % K=sort(m(2,:)); % % dw=0; % for i=1:length(N) % if N(i)>K(1) % Lie to above to beat lowest % dw=dw+1; % K=K(2:end); % else % Lie to just below best % K=K(1:end-1); % end % end % % end % % function w=War(m) % % Optimal truthful strategy % % Best lucky sequence % w=0; % % Nm=sort(m(1,:)); % Km=sort(m(2,:)); % % Nmz=[Nm' ones(size(Nm,2),1)]; % Kmz=[Km' zeros(size(Km,2),1)]; % z=[Nmz;Kmz]; % z=sortrows(z,-1); % % while ~isempty(z) % ptr1=find(z(:,2)==1,1,'last'); % ptr0=find(z(1:ptr1,2)==0,1,'last'); % if isempty(ptr0) % % score % w=w+1; % z(ptr1,:)=[]; % ptr0=find(z(:,2)==0,1,'last'); % z(ptr0,:)=[]; % else % z(ptr1,:)=[]; % z(ptr0,:)=[]; % end % end % % Create worst Ken/B Scenario % % end % % % function [d] = read_file(fn) % % Read whole array then parse % % dlmread valid for numeric arrays % m=dlmread(fn); % m(1,:)=[]; % for i=1:size(m,1)/3 % d{i}=m(3*i-1:3*i,1:m(3*i-2,1)); % end % % end % read_file % Data Set file %4 %1 %0.5 %0.6 %2 %0.7 0.2 %0.8 0.3 %3 %0.5 0.1 0.9 %0.6 0.4 0.3 %9 %0.186 0.389 0.907 0.832 0.959 0.557 0.300 0.992 0.899 %0.916 0.728 0.271 0.520 0.700 0.521 0.215 0.341 0.458