Skip to main content
Commonmark migration
Source Link

#Pyth, 21 20 18 bytes

Pyth, 21 20 18 bytes

hoacFN.n3C_Bf!%QTS 

Try it online. Test suite.

###Explanation

Explanation

  1. Get the incluSive range from 1 to input.
  2. filter for numbers for that divide the input !%QT.
  3. Get [that list, that list reversed] _B. The reversed divisors of a number is the same list as the number divided by each of the divisors.
  4. Transpose the list to get pairs of [numerator, denominator].
  5. Sort the pairs by the absolute difference of the ratio of the pair cFN and the golden ratio .n3.
  6. Get the first (lowest) pair h and print.

#Pyth, 21 20 18 bytes

hoacFN.n3C_Bf!%QTS 

Try it online. Test suite.

###Explanation

  1. Get the incluSive range from 1 to input.
  2. filter for numbers for that divide the input !%QT.
  3. Get [that list, that list reversed] _B. The reversed divisors of a number is the same list as the number divided by each of the divisors.
  4. Transpose the list to get pairs of [numerator, denominator].
  5. Sort the pairs by the absolute difference of the ratio of the pair cFN and the golden ratio .n3.
  6. Get the first (lowest) pair h and print.

Pyth, 21 20 18 bytes

hoacFN.n3C_Bf!%QTS 

Try it online. Test suite.

Explanation

  1. Get the incluSive range from 1 to input.
  2. filter for numbers for that divide the input !%QT.
  3. Get [that list, that list reversed] _B. The reversed divisors of a number is the same list as the number divided by each of the divisors.
  4. Transpose the list to get pairs of [numerator, denominator].
  5. Sort the pairs by the absolute difference of the ratio of the pair cFN and the golden ratio .n3.
  6. Get the first (lowest) pair h and print.
added 495 characters in body
Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 37
  • 92

#Pyth, 21 20 18 bytes

hoacFN.n3C_Bf!%QTS 

Try it online. Test suite.

###Explanation

  1. Get the incluSive range from 1 to input.
  2. filter for numbers for that divide the input !%QT.
  3. Get [that list, that list reversed] _B. The reversed divisors of a number is the same list as the number divided by each of the divisors.
  4. Transpose the list to get pairs of [numerator, denominator].
  5. Sort the pairs by the absolute difference of the ratio of the pair cFN and the golden ratio .n3.
  6. Get the first (lowest) pair h and print.

#Pyth, 21 20 18 bytes

hoacFN.n3C_Bf!%QTS 

Try it online. Test suite.

#Pyth, 21 20 18 bytes

hoacFN.n3C_Bf!%QTS 

Try it online. Test suite.

###Explanation

  1. Get the incluSive range from 1 to input.
  2. filter for numbers for that divide the input !%QT.
  3. Get [that list, that list reversed] _B. The reversed divisors of a number is the same list as the number divided by each of the divisors.
  4. Transpose the list to get pairs of [numerator, denominator].
  5. Sort the pairs by the absolute difference of the ratio of the pair cFN and the golden ratio .n3.
  6. Get the first (lowest) pair h and print.
deleted 4 characters in body
Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 37
  • 92

#Pyth, 21 2020 18 bytes

hoacFN.n3,R/Qdfn3C_Bf!%QTS 

Try it online.Try it online. Test suite.Test suite.

#Pyth, 21 20 bytes

hoacFN.n3,R/Qdf!%QTS 

Try it online. Test suite.

#Pyth, 21 20 18 bytes

hoacFN.n3C_Bf!%QTS 

Try it online. Test suite.

Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 37
  • 92
Loading