Possibly "Moon Duel" (1965) by Fritz Leiber, which appeared in 11th Annual Edition: The Year's Best S-F (1967). The story is available at the Internet Archive.
A guy was visiting a small moon and ran into a scary giant spider-like creature.
At the same time I was thinking how if the biped humanoid shape is
a good one for medium-size creatures on any planet, why so the spider
shape is a good one for tiny creatures and apt to turn up anywhere
and be copied in robots too.
The top hole in the sixth bubble showed me the stars, while one half
of its rim shone white with sunlight.
The guy realizes that the creature is tapping out Planck's constant and is an intelligent being.
Then the number came to me. With the butt of my Swift I rapped out
five. No answer. No scratching either. I rapped out five again.
Then the answer came, ever so faintly. Five knocked back at me.
Six five five—Planck’s Constant, the invariant quantum of energy. Oh,
it should be to the minus 29th power, of course, but I couldn’t think
how to rap that and, besides, the basic integers were all that
We each knew the other had a suit and a gun (and a lonely hole?) and
so we knew we were both intelligent and knew math. So why was our
rapping so precious?
He raised his gun—I think to rap out one, to start off pi.
The shot he fired, which has circled the tiny moonlet they are on, hits and kills the creature.
But I’ll never be sure, for just then there were two violet bursts,
close together, against the fissure wall, quite close to him.
He started to swing the muzzle of his gun toward me. At least I think
he did. He must know violet was the color of my explosions. I know I
thought someone on my side was shooting. And I must have thought he
was going to shoot me—because a violet dagger leaped from my Swift’s
muzzle and I felt its sharp recoil and then there was a violet globe
where he was standing and moments later some fragment twinged lightly
against my chest—a playful ironic tap.
He was blown apart pretty thoroughly, all his constants scattered,
Found with the Google query
"year's best" "planck's constant" "science fiction".