Skip to main content
deleted 6 characters in body
Source Link
noodle person
  • 10.3k
  • 1
  • 22
  • 76

Uiua, 15 bytes

⍢(⊙+:÷,1+1)⋅≥.0

Try it online!

Nobody tried to beat my Uiua score in the three weeks since I posted this challenge, so I decided to just leave it here for reference.

This leaves k at the top of the stack, with the actual harmonic number below it and the input below that.

Here's the code commented with a translation to traditional imperative code:

⍢(⊙+:÷,1+1)⋅≥.0­⁡​‎⁠⁠⁠⁠⁠⁠⁠‎⁡⁠⁤⁢‏⁠‎⁡⁠⁤⁣‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠⁠⁠‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌­
             .0  # ‎⁡k = 0, H = 0, n = input
⍢(        )⋅≥    # ‎⁢while H >= n:
        +1       # ‎⁣  k += 1
  ⊙+:÷,1         # ‎⁢⁡  H += 1/k

💎

Code explanation created with the help of Luminespire.

Uiua is a stack-basedtacit language, so that translation isn't one-to-one, but it's close enough.

Uiua, 15 bytes

⍢(⊙+:÷,1+1)⋅≥.0

Try it online!

Nobody tried to beat my Uiua score in the three weeks since I posted this challenge, so I decided to just leave it here for reference.

This leaves k at the top of the stack, with the actual harmonic number below it and the input below that.

Here's the code commented with a translation to traditional imperative code:

⍢(⊙+:÷,1+1)⋅≥.0­⁡​‎⁠⁠⁠⁠⁠⁠⁠‎⁡⁠⁤⁢‏⁠‎⁡⁠⁤⁣‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠⁠⁠‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌­
             .0  # ‎⁡k = 0, H = 0, n = input
⍢(        )⋅≥    # ‎⁢while H >= n:
        +1       # ‎⁣  k += 1
  ⊙+:÷,1         # ‎⁢⁡  H += 1/k

💎

Code explanation created with the help of Luminespire.

Uiua is a stack-based language, so that translation isn't one-to-one, but it's close enough.

Uiua, 15 bytes

⍢(⊙+:÷,1+1)⋅≥.0

Try it online!

Nobody tried to beat my Uiua score in the three weeks since I posted this challenge, so I decided to just leave it here for reference.

This leaves k at the top of the stack, with the actual harmonic number below it and the input below that.

Here's the code commented with a translation to traditional imperative code:

⍢(⊙+:÷,1+1)⋅≥.0­⁡​‎⁠⁠⁠⁠⁠⁠⁠‎⁡⁠⁤⁢‏⁠‎⁡⁠⁤⁣‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠⁠⁠‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌­
             .0  # ‎⁡k = 0, H = 0, n = input
⍢(        )⋅≥    # ‎⁢while H >= n:
        +1       # ‎⁣  k += 1
  ⊙+:÷,1         # ‎⁢⁡  H += 1/k

💎

Code explanation created with the help of Luminespire.

Uiua is a tacit language, so that translation isn't one-to-one, but it's close enough.

Source Link
noodle person
  • 10.3k
  • 1
  • 22
  • 76

Uiua, 15 bytes

⍢(⊙+:÷,1+1)⋅≥.0

Try it online!

Nobody tried to beat my Uiua score in the three weeks since I posted this challenge, so I decided to just leave it here for reference.

This leaves k at the top of the stack, with the actual harmonic number below it and the input below that.

Here's the code commented with a translation to traditional imperative code:

⍢(⊙+:÷,1+1)⋅≥.0­⁡​‎⁠⁠⁠⁠⁠⁠⁠‎⁡⁠⁤⁢‏⁠‎⁡⁠⁤⁣‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠⁠⁠‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌­
             .0  # ‎⁡k = 0, H = 0, n = input
⍢(        )⋅≥    # ‎⁢while H >= n:
        +1       # ‎⁣  k += 1
  ⊙+:÷,1         # ‎⁢⁡  H += 1/k

💎

Code explanation created with the help of Luminespire.

Uiua is a stack-based language, so that translation isn't one-to-one, but it's close enough.