Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. require 'primesieve'
  2.  
  3. 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)
  4.  
  5. def to_36(num)
  6. res = ''
  7. while num > 0
  8. res += BASE_36[num % 36]
  9. num /= 36
  10. end
  11. res
  12. end
  13.  
  14. def main(prime_count)
  15. length = 0
  16. prev = ''
  17. i = 0
  18. p 'inside main'
  19. Primesieve.generate_n_primes(prime_count, 0).each do |prime|
  20. res = to_36(prime)
  21. length += res.size
  22. i += 1
  23. next if i < 1_500_000_000
  24. comb = prev + res
  25. p "#{res} perc: #{ 100.0*i / prime_count}" if i % 100_000 == 0
  26. if comb.include?('iparty')
  27. p '================================= BINGO =========================='
  28. p length
  29. p comb
  30. p length + comb.index('iparty')
  31. return
  32. else
  33. prev = comb.size < 5 ? comb : comb[comb.size-5, comb.size-1]
  34. end
  35. end
  36. p "Length of processed: #{length}"
  37. end
  38.  
  39. main(2_000_000_000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement