18 "output_type": "execute_result"
22 "load 'array-numbers.rb'"
27 "execution_count": 23,
38 "execution_count": 23,
40 "output_type": "execute_result"
44 "def sequence(n0=0, &generator)\n",
45 " Enumerator.new do |yielder|\n",
48 " yielder.yield generator.call(n)\n",
57 "execution_count": 24,
68 "execution_count": 24,
70 "output_type": "execute_result"
74 "sequence {|n| n * 2}.lazy.take(5).force"
79 "execution_count": 25,
90 "execution_count": 25,
92 "output_type": "execute_result"
96 "sequence(3) {|n| n * 2}.lazy.take(5).force"
101 "execution_count": 19,
112 "execution_count": 19,
114 "output_type": "execute_result"
118 "sequence {|n| n * 2}.lazy.select {|n| n > 20}.first"
123 "execution_count": 3,
134 "execution_count": 3,
136 "output_type": "execute_result"
140 "125874.to_digits.sort"
145 "execution_count": 4,
156 "execution_count": 4,
158 "output_type": "execute_result"
162 "(125874 * 2).to_digits.sort"
167 "execution_count": 9,
178 "execution_count": 9,
180 "output_type": "execute_result"
184 "[125874.to_digits.sort, (125874 * 2).to_digits.sort, 124578.to_digits.sort].to_set.length"
189 "execution_count": 11,
197 ":identical_multiples"
200 "execution_count": 11,
202 "output_type": "execute_result"
206 "def identical_multiples(n, max_multiplier)\n",
207 " (1..max_multiplier).map {|m| (n * m).to_digits.sort}.to_set.length == 1\n",
213 "execution_count": 18,
224 "execution_count": 18,
226 "output_type": "execute_result"
230 "identical_multiples(125874, 2)"
235 "execution_count": 26,
246 "execution_count": 26,
248 "output_type": "execute_result"
252 "sequence(1) {|n| n}.lazy.select {|n| identical_multiples n, 6}.first"
257 "execution_count": null,
267 "display_name": "Ruby 2.4.0",
272 "file_extension": ".rb",
273 "mimetype": "application/x-ruby",