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
|
# File 'lib/pin_drop.rb', line 20
def self.guesses
obvious = [1234,1111,0000,1212,7777,1004,2000,4444,2222,6969,9999,3333,5555,6666,1122,1313,8888,4321,2001,1010].map(&:to_s)
singlets = []
couplets = []
nineties = []
twothousands = []
starts_with_1 = []
starts_with_0 = []
ddmm_date = []
mmdd_date = []
mmyy_date = []
starts_with_2 = []
starts_with_3 = []
starts_with_4 = []
starts_with_5 = []
starts_with_7 = []
starts_with_6 = []
starts_with_8 = []
starts_with_9 = []
the_rest = []
(0..9999).each do |i|
str = i.to_s.rjust(4, '0')
if obvious.include? str
elsif str[0] == '1' && str[1] == '9'
nineties << str
elsif str[0] == '2' && str[1] == '0' && (str[2] == '1' || str[2] == '0')
twothousands << str
elsif str.chars.uniq.length === 1
singlets << str
elsif str[0] == str[2] && str[1] == str[3]
couplets << str
elsif str[0] == '1'
starts_with_1 << str
elsif str[0] == '0'
starts_with_0 << str
elsif str[0..1].to_i <= 31 && str[2..3].to_i <= 12
ddmm_date << str
elsif str[0..1].to_i <= 12 && str[2..3].to_i <= 31
mmdd_date << str
elsif str[0..1].to_i <= 12
mmyy_date << str
elsif str[0] == '2'
starts_with_2 << str
elsif str[0] == '3'
starts_with_3 << str
elsif str[0] == '4'
starts_with_4 << str
elsif str[0] == '5'
starts_with_5 << str
elsif str[0] == '7'
starts_with_7 << str
elsif str[0] == '6'
starts_with_6 << str
elsif str[0] == '8'
starts_with_8 << str
elsif str[0] == '9'
starts_with_9 << str
else
the_rest << str
end
end
obvious + singlets + couplets + nineties + twothousands + starts_with_1 + starts_with_0 + ddmm_date + mmdd_date + mmyy_date + starts_with_2 + starts_with_3 + starts_with_4 + starts_with_5 + starts_with_7 + starts_with_6 + starts_with_8 + starts_with_9 + the_rest
end
|