%%%
%%% 1st: 1/8,145,060. 2nd: 1/1,357,510. 3rd: 1/34,808. 4th: 1/733.
%%% 5th: 1/44.562
%%%
clear all;
DATA_MAXNUM = 10000; %% Number of lotto game
result_data = [0 0 0 0 0 0 0]; % result data initialize
cnt = 1; % counter
block_lotto = zeros(DATA_MAXNUM, 7);
for x = 1:DATA_MAXNUM
y = 1; % first row
while y <= 6
% random number generating method 1
%lottonum = floor(rand() * 45 + 1); % 1~45중 하나를 임의로 추출
% random number generating method 2
randomA = randperm(45);
lottonum = randomA(1); % 6 numbers drawn randomly from [1 45]
% reject same number
if isequal(lottonum == result_data, zeros(1,7))
result_data(1, y) = lottonum;
block_lotto(x, y) = result_data(1, y);
y = y + 1;
end
end
% sorting lotto number.
block_lotto(x, 1:6) = sort(block_lotto(x, 1:6));
%%% to generate 7th number .
%
randomA = randperm(45);
lottonum = randomA(1); % 6 numbers drawn randomly from [1 45]
result_data(1, 7) = lottonum;
block_lotto(x, 7) = result_data(1, 7);
%
if isequal(lottonum == result_data, zeros(1,7))
result_data(1, 7) = lottonum;
block_lotto(x, 7) = result_data(1, 7);
end
end
%disp('block_lotto_unweight : ');
%disp(block_lotto);
save_data = uint8(block_lotto);
fid = fopen('D:\program_lang\matlab\lotto\data\578_1_future_UNweight.txt', 'wt');
for x = 1:DATA_MAXNUM
fprintf(fid, '%d %d %d %d %d %d %d\n', save_data(x, 1), save_data(x, 2), save_data(x, 3), save_data(x, 4), save_data(x, 5), save_data(x, 6), save_data(x, 7));
end
fclose(fid);
disp('done...');
%%% compare program (6/45)
%%% save this program another file .
clear all;
%
%% 579th lotto number
real_lotto_data = [5, 7, 20, 22, 37, 42, 39]; %
before_data = load('D:\program_lang\matlab\lotto\data\578_1_future_UNweight.txt');
[row, col] = size(before_data);
correct_selection = zeros(2, row); %
%%%
%%%
%%%
%
for x = 1:row
for y = 1:6
for yy = 1:6
if (before_data(x, y) == real_lotto_data(1,yy))
correct_selection(1,x) = correct_selection(1, x) + 1;
end
end
if (before_data(x, 7) == real_lotto_data(1,7))
correct_selection(2, x) = 1;
end
end
end
%disp('correct_selection : ');
%disp(correct_selection);
%%%
%%% count grade
%%%
grade = [0, 0 ,0, 0, 0]; % 1st, 2nd, ... , 5th
for x = 1:row
if (correct_selection(1,x) == 3)
grade(1,5) = grade(1,5) + 1;
elseif (correct_selection(1, x) == 4)
grade(1,4) = grade(1,4) + 1;
elseif (correct_selection(1, x) == 5 && (correct_selection(2, x) == 0))
grade(1, 3) = grade(1, 3) + 1;
elseif ((correct_selection(1, x) == 5) && (correct_selection(2, x) == 1))
grade(1, 2) = grade(1, 2) + 1;
elseif (correct_selection(1, x) == 6)
grade(1,1) = grade(1,1) + 1;
end
end
disp('UNweight grade : ');
disp(grade);
댓글 없음:
댓글 쓰기