Skip to main content
added 212 characters in body
Source Link
lyxal
  • 35.6k
  • 2
  • 69
  • 148

Keg, 6 bytes

21½Ë/ℤ 

Try it online!

This defines the function f as:

  • Taking a single parameter, then
  • Calculating the square root of 2 by raising it to the power of 0.5, then
  • Dividing the parameter by root 2, then
  • Casting the result to an integer (truncating / flooring the result) and returning it.

The footer is to define the test cases in a nice way.

Explained in a usual way

21½Ë/ℤ 2 # Push 2 to the stack 1½ # Push 1 and halve it to get 0.5 Ë # Push 2 ** 0.5 (x ** 1/2 = sqrt(x)) /ℤ # Divide and cast to integer (floor) 

🍟🍅

Sorry, we're all out of ketchup. You'll have to squeeze your own.

Keg, 6 bytes

21½Ë/ℤ 

Try it online!

This defines the function f as:

  • Taking a single parameter, then
  • Calculating the square root of 2 by raising it to the power of 0.5, then
  • Dividing the parameter by root 2, then
  • Casting the result to an integer (truncating / flooring the result) and returning it.

The footer is to define the test cases in a nice way.

Keg, 6 bytes

21½Ë/ℤ 

Try it online!

This defines the function f as:

  • Taking a single parameter, then
  • Calculating the square root of 2 by raising it to the power of 0.5, then
  • Dividing the parameter by root 2, then
  • Casting the result to an integer (truncating / flooring the result) and returning it.

The footer is to define the test cases in a nice way.

Explained in a usual way

21½Ë/ℤ 2 # Push 2 to the stack 1½ # Push 1 and halve it to get 0.5 Ë # Push 2 ** 0.5 (x ** 1/2 = sqrt(x)) /ℤ # Divide and cast to integer (floor) 

🍟🍅

Sorry, we're all out of ketchup. You'll have to squeeze your own.

Source Link
lyxal
  • 35.6k
  • 2
  • 69
  • 148

Keg, 6 bytes

21½Ë/ℤ 

Try it online!

This defines the function f as:

  • Taking a single parameter, then
  • Calculating the square root of 2 by raising it to the power of 0.5, then
  • Dividing the parameter by root 2, then
  • Casting the result to an integer (truncating / flooring the result) and returning it.

The footer is to define the test cases in a nice way.