Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'primesieve'
- BASE_36 = %w(0 1 2 3 4 5 6 7 8 9 a b c d e f j h i j k l m n o p q r s t u v w x y z)
- def to_36(num)
- res = ''
- while num > 0
- res += BASE_36[num % 36]
- num /= 36
- end
- res
- end
- def main(prime_count)
- length = 0
- prev = ''
- i = 0
- p 'inside main'
- Primesieve.generate_n_primes(prime_count, 0).each do |prime|
- res = to_36(prime)
- length += res.size
- i += 1
- next if i < 1_500_000_000
- comb = prev + res
- p "#{res} perc: #{ 100.0*i / prime_count}" if i % 100_000 == 0
- if comb.include?('iparty')
- p '================================= BINGO =========================='
- p length
- p comb
- p length + comb.index('iparty')
- return
- else
- prev = comb.size < 5 ? comb : comb[comb.size-5, comb.size-1]
- end
- end
- p "Length of processed: #{length}"
- end
- main(2_000_000_000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement