Given a dimension of an SI unit, convert the Lorentz-Heaviside version of a Planck unit \$1\$ into SI metric.

What is a Planck unit?

Planck units are a set of units of measurement. It defines five fundamental constants of the universe as dimensionless \$1\$.

What is a dimension?

There are five types of fundamental dimension: L, M, T, Q, and Θ (U+0398; Greek Capital Letter Theta).

L stands for length and corresponds to SI unit m (meter).

M stands for mass and corresponds to SI unit kg (kilogram).

T stands for time and corresponds to SI unit s (second).

Q stands for electric charge and corresponds to SI unit C (Coulomb).

Θ stands for temperature and corresponds to SI unit K (Kelvin).

A dimension is a multiplicative combination of these. For example, SI unit V (volt) is same as kg·m²·C/s⁴ and thus corresponds to dimension L²MQ/T⁴.

Planck to SI

\$1\$ as Planck unit can be converted to SI metric as follows:

$$ 1 = 5.72938×10^{−35} \space [\text{m}] = 6.13971×10^{−9} \space [\text{kg}] = 1.91112×10^{−43} \space [\text{s}] = 5.29082×10^{−19} \space [\text{C}] = 3.99674×10^{31} \space [\text{K}] $$

Input and Output

A dimension is given as the input. Its type and format doesn't matter. In particular, it can be an size-5 array of signed integers, each integer representing the exponent of a fundamental dimension.

The Planck unit \$1\$ is to be converted to the SI unit that corresponds to the inputted dimension, and then outputted. The output type and format doesn't matter.


Let's say the input format is a tuple of five integers, representing L, M, T, Q, and Θ, respectively.

For example, If the input is \$(2,1,-1,-2,0)\$, it corresponds to SI unit Ohm, and thus:

$$ 1 = \frac{(5.72938×10^{−35})^2 × (6.13971×10^{−9})}{(1.91112×10^{−43})×(5.29082×10^{−19})^2} \space [\text{Ω}] $$

So the output is approximately \$376.730\$.

For another example, if the input is \$(-2,-1,3,0,1)\$, it corresponds to SI unit K/W, and thus:

$$ 1 = \frac{(1.91112×10^{−43})^3 × (3.99674×10^{31})}{(5.72938×10^{−35})^2 × (6.13971×10^{−9})} \space [\text{K/W}] $$

So the output is approximately \$1.38424×10^{−20}\$.

Note that, if the input is \$(0,0,0,0,0)\$, the output must be \$1\$.

  • \$\begingroup\$ How much precision do we need in the constants? I assume that if we use them as is, it's five digits as given. But, if our solution computes them via their logs or inverses, how accurate do we need to get? \$\endgroup\$
    – xnor
    Commented Mar 28, 2020 at 8:28
  • \$\begingroup\$ @xnor At least 5 digits, as you say. (This is why I hate floating-point numbers.) \$\endgroup\$ Commented Mar 28, 2020 at 8:36
  • 4
    \$\begingroup\$ Yeah, floats are that worst. Do you mean give digits in the numbers we use, or five digits in the result in produces? for example, if my answer computes \$5.72938×10^{−35}\$ as 10**-34.241892, where can I cut off the 34.241892? If I cut it off to five decimal places as 34.24189, then the result of 5.72941129637e-35 isn't quite accurate to five places. Sorry to be so finicky here, but this does seem to matter for answers I'm trying. \$\endgroup\$
    – xnor
    Commented Mar 28, 2020 at 9:58
  • \$\begingroup\$ @xnor Rounding to six significant digits is acceptable. \$\endgroup\$ Commented Mar 28, 2020 at 20:02
  • \$\begingroup\$ Regarding (0,0,0,0,0) producing 1: Literally "1", or a floating point representation of "1", e.g., "1.00000"? \$\endgroup\$ Commented Mar 30, 2020 at 21:55

13 Answers 13


Python 3, 118 \$\cdots\$ 85 80 bytes

Saved a whopping 29 bytes thanks to Surculose Sputum!!!
Saved 4 bytes thanks to Arnauld!!!
Saved 5 bytes thanks to xnor!!!

lambda a,b,c,d,e:399674e26**e/174539e29**a/162874e3**b/523253e37**c/189007e13**d

Try it online!

  • \$\begingroup\$ 116 bytes haha \$\endgroup\$
    – RGS
    Commented Mar 28, 2020 at 2:47
  • 1
    \$\begingroup\$ 89 bytes by doing it the vanilla way :) \$\endgroup\$ Commented Mar 28, 2020 at 4:52
  • \$\begingroup\$ Not as short as Surculose Sputum's direct solution, but another idea is to convert the problem to addition by working in log-space: Try it online! I don't know though how many digits of precision are needed in the list since the challenge doesn't say. Along similar lines, we could probably save bytes by changing some multiplications to divisions in the direct solution. \$\endgroup\$
    – xnor
    Commented Mar 28, 2020 at 8:24
  • \$\begingroup\$ @xnor Wow! You've totally blown my mind. Have to have way more coffee and see if I can figure out what's going there. :D \$\endgroup\$
    – Noodle9
    Commented Mar 28, 2020 at 11:02
  • \$\begingroup\$ @SurculoseSputum The beauty (and oft shortness) of simplicity. Sweet - thanks! :-) \$\endgroup\$
    – Noodle9
    Commented Mar 28, 2020 at 11:03

Frink, 76 bytes

f[a,b,z,d,e]:=l_P^a m_P^b(4π)^((a-b+z-e)/2)t_P^z(ℏ c epsilon0)^(d/2)T_P^e

Example usage:

376.73031366686987155 m^2 s^-3 kg A^-2 (electric_resistance)
1.3842382138391631282e-20 m^-2 s^3 kg^-1 K (thermal_resistance)

(As a bonus, it outputs a description of the unit of the result!)

Frink has the constants plancklength, planckmass, plancktime, and plancktemperature built in, with abbreviations l_P, m_P, t_P, and T_P respectively. Unfortunately, these are the Gaussian versions of the units, and the challenge specifies that we must use the Lorentz-Heaviside versions. This is a factor of \$\sqrt{4\pi}\$ conversion for each unit, which is consolidated into the (4π)^((a-b+z-e)/2) expression in the solution. (This expression is placed in the middle of the code to save a byte by letting us remove the space between m_P^b and t_P^z.)

Incidentally, is exactly as long as 4pi in UTF-8, so it doesn't actually save any bytes -- it just looks fancier. :P

Finally, Frink inexplicably lacks the built-in unit planckcharge, so we calculate the Lorentz-Heaviside version directly ourselves as (ℏ c epsilon0)^(1/2) (this time, actually saves a byte over hbar!).


Fortran (2008), 133 bytes

At least for this challenge there should be a Fortran solution.

Takes input as integer array.

real(real64)function h(I)
use iso_fortran_env
integer I(5)

A slightly longer and less accurate function uses the logarithm (stolen from @xnor):

real(real64)function f(I)
use iso_fortran_env
integer I(5)
  • 1
    \$\begingroup\$ Would be awesome if you could solve this one with Fortran! :D \$\endgroup\$
    – Noodle9
    Commented Mar 28, 2020 at 11:11
  • \$\begingroup\$ Thank you for the tip \$\endgroup\$
    – mcocdawc
    Commented Mar 28, 2020 at 11:53
  • 1
    \$\begingroup\$ You can save a few bytes by getting rid of the decimal points (e.g. 5.72938d-35 ~> 572938d-40). \$\endgroup\$
    – Arnauld
    Commented Mar 28, 2020 at 15:41
  • \$\begingroup\$ Thank you very much \$\endgroup\$
    – mcocdawc
    Commented Mar 28, 2020 at 16:08

Jelly,  35  34 bytes


A monadic Link accepting a list of the five exponents, [L, M, T, Q, Θ], which yields a floating-point number.

Try it online!


“~VHð¡ȷ‘I⁵*ד®ƬØʋ¥4ẋİ8nCaḌ’bȷ6¤*⁸P - Link: list of numbers       [L, M, T, Q, Θ]
“~VHð¡ȷ‘                           - list of code-page indices   [126, 86, 72, 24, 0, 26]
        I                          - differences                 [-40,-14,-48,-24,26]
         ⁵                         - ten                         10
          *                        - exponentiate                [1e-40, 1e-14, 1e-48, 1e-24, 1e26]
                              ¤    - nilad followed by link(s) as a nilad:
            “®ƬØʋ¥4ẋİ8nCaḌ’        -   base 250 number           572938613971191112529082399674
                            ȷ6     -   10^6                      1000000
                           b       -   convert from base         [572938,613971,191112,529082,399674]
           ×                       - multiply (vectorises)       [5.72938e-35,6.13971e-09,1.91112e-43,5.29082e-19,3.99674e31]
                                ⁸  - chain's left argument       [L, M, T, Q, Θ]
                               *   - exponentiate                [5.72938e-35^L,6.13971e-09^M,1.91112e-43^T,5.29082e-19^Q,3.99674e31^Θ]
                                 P - product                     5.72938e-35^L×6.13971e-09^M×1.91112e-43^T×5.29082e-19^Q×3.99674e31^Θ
  • \$\begingroup\$ 34 bytes by using STDIN Ɠ instead of first argument , enabling you to use for -100 instead of the _48. \$\endgroup\$ Commented Mar 30, 2020 at 19:54
  • \$\begingroup\$ @KevinCruijssen Nice & thanks; I'm going to do 34 a different way though... \$\endgroup\$ Commented Mar 30, 2020 at 22:02
  • \$\begingroup\$ Ah, using differences. Yeah, that's also a way. :) \$\endgroup\$ Commented Mar 31, 2020 at 6:28

05AB1E, 31 29 bytes


Try it online!

-2 thanks to @Kevin Cruijssen

inspired by @xnor.


•¿NkˆSSÀ¯j5ÄΣDt₁ñµ•8ô6°/₃- compressed list [-34.241893, -8.211853000000005, -42.718713, -18.276477999999997, -82.33983, -94.999995]
* multiply by the implicit input (e.g. [-68.48378600000001, -8.211852999999998, 42.718713, 36.552955999999995, 0.0])
O sum (e.g. 2.576029999999996)
° raise 10 to the power of that (e.g. 376.729821659)

Old Solution, 36 35 34 bytes


-1 thanks to @Expired Data

Try it online!


"7Q/Gy"Ç₃- compressed list [-40,-14,-48,-24,26]
* multiply (vectorize) with the implicit input - [-80, -14, 48, 48, 0]
O sum - 2
° 10^ - 100
•7“µ$₁$´*h$Ć²E• compressed number 572938613971191112529082399674
6ô split into groups of length 6 - [572938,613971,191112,529082,399674]
I push input to the stack, to get [2, 1, -1, -2, 0] [572938,613971,191112,529082,399674] 100
m power (vectorize) - [328257951844, 613971, 5.232533802168362e-6, 3.5723502030270884e-12, 1]
P product - 3.7672911312918473
* multiply - 376.72911312918473, and then implicitly output
  • \$\begingroup\$ •;sê •2ô58- can be "7Q/Gy"Ç₃- for -1 \$\endgroup\$ Commented Mar 28, 2020 at 16:05
  • \$\begingroup\$ thanks! how did you find it? I also need to update to TIO link \$\endgroup\$ Commented Mar 28, 2020 at 16:44
  • \$\begingroup\$ Well 95 is a 1 byte built in as opposed to 58 which is two and integer lists can be represented as strings and converted from ASCII if they're all in the range you need \$\endgroup\$ Commented Mar 28, 2020 at 19:24
  • \$\begingroup\$ You can remove the s before the * in your 31-byte version. \$\endgroup\$ Commented Mar 30, 2020 at 8:16
  • \$\begingroup\$ 29 bytes by also using ₃- instead of 53- with a different compressed integer. \$\endgroup\$ Commented Mar 30, 2020 at 8:28

Perl 5 -pa, 84 80 bytes

@Arnauld and I both realized that you can save bytes by removing the decimal points.


Try it online!

  • 1
    \$\begingroup\$ I was actually just working on that when you posted. \$\endgroup\$
    – Xcali
    Commented Mar 28, 2020 at 15:41

dc, 85 81 78 75 70 bytes


Try it online!

Or try a test suite that shows the sample cases listed in the challenge. (This is a bash script that runs the dc program on each test data set in turn.)

Saved 4 bytes by removing the decimal points, thanks to @Arnauld.

Had to add 1 byte also though, because I had inadvertently omitted a digit in one of the constants.

Saved 3 more bytes by changing constants to hexadecimal.

Thanks to @Noodle9 for pointing out that using division instead of multiplication can shorten this. That, plus careful attention to how many significant digits were needed throughout, yielded a savings of 5 additional bytes.

Input on stdin, one number per line, in base 16, in the following order:


This is the OP's order except the last one there is moved to the first position instead.

(The challenge says, "A dimension is given as the input. Its type and format doesn't matter." Also, hexadecimal input won't make a difference in practice given the problem domain, because we're not going to have a dimensional exponent outside the range -9 to 9. And this is allowed anyway by "Yes, I/O in unary, binary, octal, decimal or hexadecimal should be acceptable by default", which got the required support of at least 5 net votes, and at least twice as many upvotes as downvotes -- in this case, 20 upvotes, 8 downvotes, and 12 net votes.)

Output on stdout, in base 10 as usual, with lots of decimal places :) .

If you try this out, note that when you enter negative numbers in dc, they're written with an initial _ character instead of -, since - is reserved for the binary subtraction operator. And don't forget to put Θ first, and to enter them all in hexadecimal! (Output is still in decimal.)


JavaScript (ES7),  81  76 bytes

Saved 5 bytes thanks to @Noodle9

Seems like the direct formula is the shortest way... ¯\_(ツ)_/¯

Takes input as 5 distinct arguments.


Try it online!

JavaScript (ES7), 86 bytes

Using reduce() adds  5  10 bytes.

Takes input as an array.


Try it online!

  • 2
    \$\begingroup\$ 76 bytes. \$\endgroup\$
    – Noodle9
    Commented Mar 29, 2020 at 0:13

Mathematica, 260 bytes

Using a different method than the OP's. In particular, Table 2 at https://en.wikipedia.org/wiki/Planck_units#Definition

Many opportunities for cleanup (e.g., shrink name to c, saving 6 bytes), but seems pointless. Newlines and indenting are inessential and are only present for presentation. Two spaces are required, at the end of the BoltzmannConstant line and at the end of the ElectricConstant line.



convert[2, 1, -1, -2, 0]
(*  376.730 kg m^2/(s^3A^2)  *)
(*  FullForm: Quantity[376.730, ("Kilograms" ("Meters")^2)/(("Amperes")^2 ("Seconds")^3)]  *)

convert[-2, -1, 3, 0, 1]
(*  1.3842\[Times]10^-20 s^3K/(kg m^2)  *)
(*  FullForm: Quantity[1.3842\[Times]10^-20, ("Kelvins"*"Seconds"^3)/("Kilograms"*"Meters"^2)]  *)

convert[0, 0, 0, 0, 0]
(*  1.00000  *)

Notice that this code uses a curated source of consensus scientific values of the constants, and the output will change as those values change. Of relevance to the Challenge (and exemplified in the above samples), the gravitational constant is only 6.674 30(15) *10^(-11) m^3 /(kg s^2), so is only known to four significant digits. This impacts the precision of length, mass, and time (except in combinations where this term cancels) in the Challenge, although the Challenge does not acknowledge this limitation of precision in those constants.


PowerShell, 124 101 bytes

-23 bytes thanks to mazzy

$args|%{$t/=[math]::pow((174539e29,162874e3,523253e37,189007e13, 2502039161917e-44)[$i++],$_)}

Try it online.

  • 1
    \$\begingroup\$ ? Try it online! \$\endgroup\$
    – mazzy
    Commented Apr 2, 2020 at 3:55
  • 1
    \$\begingroup\$ It looks great :) what about this slightly longer answer? Try it online! \$\endgroup\$ Commented Apr 2, 2020 at 7:16
  • 1
    \$\begingroup\$ It looks nice. I don't see any good reason to use 1/const and const in the same expression at the same time, unless it shortens the expression. \$\endgroup\$
    – mazzy
    Commented Apr 2, 2020 at 10:30

Java 8, 118 bytes

Math M=null;(a,b,c,d,e)->M.pow(399674e26,e)/M.pow(174539e29,a)/M.pow(162874e3,b)/M.pow(523253e37,c)/M.pow(189007e13,d)

Port of @Noodle9's Python answer, so make sure to upvote him!!

Try it online.


TI-83 Basic, 62 tokens

Using list operations:



prod(                 Multiply all list elements together (1 token)
     { ... }          Constants in list (59 tokens)
            ^         Power using 2 lists as arguments (1 token)
             Ans      Input list stored in answer variable (1 token)


| {2,1,-1,-2,0}    | Give input
|    {2 1 -1 -2 0} |
| prgmPLANCK       | Run program
|      376.7291131 | Result

Second example unfortunately returns 0, because of insufficient precision on calculator.


Fortran (GFortran), 95 90 bytes


Try it online!

Input on stdin, output on stdout.

Thanks to @Noodle9 for saving 5 bytes by pointing out that using division instead of multiplication can shorten this.

  • \$\begingroup\$ 90 bytes. \$\endgroup\$
    – Noodle9
    Commented Mar 30, 2020 at 10:45
  • \$\begingroup\$ @Noodle9 -- Thank you! This same idea shortened my dc solution too. \$\endgroup\$ Commented Mar 31, 2020 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.