Home
/
w958-generator
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
26005e3
)
corrected ret & oem part2 subroutines
master
author
David Polakovic
<email@dpolakovic.space>
Mon, 1 Apr 2024 18:48:45 +0000 (20:48 +0200)
committer
David Polakovic
<email@dpolakovic.space>
Mon, 1 Apr 2024 18:48:45 +0000 (20:48 +0200)
generate-for
patch
|
blob
|
history
diff --git
a/generate-for
b/generate-for
index c4eb906507fdcf0eb3aa0e36edefc2cae283f193..012877a58ad077a2eaf85a46e6ce0fb3ca7c3101 100644
(file)
--- a/
generate-for
+++ b/
generate-for
@@
-13,19
+13,13
@@
sub generate95_ret_part1 {
return $string;
}
return $string;
}
-# generates 7 digit number
of which digit sum is 7 (e.g.: 4001110)
+# generates 7 digit number
divisible by 7
sub generate95_ret_part2 {
sub generate95_ret_part2 {
- my $sum = shift;
- my $string = "";
-
- for my $i (1..6) {
- my $digit = int(rand($sum + 1));
- $sum -= $digit;
- $string .= $digit;
- }
- $string .= $sum;
-
- return $string;
+ my $num;
+ do {
+ $num = int(rand(9000000)) + 1000000;
+ } while ($num % 7 != 0); # Repeat until the number is divisible by 7
+ return $num;
}
# picks random two digit combination from the list
}
# picks random two digit combination from the list
@@
-34,17
+28,19
@@
sub generate95_oem_part2 {
my $random_index = int(rand(scalar @list));
my $random_value = $list[$random_index];
}
my $random_index = int(rand(scalar @list));
my $random_value = $list[$random_index];
}
-# generates random 7 digit number, starting with "00"
+
+
+# generates random 7 digit number, starting with "00" and divisible by 7
sub generate95_oem_part3 {
sub generate95_oem_part3 {
- my $sum = shift;
- my $string = "00";
+ my $string = "00"; # Start with "00"
- for my $i (3..6) {
- my $digit = int(rand($sum + 1));
- $sum -= $digit;
- $string .= $digit;
+ while (1) {
+ my $number = int(rand(90000)) + 10000;
+ if ($number % 7 == 0) {
+ $string .= $number;
+ last;
+ }
}
}
- $string .= $sum;
return $string;
}
return $string;
}
@@
-76,7
+72,7
@@
if (@ARGV == 0) {
my $result95_oem =
$result95_oem_part1 .
$result95_oem_part2 .
my $result95_oem =
$result95_oem_part1 .
$result95_oem_part2 .
- "-
dpo
-" .
+ "-
OEM
-" .
$result95_oem_part3 .
"-" .
$result95_oem_part4;
$result95_oem_part3 .
"-" .
$result95_oem_part4;