-
Notifications
You must be signed in to change notification settings - Fork 0
/
cc5k.pl
executable file
·195 lines (167 loc) · 2.97 KB
/
cc5k.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/usr/bin/perl
use strict;
use warnings;
use File::Basename;
###
# TO-DO: Add a growing status bar for each country -- possibly a dynamically
# resorting list
##
my @COUNTRIES = qw/
India
Greece
US-West
US-EastCoast
US-Southwest
US-SoulFood
RepublicOfTexas
Acadia
Jamaica
Mexico
Cuba
WestIndies
CentralAmerica
Brazil
Peru
Argentina
UK
Germany
France
Spain-Portugal
Spain-Tapas
Basque
Italy
Poland
BalticEurope
Turkey
Belgium
Morocco
NorthAfrica
MiddleEast
Pakistan
Afghanistan
China-Dimsum
China-NotDimsum
Japan
Sushi
Koreas
Mongolia
Russia
Thailand
Vietnam
Indonesia
Malaysia
Philipines
Australia
Ethiopia
SouthAfrica
Scandanavia
Kosher-ish
GourmetSTL
Hawaii
Breakfast
SteakHouse
/;
my @PREV_COUNTRIES = qw/
India
Cuba
Greece
Acadia
Jamaica
Peru
Scandanavia
UK
Vietnam
WestIndies
Afghanistan
US-West
US-EastCoast
US-SoulFood
Argentina
Brazil
Morocco
Basque
BalticEurope
MiddleEast
RepublicOfTexas
Mexico
CentralAmerica
US-Southwest
Japan
Philipines
Spain-Tapas
Russia
Koreas
France
Hawaii
Sushi
Belgium
SouthAfrica
Spain-Portugal
Pakistan
Poland
China-Dimsum
/;
$| = 1;
sub usage
{
my $name = basename $0;
print <<"USAGE";
USAGE: $name <threshold>
<threshold> is the number of times a country must match before it is chosen
USAGE
exit 2;
}
sub validate
{
my $country = shift;
if( $country eq 'Scandanavia' )
{
print "\n\nNo one wants Scandanativa. No. Just, no.\n";
print "No one wants to eat a bunch of nasty-ass fermented fish.\n";
print "No.\n\n";
print "Continuing...";
return 0;
}
elsif( not grep {/$country/} @PREV_COUNTRIES )
{
print "\n\nYour new country is...\n";
sleep 3;
print "<drumroll>\n";
sleep 9;
print "\n\n *** $country!!! ***\n\n";
return 1;
}
else
{
print "\n\nWe've already done $country.\n\n";
print "Continuing...";
return 0;
}
}
sub main
{
my $threshold = $ARGV[0];
usage() if not defined $threshold;
my %store = ();
my $iterations = 0;
print "Country Cuisine Choosing in progress...";
while( 1 )
{
$iterations++;
print "." if( $iterations % 10000 == 0 );
my $country = $COUNTRIES[ (int(rand 10000) % ($#COUNTRIES)) ];
$store{$country}++;
if( $store{$country} > $threshold )
{
last if validate( $country );
$store{$country} = 0;
}
}
sleep 1;
print "\n\nFinal Vote Counts\n=================\n";
sleep 2;
print "$_ = $store{$_}\n"
for (sort {$store{$b} <=> $store{$a}} keys %store);
return 0;
}
main();