This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # Goal: Create a method that takes an input number and creates a hash of its prime factors and their exponents. | |
| # e.g. prime_factorization(18) => { 2=>1, 3=>2 } #i.e. 2 * 3^2 | |
| # Logic: Take a number and divide by each prime number, and divide the resulting quotient by prime numbers, etc. to get the total factorization. | |
| # e.g. 100 = 50 * 2. | |
| # 50 = 25 * 2. | |
| # 25 = 5 * 5. | |
| # Prime factorization of 100 = 2*2*5*5 or 2^2*5^2. | |
| factors = Hash.new(0) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # Problem taken from: https://projecteuler.net/problem=11 | |
| # In the 2020 grid below, four numbers along a diagonal line have been marked in red. | |
| # The product of these numbers is 26 63 78 14 = 1788696. | |
| # What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 2020 grid? | |
| n = '08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 | |
| 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 | |
| 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 | |
| 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91 | 
NewerOlder