# Question
Title: Draw the "{} CODE GOLF & coding challenges" logo!
Wow, time really flies! It's already been one year since the debut of the Code Golf Stack Exchange site design. Let's celebrate this milestone with a code golf challenge... to imitate the site logo!

Golf a program that outputs a graphic of a medal enclosed in curly braces `{}`, along with two lines of text containing `CODE GOLF` and `& coding challenges`.

The medal graphic `{}` should consist of the following:

* **The medallion:** A solid-filled circle with radius `r`, surrounded by a concentric ring of the same color with an outer radius between `1.5r` and `1.6r` and a thickness between `0.2r` and `0.3r`.
* **The ribbon:** A solid-filled, horizontally symmetrical hexagon with height between `3r` and `4r` and side lengths ranging from `1.8r` to `2.4r`, placed directly above the medallion and sharing its vertical axis of symmetry.
    + A "y"-shaped cutout within the hexagon (masked out or solid-filled with the background color). This is defined by a horizontally centered, solid, downward-pointing acute isosceles triangle, with the right side extended by a line segment of thickness up to `0.3r` that intersects with the bottom left vertex of the hexagon. (The left and right sides should be co-linear with the top left and top right vertices of the hexagon, respectively.)
* **A pair of curly braces** `{` and `}` with a height between `6r` and `7r`, such that the imaginary horizontal axis that joins the "spikes" `{——}` falls below the apex of the cut-out isosceles triangle and above the medallion's outer ring.

The text output should consist of the string `CODE GOLF` above the string `& coding challenges`, with the horizontal spans of `&` and `s` falling within those of `C` and `F` respectively. You can achieve this any way you like, including, but not limited to:

* Rendering text within the image, to the right of the `{}`.
* Rendering text in a separate image, window, or GUI element.
* Printing to standard output/standard error.

To justify the text, you may add spaces uniformly between the letters and words such that the letter spacing to word spacing ratio is no more than 2/3, e.g:

```
C  O  D  E   G  O  L  F
&   coding   challenges

```

Ensure all shapes and glyphs in your output are solid-filled and non-overlapping. Optionally, color your medal `#F7CC46` gold and `#0061BA` blue (and `#004E96` blue?) for some bonus internet points!

This is ; the less bytes, the better. Be sure to include a screenshot in your answer!

---

For reference, the official SVG logo is as follows:

```
html { background: #2b2520 }
```

```
<svg xmlns="http://www.w3.org/2000/svg" height="126" viewBox="0 0 200 42" fill="none">
    <path d="M74.053 22.38c-1.561 0-2.976-.332-4.245-.994a7.756 7.756 0 0 1-2.977-2.785c-.714-1.195-1.072-2.54-1.072-4.037 0-1.497.358-2.836 1.072-4.016a7.546 7.546 0 0 1 2.977-2.785c1.269-.676 2.691-1.015 4.267-1.015 1.327 0 2.523.23 3.588.691a7.184 7.184 0 0 1 2.714 1.987L78.1 11.498c-1.036-1.18-2.32-1.77-3.851-1.77-.949 0-1.795.208-2.539.626a4.405 4.405 0 0 0-1.75 1.705c-.409.735-.613 1.57-.613 2.505 0 .935.204 1.77.613 2.504a4.556 4.556 0 0 0 1.75 1.727c.744.403 1.59.605 2.539.605 1.531 0 2.815-.598 3.851-1.792l2.276 2.072a7.085 7.085 0 0 1-2.714 2.008c-1.08.46-2.283.691-3.61.691zM89.869 22.38c-1.59 0-3.028-.339-4.311-1.015-1.27-.677-2.269-1.605-2.998-2.786-.715-1.194-1.073-2.533-1.073-4.015 0-1.483.358-2.814 1.073-3.994a7.663 7.663 0 0 1 2.998-2.807c1.283-.676 2.72-1.015 4.31-1.015 1.59 0 3.02.339 4.29 1.015a7.664 7.664 0 0 1 2.998 2.807c.729 1.18 1.094 2.511 1.094 3.994 0 1.482-.365 2.82-1.094 4.015-.73 1.18-1.73 2.109-2.998 2.785-1.27.677-2.7 1.015-4.29 1.015zm0-2.98c.904 0 1.721-.202 2.45-.605a4.444 4.444 0 0 0 1.707-1.727c.423-.734.635-1.569.635-2.504 0-.936-.212-1.77-.635-2.505a4.296 4.296 0 0 0-1.706-1.705c-.73-.418-1.547-.626-2.451-.626-.905 0-1.722.208-2.451.626a4.445 4.445 0 0 0-1.729 1.705c-.408.735-.613 1.57-.613 2.505 0 .935.205 1.77.613 2.504a4.6 4.6 0 0 0 1.729 1.727c.73.403 1.546.605 2.45.605zM100.914 7.007h6.959c1.663 0 3.129.317 4.398.95 1.284.62 2.276 1.497 2.976 2.634.715 1.137 1.072 2.462 1.072 3.973 0 1.511-.357 2.835-1.072 3.972-.7 1.137-1.692 2.022-2.976 2.656-1.269.619-2.735.928-4.398.928h-6.959V7.007zm6.784 12.242c1.531 0 2.75-.418 3.654-1.252.919-.85 1.379-1.994 1.379-3.433 0-1.44-.46-2.576-1.379-3.411-.904-.85-2.123-1.274-3.654-1.274h-3.239v9.37h3.239zM130.853 19.314v2.806h-11.86V7.007h11.576v2.807h-8.053v3.282h7.112v2.72h-7.112v3.498h8.337zM150.222 14.326h3.239v6.132c-.832.619-1.795 1.094-2.889 1.425a11.349 11.349 0 0 1-3.304.496c-1.59 0-3.02-.33-4.289-.993-1.269-.676-2.269-1.605-2.998-2.785-.715-1.195-1.072-2.54-1.072-4.037 0-1.497.357-2.836 1.072-4.016.729-1.194 1.736-2.123 3.02-2.785 1.283-.676 2.728-1.015 4.332-1.015 1.343 0 2.561.223 3.655.67a7.24 7.24 0 0 1 2.757 1.943l-2.276 2.072c-1.094-1.137-2.414-1.705-3.961-1.705-.977 0-1.845.201-2.604.604a4.37 4.37 0 0 0-1.772 1.706c-.423.734-.635 1.576-.635 2.526 0 .935.212 1.77.635 2.504a4.557 4.557 0 0 0 1.751 1.727c.758.403 1.619.605 2.582.605 1.021 0 1.94-.216 2.757-.648v-4.426zM164.172 22.38c-1.59 0-3.027-.339-4.311-1.015-1.269-.677-2.269-1.605-2.998-2.786-.715-1.194-1.072-2.533-1.072-4.015 0-1.483.357-2.814 1.072-3.994.729-1.195 1.729-2.13 2.998-2.807 1.284-.676 2.721-1.015 4.311-1.015 1.59 0 3.02.339 4.289 1.015a7.669 7.669 0 0 1 2.998 2.807c.729 1.18 1.094 2.511 1.094 3.994 0 1.482-.365 2.82-1.094 4.015-.73 1.18-1.729 2.109-2.998 2.785-1.269.677-2.699 1.015-4.289 1.015zm0-2.98c.904 0 1.721-.202 2.451-.605a4.45 4.45 0 0 0 1.707-1.727c.423-.734.634-1.569.634-2.504 0-.936-.211-1.77-.634-2.505a4.303 4.303 0 0 0-1.707-1.705c-.73-.418-1.547-.626-2.451-.626-.905 0-1.722.208-2.451.626a4.448 4.448 0 0 0-1.729 1.705c-.408.735-.612 1.57-.612 2.505 0 .935.204 1.77.612 2.504.423.734 1 1.31 1.729 1.727.729.403 1.546.605 2.451.605zM175.217 7.007h3.545V19.27h7.681v2.85h-11.226V7.007zM191.969 9.814v3.994h7.09v2.807h-7.09v5.505h-3.545V7.007H200v2.807h-8.031zM68.163 33.798c.865 0 1.564-.313 2.132-.788.557.382 1.102.649 1.635.788l.343-1.089c-.367-.104-.77-.312-1.208-.602.521-.787.9-1.678 1.161-2.628h-1.255c-.178.764-.45 1.424-.806 1.968a9.46 9.46 0 0 1-1.646-1.713c.781-.59 1.575-1.204 1.575-2.177 0-.96-.628-1.609-1.682-1.609-1.101 0-1.812.845-1.812 1.887 0 .51.19 1.1.51 1.714-.711.498-1.35 1.111-1.35 2.118 0 1.193.911 2.13 2.403 2.13zm-.426-5.974c0-.58.273-.973.687-.973.45 0 .604.313.604.718 0 .567-.438.972-.995 1.355-.19-.383-.296-.753-.296-1.1zm.592 4.943c-.722 0-1.267-.474-1.267-1.18 0-.452.249-.823.592-1.158a10.731 10.731 0 0 0 1.753 1.898c-.331.278-.699.44-1.078.44zM83.658 33.798c.83 0 1.682-.29 2.357-.857l-.569-.857c-.45.336-.994.625-1.658.625-1.148 0-1.93-.752-1.93-1.887 0-1.146.805-1.898 1.966-1.898.521 0 .983.185 1.433.544l.651-.834c-.485-.451-1.22-.799-2.155-.799-1.777 0-3.305 1.088-3.305 2.987 0 1.887 1.386 2.976 3.21 2.976zM90.239 33.798c1.528 0 2.925-1.089 2.925-2.976 0-1.898-1.397-2.987-2.925-2.987-1.528 0-2.926 1.088-2.926 2.987 0 1.887 1.398 2.976 2.926 2.976zm0-1.089c-.948 0-1.516-.752-1.516-1.887 0-1.146.568-1.898 1.516-1.898.947 0 1.516.752 1.516 1.898 0 1.135-.569 1.887-1.516 1.887zM96.902 33.798c.652 0 1.303-.36 1.753-.8h.036l.106.66h1.126v-8.173h-1.374v2.06l.07.962h-.035c-.45-.429-.936-.672-1.599-.672-1.326 0-2.57 1.135-2.57 2.987 0 1.876.995 2.976 2.487 2.976zm.332-1.1c-.888 0-1.41-.66-1.41-1.887 0-1.193.676-1.876 1.481-1.876.426 0 .829.139 1.244.521v2.559c-.403.463-.83.683-1.315.683zM104.407 33.659h1.362v-5.685h-3.885v1.054h2.523v4.63zm.58-6.727c.557 0 .971-.347.971-.891 0-.533-.414-.903-.971-.903-.557 0-.971.37-.971.903 0 .544.414.891.971.891zM108.962 33.659h1.374V29.78c.533-.532.924-.799 1.492-.799.794 0 1.09.417 1.09 1.332v3.346h1.374v-3.52c0-1.47-.616-2.304-1.954-2.304-.889 0-1.552.452-2.097.996h-.047l-.107-.857h-1.125v5.685zM118.48 36.171c2.049 0 3.352-.891 3.352-2.014 0-.996-.782-1.39-2.286-1.39h-1.184c-.723 0-1.102-.162-1.102-.532 0-.232.119-.394.355-.533.308.104.628.162.889.162 1.303 0 2.333-.671 2.333-1.933 0-.37-.178-.718-.379-.938h1.338v-1.019h-2.38a2.792 2.792 0 0 0-.912-.139c-1.279 0-2.393.741-2.393 2.05 0 .67.332 1.18.746 1.47v.046c-.426.278-.698.695-.698 1.065 0 .475.284.764.592.95v.046c-.604.324-.924.74-.924 1.192 0 1.02 1.054 1.517 2.653 1.517zm.024-5.152c-.604 0-1.102-.417-1.102-1.135 0-.694.498-1.123 1.102-1.123.604 0 1.101.429 1.101 1.123 0 .718-.497 1.135-1.101 1.135zm.142 4.272c-1.078 0-1.682-.3-1.682-.81 0-.267.154-.51.569-.741.236.058.509.08.888.08h.924c.781 0 1.172.117 1.172.556 0 .487-.734.915-1.871.915zM133.371 33.798a3.69 3.69 0 0 0 2.357-.857l-.569-.857c-.45.336-.995.625-1.658.625-1.149 0-1.931-.752-1.931-1.887 0-1.146.806-1.898 1.966-1.898.522 0 .983.185 1.434.544l.651-.834c-.486-.451-1.22-.799-2.156-.799-1.776 0-3.304 1.088-3.304 2.987 0 1.887 1.386 2.976 3.21 2.976zM137.369 33.659h1.374V29.78c.533-.532.924-.799 1.492-.799.794 0 1.09.417 1.09 1.332v3.346h1.374v-3.52c0-1.47-.616-2.304-1.954-2.304-.889 0-1.54.452-2.049.973h-.036l.083-1.216v-2.107h-1.374v8.174zM146.283 33.798c.782 0 1.564-.382 2.179-.846h.036l.107.707h1.113v-3.37c0-1.586-.888-2.454-2.499-2.454-.995 0-1.954.382-2.653.787l.497.892c.604-.324 1.256-.602 1.907-.602.948 0 1.338.475 1.386 1.111-2.866.197-4.015.834-4.015 2.107 0 .996.805 1.668 1.942 1.668zm.415-1.042c-.581 0-1.043-.22-1.043-.73 0-.613.616-1.03 2.701-1.17v1.205c-.533.417-1.078.695-1.658.695zM155.351 33.798c.675 0 1.078-.116 1.646-.325l-.319-.984c-.368.15-.687.22-.995.22-.581 0-1.043-.29-1.043-1.053v-6.171h-3.197v1.053h1.835v5.048c0 1.401.723 2.212 2.073 2.212zM162.453 33.798c.675 0 1.078-.116 1.646-.325l-.32-.984c-.367.15-.687.22-.995.22-.58 0-1.042-.29-1.042-1.053v-6.171h-3.198v1.053h1.836v5.048c0 1.401.723 2.212 2.073 2.212zM168.714 33.798c.852 0 1.658-.278 2.274-.672l-.462-.833c-.521.289-1.019.474-1.635.474-1.077 0-1.847-.51-2.001-1.563h4.275c.024-.15.06-.405.06-.671 0-1.575-.96-2.698-2.689-2.698-1.563 0-3.008 1.123-3.008 2.976 0 1.887 1.409 2.987 3.186 2.987zm-.142-4.932c.829 0 1.35.463 1.445 1.389h-3.092c.178-.915.841-1.39 1.647-1.39zM172.878 33.659h1.374V29.78c.533-.532.924-.799 1.492-.799.794 0 1.09.417 1.09 1.332v3.346h1.374v-3.52c0-1.47-.616-2.304-1.954-2.304-.889 0-1.552.452-2.097.996h-.047l-.107-.857h-1.125v5.685zM182.396 36.171c2.049 0 3.352-.891 3.352-2.014 0-.996-.782-1.39-2.286-1.39h-1.184c-.723 0-1.102-.162-1.102-.532 0-.232.119-.394.356-.533.307.104.627.162.888.162 1.303 0 2.333-.671 2.333-1.933 0-.37-.178-.718-.379-.938h1.338v-1.019h-2.38a2.792 2.792 0 0 0-.912-.139c-1.279 0-2.393.741-2.393 2.05 0 .67.332 1.18.746 1.47v.046c-.426.278-.698.695-.698 1.065 0 .475.284.764.592.95v.046c-.604.324-.924.74-.924 1.192 0 1.02 1.054 1.517 2.653 1.517zm.024-5.152c-.604 0-1.102-.417-1.102-1.135 0-.694.498-1.123 1.102-1.123.604 0 1.101.429 1.101 1.123 0 .718-.497 1.135-1.101 1.135zm.142 4.272c-1.078 0-1.682-.3-1.682-.81 0-.267.154-.51.569-.741.236.058.509.08.888.08h.924c.781 0 1.172.117 1.172.556 0 .487-.734.915-1.871.915zM190.019 33.798c.853 0 1.658-.278 2.274-.672l-.462-.833c-.521.289-1.018.474-1.634.474-1.078 0-1.848-.51-2.002-1.563h4.276a4.52 4.52 0 0 0 .059-.671c0-1.575-.959-2.698-2.689-2.698-1.563 0-3.008 1.123-3.008 2.976 0 1.887 1.409 2.987 3.186 2.987zm-.142-4.932c.829 0 1.35.463 1.445 1.389h-3.091c.177-.915.841-1.39 1.646-1.39zM196.801 33.798c1.765 0 2.724-.788 2.724-1.76 0-.903-.485-1.39-2.345-1.795-1.078-.231-1.516-.37-1.516-.775 0-.348.308-.626 1.078-.626.687 0 1.35.209 1.919.568l.627-.822c-.592-.382-1.468-.753-2.428-.753-1.634 0-2.558.706-2.558 1.702 0 .857.699 1.401 2.25 1.714 1.351.277 1.611.486 1.611.856 0 .382-.379.683-1.184.683a4.373 4.373 0 0 1-2.44-.717l-.592.845c.722.474 1.764.88 2.854.88zM45.057 36.394c.872 0 1.575-.043 2.109-.128.562-.084.998-.24 1.307-.466.309-.226.52-.538.632-.934.14-.367.211-.848.211-1.442 0-1.16-.028-2.277-.084-3.352a68.576 68.576 0 0 1-.085-3.564c0-1.612.324-2.771.97-3.479.635-.721 1.69-1.212 3.163-1.47a.101.101 0 0 0 .084-.1.101.101 0 0 0-.084-.099c-1.474-.258-2.528-.734-3.163-1.428-.646-.735-.97-1.909-.97-3.521 0-1.273.029-2.46.085-3.564.056-1.103.084-2.22.084-3.352 0-.594-.07-1.074-.21-1.442a1.69 1.69 0 0 0-.633-.933c-.31-.227-.745-.382-1.307-.467-.534-.085-1.237-.127-2.109-.127h-.074a1.655 1.655 0 0 1 0-3.31h1.592c2.699 0 4.68.439 5.946 1.316 1.265.848 1.897 2.418 1.897 4.709 0 .735-.028 1.414-.084 2.036a17.36 17.36 0 0 1-.169 1.74 310.46 310.46 0 0 0-.169 1.655 36.891 36.891 0 0 0-.042 1.824c0 .367.085.735.253 1.103.169.368.478.707.928 1.018.45.283 1.04.523 1.77.721.316.07.665.13 1.048.175 1.008.121 1.82.932 1.82 1.947 0 1.014-.813 1.822-1.818 1.96-.384.053-.733.121-1.05.203-.73.17-1.32.41-1.77.722-.45.283-.759.608-.928.976a2.627 2.627 0 0 0-.253 1.102c0 .68.014 1.302.042 1.867.057.538.113 1.09.17 1.655.084.537.14 1.103.168 1.697.056.594.084 1.273.084 2.036 0 2.291-.632 3.861-1.897 4.71-1.265.877-3.247 1.315-5.946 1.315h-1.592a1.655 1.655 0 0 1 0-3.31h.074zM14.716 36.394c-.871 0-1.574-.043-2.108-.128-.563-.084-.998-.24-1.308-.466a1.69 1.69 0 0 1-.632-.934c-.14-.367-.21-.848-.21-1.442 0-1.16.027-2.277.084-3.352.056-1.075.084-2.262.084-3.564 0-1.612-.323-2.771-.97-3.479-.635-.721-1.689-1.212-3.163-1.47a.101.101 0 0 1-.084-.1c0-.048.036-.09.084-.099 1.474-.258 2.528-.734 3.163-1.428.647-.735.97-1.909.97-3.521 0-1.273-.028-2.46-.084-3.564a65.75 65.75 0 0 1-.085-3.352c0-.594.07-1.074.211-1.442a1.69 1.69 0 0 1 .633-.933c.309-.227.745-.382 1.307-.467.534-.085 1.236-.127 2.108-.127h.074a1.655 1.655 0 1 0 0-3.31h-1.592c-2.699 0-4.68.439-5.945 1.316C5.988 5.38 5.355 6.95 5.355 9.24c0 .735.028 1.414.084 2.036.029.594.085 1.174.17 1.74.055.537.112 1.089.168 1.655.028.565.042 1.173.042 1.824 0 .367-.084.735-.253 1.103-.169.368-.478.707-.928 1.018-.45.283-1.04.523-1.77.721-.316.07-.665.13-1.048.175C.812 19.634 0 20.445 0 21.46c0 1.014.813 1.822 1.818 1.96.384.053.734.121 1.05.203.73.17 1.32.41 1.77.722.45.283.76.608.928.976.169.367.253.735.253 1.102 0 .68-.014 1.302-.042 1.867-.056.538-.113 1.09-.169 1.655-.084.537-.14 1.103-.169 1.697a21.84 21.84 0 0 0-.084 2.036c0 2.291.633 3.861 1.898 4.71 1.265.877 3.246 1.315 5.945 1.315h1.592a1.655 1.655 0 1 0 0-3.31h-.074z" fill="#fff"/>
    <path fill="#004E96" d="M23.74.772h11.663v4.597H23.74z"/>
    <path d="M35.423.772l4.991 7.225a3 3 0 0 1 .078 3.293l-6.313 10.123h-6.437L35.422.772z" fill="#0061BA"/>
    <path fill-rule="evenodd" clip-rule="evenodd" d="M29.581 41.228a9.194 9.194 0 1 0 0-18.39 9.194 9.194 0 1 0 0 18.39zm0-16.866a7.671 7.671 0 1 0 0 15.343 7.671 7.671 0 0 0 0-15.343zm-5.901 7.671a5.902 5.902 0 1 1 11.803 0 5.902 5.902 0 0 1-11.803 0z" fill="#F7CC46"/>
    <path fill-rule="evenodd" clip-rule="evenodd" d="M18.748 7.997L23.74.772l4.93 13.249-2.767 7.392h-.919L18.671 11.29a3 3 0 0 1 .077-3.293zm8.994 13.416h3.678l-1.834-4.928-1.844 4.928z" fill="#0061BA"/>
</svg>
```

# Answer
> 9 votes
# SVG, 259 bytes

```
<svg viewBox=-30,-29,200,40><text x=-26 font-size=32>{ }</text><text x=25 y=-9>CODE GOLF</text><text x=29 font-size=9>& coding challenges</text><path fill=blue d=M-4.5-24h9l4,8-4,8h-8l6-12h-5l2,4-4,8-4-8 /><g fill=gold><circle r=6.8 /><circle r=5 stroke=#fff>
```

Also including a screenshot, since this is um.. not exactly best practises and will probably not look right in all browsers.

# Answer
> 7 votes
# 05AB1E, ~~123~~ 115 bytes

```
„P122žw•·54†u%í[Ç¤õìEEÖÇćÃKõ&Ê»¦1ćÊ₂à<äć°S£ŸǝzMçqõR^ùµTÄYšαÄâ[¬Å%J#›-J(%í/ûÜN₅≠ÝmÁ∞j!i_´ÿÓÙ7žŠλ•bÀðT×…ƒËÿŠˆu…&Âïªï»

```

Try it online! Beats all other answers. Technically, there is only one other valid answer. All other answers don't meet the specifications. Outputs as a plain PBM, and outputs the text after it.

# Output (enlarged)

Actual output size is 22x32.

---

```
„P122žw•...•bÀðT×…...u…...»  # trimmed program
„P1                          # push literal
   22                        # push literal
     žw                      # push 32
       •...•                 # push 166945169634011025567565467884298025990186958890541902453598900323554121322972765574841330722535555954069208033251875962777321153953373288109249110692417567618626198556352935215968754836351913816090583315808287...
            b                # in binary...
             À               # shifted left 1 character
                 …...        # push "codeÿ golf"...
                             # (implicit) with ÿ replaced by...
               T             # 10...
              ð              # space...
                ×            # s...
                     u       # in uppercase
                      …...   # push "& coding challenges"
                          »  # join stack by newlines
                             # implicit output

```

`ðT×` can also be `9çº` to slightly increase the distance between `CODE` and `GOLF`: Try it online!

# Answer
> 5 votes
# PostScript, 432 bytes

Code (compressed version):

```
<</L{lineto}/F{closepath fill}/S{setrgbcolor}/t{translate}/N{newpath}/H/Helvetica/M{moveto}/T{M selectfont show}/C{N 0 360 arc F}>> begin 15 15 scale ({  }) H 7.2 0 2 T (CODE GOLF) H 3.6 9 4 T (& coding challenges) H 2.35 9 1 T 4.2 2.4 t .94 .8 .27 S 0 0 1.5 C 1 1 1 S 0 0 1.25 C .94 .8 .27 S 0 0 1 C 0 3 t 0 .31 .59 S N 1.55 0 M 6{60 rotate 1.55 0 L}repeat F 1 1 1 S N -.7 -1.35 M -.05 0 L -.45 .9 L .45 .9 L -.5 -1.35 L F showpage

```

Code (uncompressed version):

```
% some short-named procedures for later use
<<
  /L {lineto}
  /F {closepath fill}
  /S {setrgbcolor}
  /t {translate}
  /N {newpath}
  /H /Helvetica
  /M {moveto}
  /T {  % text fontname fontsize x y --> ---
    M selectfont show
  }
  /C {  % x y radius --> ---
    N 0 360 arc F
  }
>> begin

15 15 scale

% Draw the texts
({  }) H 7.2 0 2 T
(CODE GOLF) H 3.6 9 4 T
(& coding challenges) H 2.35 9 1 T

% Draw the medaillon
4.2 2.4 t
.94 .8 .27 S % gold
0 0 1.5 C
1 1 1 S   % white
0 0 1.25 C
.94 .8 .27 S % gold
0 0 1 C

% Draw the ribbon
0 3 t
0 .31 .59 S   % blue
N 1.55 0 M
6 {60 rotate 1.55 0 L} repeat
F
1 1 1 S  % white
N
-.7 -1.35 M
-.05 0 L
-.45 .9 L
.45 .9 L
-.5 -1.35 L
F

showpage

```

Result:

# Answer
> 5 votes
# Octave / Matlab, ~~469~~ ~~477~~ 469 bytes

* +8 To fix the size of "CODE GOLF"
* -8 by talking tiny bit more liberty with the colours and removing  `on` after `hold` (given the default state of the `hold` is `off`, calling `hold` by itself just sets it to `on`)

```
y=[1,.8,.3],b=[0,.4,.8],w=[1,1,1],hold
e='Edgecolor',n='none',r=@real,i=@imag,p=@patch,x=@text,f='FontSize'
h=1.8*exp(j*pi/3*(0:5))
p(r(h),i(h),b,e,n)
t=exp(pi*[3,-1,-5]/6j)+j
t=[t,.2*t(3),t(3)'-.3,t(3)']-.6j
p(r(t),i(t),w,e,n)
c=exp(pi*(0:98)/49j)
c=@(a,l)p(r(a*c-3.3j),i(a*c-3.3j),l,e,n)
c(1.5,y),c(1.3,w),c(1,y)
x(-4,-1,'{',f,99),x(2,-1,'}',f,99)
x(5,0,'CODE GOLF',f,49)
x(5,-3,'& coding challenges',f,31)
axis equal off,ylim([-5 2]),xlim([-4 25])
set(gcf,'Color',w)

```

Try it online!, although you don't get the figure in TIO, so here is screenshot of the one I get.

Matlab version 9.3.0.948333 (R2017b) Update 9, on macOS Catalina, 10.15.4

## Ungolfed

```
yellow = [246,204,70]/255;
blue = [0,97,186]/255;
white = [1 1 1];

hold on; % Allow multiple plots on the same axis (implicitly creates a figure)

% Make a blue hexagon
hex = exp(1i*2*pi/6*(0:5)); % Points on a hexagon
patch(real(1.8*hex),imag(1.8*hex),blue,'EdgeColor','none');

tri = exp(1i*(2*pi/3*(0:2)-3*pi/6))+1i;
tri = [tri (0.8*tri(1)+0.2*tri(3)) tri(3)'-0.3 tri(3)'];
patch(real(tri-.6i),imag(tri-.6i),white,'EdgeColor','none');

circ = exp(1i*linspace(0,2*pi,1e3)); % 100 points on a unit circle
co = -3.3i; % Offset
c = @(r,l)patch(real(r*circ+co),imag(r*circ+co),l,'EdgeColor','none');
c(1.5,yellow)
c(1.3,white)
c(1.0,yellow)

text(-4,-1,'{','FontSize',99);
text(2,-1,'}','FontSize',99);
text(5,-1.5,{'CODE GOLF','& coding challenges'},'FontSize',33)

axis equal off;
ylim([-5 2]); xlim([-4 25]);
set(gcf,'Color',white);
% grid on; box on;

```

# Answer
> 2 votes
# LaTeX + TikZ, 449 bytes

```
\documentclass[tikz]{standalone}\usetikzlibrary{shapes}\begin{document}\tikz{\path[fill]circle(1.6)(0,3)node[scale=32]{\{~\}}(0,5)node[fill,regular polygon,regular polygon sides=6,inner sep=70]{}(0,5)node[fill=white,rotate=180,regular polygon,regular polygon sides=3,inner sep=20]{};\path[fill=white,rotate=60](0.6,1.5)rectangle(5,1.8)(0,0)circle(1.4);\fill circle(1)(17,3)node[scale=9,align=left]{CODE GOLF\\\tiny\&~coding challenges};}\enddocument

```

Readable version:

```
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes}

\begin{document}
\tikz{
\path[fill]
    circle(1.6)
    (0,3)node[scale=32]{\{~\}}
    (0,5)node[fill,regular polygon,regular polygon sides=6,inner sep=70]{}
    (0,5)node[fill=white,rotate=180,regular polygon,regular polygon sides=3,inner sep=20]{};

\path[fill=white,rotate=60]
    (0.6,1.5)rectangle(5,1.8)
    (0,0)circle(1.4);

\fill
    circle(1)
    (17,3)node[scale=9,align=left]{CODE GOLF\\\tiny\&~coding challenges};
}
\enddocument

```

Outputs a PDF:

# Answer
> 2 votes
# Wolfram Language (Mathematica), 332 bytes

```
g=Graphics;r=GraphicsRow;c=RGBColor;r@{r@{Style["{",30],GraphicsColumn[{g@{c@"#0061BA",Polygon[{{15,6},{6,23},{15,40},{36,40},{43,23},{37,6},{17,6},{32,30},{19,30},{24,20}}]},g@{{c@"#F7CC46",Disk[]},{White,Thickness[.05],Circle[{0,0},.8]}}},ImageSize->Scaled[.04]],Style["}",30]},Column@{Style["CODEGOLF",15.5],"&codingChallenges"}}

```

Try it online!

# Answer
> 2 votes
# HTML + CSS, ~~958~~ ~~656~~ 588 bytes

```
<div style="display: flex; align-items:center; font-size:40px;">{

<div style="color: blue; line-height:0; transform: translate(-7px,07px); width: 32px">
  <div style="transform: scaleX(0.65); letter-spacing: -5px;">♦♦</div>
  <div style="width:16px; height:7px; background:blue; margin:-15px 0 0 15px "></div>
  <div style="transform: scale(0.47, 0.51); margin:14px 0 0 9px">▲</div>
  <div style="color: gold; font-size: 20px; margin:21px 0 0 13px">◉</div>
</div>

}<div><div style="font-size:21px">CODE GOLF</div><div style="font-size:14px">& coding challenges</div></div></div>
```

This solution works on Chrome and Safari

---
Tags: code-golf, graphical-output, geometry
---


title: Nightmare Puzzlang translator

text:
# Question
Title: Nightmare Puzzlang translator
# Background

Puzzlang is a derivative of Brainfuck, where the symbol `X` executes a BF command based on three characters on top of it, and anything else does nothing.

The following is the translation table for Puzzlang, where `X` is the literal X and `.` stands for anything else:

```
 >      <      +      -      .      ,      [      ]

..X    X..    XXX    ...    .X.    X.X    XX.    .XX
 X      X      X      X      X      X      X      X

```

Also, the entire source code wraps around both horizontally and vertically at the translation step. For example, the following code is an infinite loop:

```
XX X

```

since you can view the code like this (the dots are where the wrapped X's would go)

```
... ..
.XX X.

```

and matching with the translation table gives `+[]` for the three X's in order.

**Nightmare Puzzlang** is an evil twin of the regular Puzzlang. In Nightmare Puzzlang, each X translates into a byte based on its eight neighbors. Any non-X characters translate into nothing. The wrapping rule is the same.

Since there is no "official" specification, let's assume that the following pattern (where X denotes the one to translate)

```
abc
dXe
fgh

```

translates to `abcdefgh` in binary (X is one, non-X is zero). Then the following code

```
XX...
X..X.
X..XX
X..XX
X.XX.

```

translates to `4a b4 66 03 56 4b bf d2 6e fd c3 2c 70` in hex, or `J´fVK¿ÒnýÃ,p` as a string. Note that the resulting string will very likely have ASCII unprintables.

# Task

Translate the given Nightmare Puzzlang code into a string.

# Input & output

For input, you can take 2D array of chars, list of strings, or a single string whose lines are delimited by newlines. You can assume that the input is rectangular in shape, i.e. row lengths are equal.

For output, you can give a single string, a list of chars, or a list of charcodes.

# Test Cases

Note that the result must remain the same when any of the dots are replaced with anything else other than the capital X.

```
X (1 row, 1 column)
String: ÿ
Charcode: [255]

X. (1 row, 2 columns)
String: B
Charcode: [66]

X
. (2 rows, 1 column)
String:
Charcode: [24]

X.
.X
String: ¥¥
Charcode: [165, 165]

X.X
.X.
String: 1Œ¥
Charcode: [49, 140, 165]

X.X
XX.
X.X
String: ÓmÎµv«
Charcode: [211, 109, 206, 181, 118, 171]

X.XX.XXX..XXXX.
String: BkÖkÿÖkÿÿÖ
Charcode: [66, 107, 214, 107, 255, 214, 107, 255, 255, 214]

X.XX.XXX.XXXXX.
XX.X..XX....X..
String: cR){Ö9Z”JµÆïÖç
Charcode: [99, 173, 82, 41, 123, 214, 8, 24, 57, 90, 148, 74, 181, 198, 239, 214, 231]

X
X
X
.
.
X
.
X
X
.
X
String: ÿÿøø
Charcode: [255, 255, 248, 24, 31, 248, 31]

XX
X.
XX
.X
.X
XX
..
XX
XX
..
.X
String: º]ç]ºâG¸Xøø
Charcode: [186, 93, 231, 93, 186, 226, 71, 184, 88, 31, 31, 248, 248, 7]

XX XXX XX  XX
X  X X X X X
X  X X X X XX
X  X X X X X
XX XXX XX  XX

XXX XXX X  XX
X   X X X  X
X X X X X  XX
X X X X X  X
XXX XXX XX X
(11 rows, 13 columns, no extra padding, result has two newlines)
zôª}òªuJ½æbÂb‚cRBBBBJ½ÇCFCDcXH¸PH°H¸

æbÂBcRBBBJ½ÃFCFCbO¾UO¾UN”C
Charcode: [122, 244, 170, 125, 242, 170, 117, 74, 189, 230, 98, 194, 98, 130, 99, 82, 66, 66, 66, 66, 74, 189, 199, 67, 70, 67, 68, 99, 88, 144, 72, 184, 80, 72, 176, 72, 184, 26, 28, 16, 10, 29, 18, 2, 10, 29, 230, 98, 194, 66, 99, 82, 2, 66, 66, 66, 74, 189, 195, 70, 67, 70, 67, 98, 79, 190, 85, 79, 190, 85, 78, 148, 67]

```

# Rules

Standard rules apply. The shortest submission in bytes wins.

# Answer
> 3 votes
# APL (Dyalog Unicode), 57 bytes

```
¯1~⍨,1↓∘⍉∘⌽⍣4⊢{2 2⌷⍵:2⊥(~¯9↑5↑1)/,⍵⋄¯1}⌺3 3⊢⍉∘(¯1∘↑⍪⊢⍪1∘↑)⍣2⊢'X'=⎕

```

Try it online!

A full program which takes a binary matrix through STDIN, returns an array of codepoints.

## Explanation

`x¯1~⍨,1↓∘⍉∘⌽⍣4⊢{2 2⌷⍵:2⊥(~¯9↑5↑1)/,⍵⋄¯1}⌺3 3⊢⍉∘(¯1∘↑⍪⊢⍪1∘↑)⍣2⊢'X'=⎕`

take input

`'X'=` boolean matrix where 'X's are 1s

`⍉∘(...)⍣2⊢` do the following twice:

`¯1∘↑⍪⊢⍪1∘↑` pad each row with its wraparound on both sides

`⍉∘` and transpose

`{...}⌺3 3⊢` then, do the following for each 3x3 window:

`2 2⌷⍵:` if the middle element is 1:

`2⊥(~¯9↑5↑1)/,⍵` decode the rest of the window as binary

`⋄¯1` Otherwise, return ¯1.

`⍣4⊢` Do the following 4 times:

`1↓∘⍉∘⌽` rotate 90°, drop first row (remove the border cells)

`,` flatten into a simple array

`¯1~⍨` remove all ¯1s

# Answer
> 2 votes
# Python 3, ~~166~~ ~~162~~ 161 bytes

```
lambda p,r=range:[chr(int(''.join(str(+([n*2for n in p+p][y+i//3-1][x+i%3-1]=='X'))for i in r(9)if i-4),2))for y in r(len(p))for x in r(len(p[0]))if'X'==p[y][x]]

```

Takes as input a list of strings and returns a character array.

Try It Online!

Ungolfed (sorta):

```
def f(p):
    chars = []
    for y in range(len(p)):
        for x in range(len(p[0])):
            if p[y][x] != 'X':
                continue
            bits = []
            for i in range(9):
                if i == 4:
                    continue
                bit_x = x + i%3 - 1
                bit_y = y + i//3 - 1
                char_at_cell = [n*2for n in p+p][bit_y][bit_x]
                bit = str(+(char_at_cell=='X'))
                bits.append(bit)
            char_code = int(''.join(bits), 2)
            chars.append(chr(char_code))
    return chars

```

Edit: made shorter by 5 bytes thanks to Jo King and Jonathan Frech

# Answer
> 2 votes
# JavaScript (ES6), 159 bytes

Takes input as a 2D array of characters. Returns an array of character codes.

```
f=M=>M.map((r,y)=>r.map((v,x)=>v>f&&o.push([...'22211000'].map((k,j)=>s|=(M[(y+h+~-k)%h][(x+w+~-'21020'[j%5])%w]>f)<<j,h=M.length,w=M[s=0].length)|s)),o=[])&&o

```

Try it online!

### Commented

```
f = M =>                        // f = main function taking the input matrix
                                //     it is named because we are later using '>f'
  M.map((r, y) =>               // for each row r[] at position y in M[]:
    r.map((v, x) =>             //   for each value v at position x in r[]:
      v > f &&                  //     ignore this cell if v is not equal to 'X'
      o.push(                   //     otherwise, push a new value in o[]:
        [...'22211000']         //       iterate over dy values (+1)
        .map((k, j) =>          //       for each value k at position j in this array:
          s |= (                //         update s:
            M[(y + h +          //           compute the row
              ~-k)              //           by adding dy = k - 1
              % h]              //           and applying a modulo h
            [(x + w +           //           compute the column
              ~-'21020'[j % 5]) //           by adding dx = [2,1,0,2,0,2,1,0][j] - 1
              % w]              //           and applying a modulo w
            > f                 //           test whether this cell is a 'X'
          ) << j,               //         and set the corresponding bit in s if it is
          h = M.length,         //         initialize h = matrix height
          w = M[s = 0].length   //         initialize w = matrix width and s = bitmask
        ) | s                   //       end of map() over dy; yield s
      )                         //     end of push()
    ),                          //   end of map over r[]
    o = []                      //   initialize o = output array
  ) && o                        // end of map over M[]; return o

```

# Answer
> 1 votes
# Jelly, 19 bytes

```
=”Xµ-r1p`ẸƇ+ⱮŒṪœịµḄ

```

A monadic Link that accepts a list of the lines and yields a list of code-points.

**Try it online!**

### How?

```
=”Xµ-r1p`ẸƇ+ⱮŒṪœịµḄ - Link: lines
 ”X                 - character = 'X'
=                   - equals? -> binary matrix from lines with X:1 and .:0
   µ             µ  - monadic chain - f(v=that):
    -               -   -1
      1             -   1
     r              -   inclusive range = [-1, 0, 1]
        `           -   use as both arguments of:
       p            -     Cartesian product
                               = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,0],[0,1],[1,-1],[1,0],[1,1]]
          Ƈ         -   keep those for which:
         Ẹ          -     any? = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]
             ŒṪ     -   multidimensional truthy indices (v)
            Ɱ       -   map across these with:
           +        -     add
               œị   -   index into (v)
                  Ḅ - convert from binary

```

---
Tags: code-golf, grid
---


title: The Arithmetic Derivative

text:
# Question
Title: The Arithmetic Derivative
The derivative of a function is a cornerstone of mathematics, engineering, physics, biology, chemistry, and a large number of other sciences as well. Today we're going to be calculating something only tangentially related: the arithmetic derivative.

# Definition

The arithmetic derivative `a(n)` or `n'` is defined here (A003415) by a number of properties that are similar to the derivative of a function.

* `a(0) = a(1) = 0`,
* `a(p) = 1`, where `p` is any prime, and
* `a(mn) = m*a(n) + n*a(m)`.

The third rule is based on the product rule for differentiation of functions: for functions `f(x)` and `g(x)`, `(fg)' = f'g + fg'`. So with numbers, `(ab)' = a'b + ab'`.

Also of note, since the arithmetic derivative can be extended to the negative numbers via this simple relation, `a(-n) = -a(n)`, the input may be negative.

# Rules

* Write a program or function that, given any integer `n`, returns the arithmetic derivative of `n`.
* Inputs will be `-2<sup>30</sup> < n < 2<sup>30</sup>`, to avoid problems with integer sizes and numbers too large to factor in a reasonable amount of time. Your algorithm should still be able to theoretically calculate the arithmetic derivative of numbers outside this range.
* Built-ins for symbolic math, prime factorization and differentiation are allowed.

# Examples

```
> a(1)
0
> a(7)
1
> a(14)   # a(7)*2 + a(2)*7 = 1*2 + 1*7 = 9
9
> a(-5)   # a(-5) = -a(5) = -1
-1
> a(8)    # a(8) = a(2**3) = 3*2**2 = 12
12
> a(225)  # a(225) = a(9)*25 + a(25)*9 = 6*25 + 10*9 = 150 + 90 = 240
240
> a(299792458)  # a(299792458) = a(2)*149896229 + a(7)*42827494 + a(73)*4106746 + a(293339)*1022 = 1*149896229 + 1*42827494 + 1*4106746 + 1*1022 = 149896229 + 42827494 + 4106746 + 1022 = 196831491
196831491

```

As always, if the problem is unclear, please let me know. Good luck and good golfing!

# Answer
> 11 votes
# MATL, 12 bytes

```
|1>?GtYf/s}0

```

**Try it online!**

### Explanation

Consider an integer *a* with |*a*|\>1, and let the (possibly repeated) prime factors of |*a*| be *f*1, ..., *f**n*. Then the desired result is *a*·(1/*f*1 \+ ... + 1/*f**n*).

```
|1>     % take input's absolute value. Is it greater than 1?
?       % if so:
  Gt    %   push input twice
  Yf    %   prime factors. For negative input uses its absolute value
  /     %   divide element-wise
  s     %   sum of the array
}       % else:
  0     %   push 0

```

# Answer
> 9 votes
## Python, 59 bytes

```
f=lambda n,p=2:+(n*n>1)and(n%p and f(n,p+1)or p*f(n/p)+n/p)

```

A recursive function. On large inputs, it runs out of stack depth on typical systems unless you run it with something like Stackless Python.

The recursive definition is implemented directly, counting up to search for candidate prime factors. Since `f(prime)=1`, if `n` has a prime `p` as a factor, we have `f(n) == p*f(n/p)+n/p`.

# Answer
> 8 votes
# Jelly, ~~8~~ 7 bytes

*-1 byte by @Dennis*

```
ÆfḟṠ³:S

```

Uses the same formula everyone else does. However, there's a little trick to deal with `0`.

```
o¬AÆfİS×     Main link. Inputs: n
o¬             Logical OR of n with its logical NOT
               That is, 0 goes to 1 and everything else goes to itself.
  A            Then take the absolute value
   Æf          get its list of prime factors
     İ         divide 1 by those
      S        sum
       ×       and multiply by the input.

```

Try it here.

# Answer
> 5 votes
## Python 2, ~~87~~ ~~78~~ ~~76~~ 74 bytes

```
a=b=input()
d=2
s=0
while d<=abs(b):
    if a%d==0:
        a=a/d
        s+=b/d
    else:
        d+=1
print s

```

Improvements thanks to @Maltysen:

```
a=b=input()
d=2
s=0
while d<=abs(b):
    if a%d==0:a/=d;s+=b/d
    else:d+=1
print s

```

Further improvement by two bytes:

```
a=b=input()
d=2
s=0
while abs(a)>1:
    if a%d<1:a/=d;s+=b/d
    else:d+=1
print s

```

Further improvement thanks to @xnor:

```
a=b=input()
d=2
s=0
while a*a>1:
    if a%d<1:a/=d;s+=b/d
    else:d+=1
print s

```

### Explanation

The arithmetic derivative of `a` is equal to `a` times the sum of the reciprocals of the prime factors of `a`. No exception for 1 is needed since the sum of the reciprocals of the prime factors of 1 is zero.

# Answer
> 4 votes
# J, ~~30~~ ~~27~~ 19 chars

Thanks to @Dennis for chopping off 3 characters.

Thanks to @Zgarb for chopping off 8 characters.

```
0:`(*[:+/%@q:@|)@.*

```

Try it online!

Sample input:

```
0:`(*[:+/%@q:@|)@.* _8
_12

0:`(*[:+/%@q:@|)@.* 0
0

0:`(*[:+/%@q:@|)@.* 8
12

```

How it works:

```
0:`(*[:+/%@q:@|)@.* N
XX`YYYYYYYYYYYYY@.Z   if Z then Y else X end
0:                        X:  return 0
                  Z       Z:  signum(N)
   (*[:+/%@q:@|)          Y:  N*add_all(reciprocal_all(all_prime_factors(abs(N))))
                              N
    *                          *
      [:+/                      add_all(                                         )
          %@                            reciprocal_all(                         )
            q:@                                       all_prime_factors(      )
               |                                                        abs( )
                                                                            N

```

# Answer
> 4 votes
# Haskell, ~~203~~ 90 bytes

Thanks @nimi!

I still have no idea when what indentations cause what interpretation, this is the shortest I managed so far, and as always, I'm sure it can be golfed a lot more. I'm going to try again in the evening.

```
n#(x:_)|y<-div n x=x*a y+y*a x;_#_=1
a n|n<0= -a(-n)|n<2=0|1<2=n#[i|i<-[2..n-1],mod n i<1]

```

# Answer
> 3 votes
# Pyth - ~~10~~ 8 bytes

Lovin' the implicit input! Should bring it on par with Jelly for most things (Except Dennis' golfing skills).

```
*scL1P.a

```

Test Suite.

```
*             Times the input, implicitly (This also adds the sign back in)
 s            Sum
  cL1         Reciprocal mapped over lit
   P          Prime factorization
    .a        Absolute value of input, implicitly

```

# Answer
> 3 votes
## Haskell, 59 bytes

```
n%p|n*n<2=0|mod n p>0=n%(p+1)|r<-div n p=r+p*r%2
(%2)

```

Implements the recursive definition directly, with an auxiliary variable `p` that counts up to search for potential prime factors, starting from `2`. The last line is the main function, which plugs `p=2` to the binary function defined in the first line.

The function checks each case in turn:

* If `n*n<2`, then `n` is one of `-1,0,1`, and the result is `0`.
* If `n` is not a multiple of `p`, then increment `p` and continue.
* Otherwise, express `n=p*r`, and by the "derivative" property, the result is `r*a(p)+p*a(r)`, which simplifies to `r+p*a(r)` because `p` is prime.

The last case saves bytes by binding `r` in a guard, which also avoids the `1>0` for the boilerplate `otherwise`. If `r` could be bound earlier, the second condition `mod n p>0` could be checked as `r*p==n`, which is 3 bytes shorter, but I don't see how to do that.

# Answer
> 3 votes
# APL (Dyalog Extended), ~~13~~ 9 bytes

A simple solution. The Dyalog Unicode version was simply a longer version of this so it has been omitted.

**Edit:** Saved 4 bytes by adopting the method in lirtosiast's Jelly solution.

```
{+/⍵÷⍭|⍵}

```

Try it online!

**Ungolfing**

```
{+/⍵÷⍭|⍵}

{        }  A dfn, a function in {} brackets.
     ⍭|⍵   The prime factors of the absolute value of our input.
   ⍵÷      Then divide our input by the above array,
            giving us a list of products for the product rule.
 +/         We sum the above numbers, giving us our arithmetic derivative.

```

# Answer
> 3 votes
# Japt -x, ~~16~~ ~~13~~ 10 bytes

```
ÒU©a k £/X

```

*\- 6 bytes thanks to @Shaggy*

Try it online!

# Answer
> 2 votes
# Ruby, ~~87~~ ~~66~~ ~~80~~ ~~75~~ ~~70~~ 68 bytes

This answer is based on Luis Mendo's MATL answer, wythagoras's Python answer, and the idea that the arithmetic derivative of a number `m` is equal to `m·(1/p<sub>1</sub> + 1/p<sub>2</sub> + ... + 1/p<sub>n</sub>)` where `p<sub>1</sub>...p<sub>n</sub>` is every prime factor of `n` to multiplicity.

```
->n{s=0;(2...m=n.abs).map{|d|(m/=d;s+=n/d)while m%d<1};m<2?0:s+0**s}

```

This function is called in the following way:

```
> a=->n{s=0;(2...m=n.abs).map{|d|(m/=d;s+=n/d)while m%d<1};m<2?0:s+0**s}
> a[299792458]
196831491

```

**Ungolfing:**

```
def a(n)
  s = 0
  m = n.abs
  (2...m).each do |z|
    while m%d == 0
      m /= d
      s += n / d
    end
  end
  if s == 0
    if n > 1
      s += 1 # if s is 0, either n is prime and the while loop added nothing, so add 1
             # or n.abs < 2, so return 0 anyway
             # 0**s is used in the code because it returns 1 if s == 0 and 0 for all other s
    end
  end
  return s
end

```

# Answer
> 2 votes
# Julia, ~~72~~ 43 bytes

```
n->n^2>1?sum(p->n÷/(p...),factor(n^2))/2:0

```

This is an anonymous function that accepts an integer and returns a float. To call it, assign it to a variable.

For an input integer *n*, if *n*2 ≤ 1 return 0. Otherwise obtain the prime factorization of *n*2 as a `Dict`, then for each prime/exponent pair, divide the prime by its exponent, then divide *n* by the result. This is just computing *n* *x* / *p*, where *p* is the prime factor and *x* is its exponent, which is the same as summing *n* / *p*, *x* times. We sum the resulting array and divide that by 2, since we've summed twice as much as we need. That's due to the fact that we're factoring *n*2 rather than *n*. (Doing that is a byte shorter than factoring |*n*|.)

Saved 29 bytes thanks to Dennis!

# Answer
> 2 votes
# Seriously, ~~17~~ ~~14~~ ~~11~~ 12 bytes

My first ever Seriously answer. This answer is based on Luis Mendo's MATL answer and the idea that the arithmetic derivative of a number `m` is equal to `m·(1/p<sub>1</sub> + 1/p<sub>2</sub> + ... + 1/p<sub>n</sub>)` where `p<sub>1</sub>...p<sub>n</sub>` is every prime factor of `n` to multiplicity. My addition is to note that, if `m = p<sub>1</sub><sup>e<sub>1</sub></sup>·p<sub>2</sub><sup>e<sub>2</sub></sup>·...·p<sub>n</sub><sup>e<sub>n</sub></sup>`, then `a(m) = m·(e<sub>1</sub>/p<sub>1</sub> + e<sub>2</sub>/p<sub>2</sub> + ... + e<sub>n</sub>/p<sub>n</sub>)`. Thanks to Mego for golfing and bug fixing help. Try it online!

```
,;w`i@/`MΣ*l

```

**Ungolfing:**

```
,             get a single input
 ;w           duplicate input and get prime factorization, p_f
               for input [-1..1], this returns [] and is dealt with at the end
   `   `M     map the function inside `` to p_f
    i         pop all elements of p_f[i], the prime and the exponent, to the stack
     @        rotate so that the exponent is at the top of the stack
      /       divide the exponent by the prime
         Σ    sum it all together
          *   multiply this sum with the input
           l  map and multiply do not affect an empty list, so we just take the length, 0
               l is a no-op for a number, so the result is unchanged for all other inputs

```

# Answer
> 1 votes
# Mathematica 10.0, 39 bytes

```
Tr[If[#>1,#2/#,0]&@@@FactorInteger@#]#&

```

# Answer
> 1 votes
# Jolf, 13 bytes

```
*jmauΜm)jd/1H

```

Kudos to the MATL answer for the algorithm! Try it here, or test them all at once. (Outputs \[key,out\] in an array.)

## Explanation

```
*jmauΜm)jd/1H
*j             input times
      m)j         p.f. of input
     Μ   d/1H      mapped to inverse
    u            sum of
  ma            abs of

```

# Answer
> 1 votes
# APL(NARS), 35 char, 70 bytes

```
{1≥a←∣⍵:0⋄1=≢k←πa:×⍵⋄c+m×∇c←⍵÷m←↑k}

```

test and how to use:

```
  f←{1≥a←∣⍵:0⋄1=≢k←πa:×⍵⋄c+m×∇c←⍵÷m←↑k}
  f 14
9
  f 8
12
  f 225
240
  f ¯5
¯1
  f 299792458
196831491

```

I thought that it would not be ok because I don't know if c variable is composed (and not a prime)... But seems ok for the test...

# Answer
> 1 votes
# 05AB1E, ~~7~~ 4 bytes

```
ÄÒ÷O

```

Port of *@lirtosiast*'s Jelly answer.

Try it online or verify all test cases.

**Explanation:**

```
Ä     # Take the absolute value of the (implicit) input
 Ò    # Get all its prime factors (with duplicates)
  ÷   # Integer divide the (implicit) input by each of these prime factors
   O  # And take the sum (which is output implicitly)

```

# Answer
> 1 votes
# Pari/GP, 44 bytes

```
n->n*vecsum([i[2]/p|i<-factor(n)~,0<p=i[1]])

```

Try it online!

# Answer
> 1 votes
# Vyxal `s`, 3 bytes

```
ȧǐ/

```

Try it Online!

```
ȧ   # Abs. val
 ǐ  # All prime factors
    # (Implicit input)
  / # Divided by each factor.
    # (s flag) sum of stack

```

-1 thx to Underslash

# Answer
> 0 votes
# Perl 5, 62 bytes

```
perl -MMath::Prime::Util=:all -E"map$i+=1/$_,factor abs($j=<>);say$i*$j"

```

Uses the formula (from OEIS): `If n = Product p_i^e_i, a(n) = n * Sum (e_i/p_i).`

# Answer
> 0 votes
## Perl 6, 90

```
sub A(\n) {0>n??-A(-n)!!(n>1)*{$_??n/$_*A($_)+$_*A n/$_!!1}(first n%%*,2..^n)};say A slurp

```

This might be a bit slow for large numbers. Replace `2..^n` with `2..n.sqrt` for longer code but faster computation.

# Answer
> 0 votes
# Ink, 183 bytes

```
==function a(n)
{n<0:
~return-a(-n)
}
{n<2:
~return 0
}
~temp f=t(n,2)
{f:
~return a(n/f)*f+n/f
}
~return 1
==function t(n,i)
{n>1&&n-i:
{n%i:
~return t(n,i+1)
}
~return i
}
~return 0

```

Try it online!

I refuse to believe this is a good solution, but I can't see a way to improve it either.

---
Tags: code-golf, math, sequence, arithmetic, number-theory
---


title: Print the f × f times table

text:
# Question
Title: Print the f × f times table
Your task is to print the hexidecimal times table:

```
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
00 02 04 06 08 0a 0c 0e 10 12 14 16 18 1a 1c 1e
00 03 06 09 0c 0f 12 15 18 1b 1e 21 24 27 2a 2d
00 04 08 0c 10 14 18 1c 20 24 28 2c 30 34 38 3c
00 05 0a 0f 14 19 1e 23 28 2d 32 37 3c 41 46 4b
00 06 0c 12 18 1e 24 2a 30 36 3c 42 48 4e 54 5a
00 07 0e 15 1c 23 2a 31 38 3f 46 4d 54 5b 62 69
00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78
00 09 12 1b 24 2d 36 3f 48 51 5a 63 6c 75 7e 87
00 0a 14 1e 28 32 3c 46 50 5a 64 6e 78 82 8c 96
00 0b 16 21 2c 37 42 4d 58 63 6e 79 84 8f 9a a5
00 0c 18 24 30 3c 48 54 60 6c 78 84 90 9c a8 b4
00 0d 1a 27 34 41 4e 5b 68 75 82 8f 9c a9 b6 c3
00 0e 1c 2a 38 46 54 62 70 7e 8c 9a a8 b6 c4 d2
00 0f 1e 2d 3c 4b 5a 69 78 87 96 a5 b4 c3 d2 e1

```

# Specifications:

* You can print the hex values in uppercase.
* Your lines can end with a trailing space and the program output can end with a trailing newline.
* Every hex value must be padded to 2 digits with `0`s as shown.

This is , so the shortest answer (measured in bytes) wins.

# Answer
# Stax, 11 bytes

```
äΔ←ùûv╚ö♦.J

```

Run and debug it
> 2 votes

# Answer
# Jelly, 12 bytes

```
⁴Ḷ×þ`d⁴‘ịØhG

```

Try it online!

### How it works

```
⁴Ḷ×þ`d⁴‘ịØhG  Main link. No arguments.

⁴             Set the return value to 16.
 Ḷ            Unlength; yield [0, ..., 15].
  ×þ`         Build the multiplication table of [0, ..., 15] and itself.
     d⁴       Divmod 16; yield [p : 16, p % 16] for each product p.
       ‘      Increment quotients and remainders (1-based indexing).
        ịØh   Index into the lowercase hexadecimal alphabet.
           G  Grid; join columns by spaces, rows by newlines.

```
> 14 votes

# Answer
# Python 2, 60 bytes

```
for n in range(256):r=n%16;print'%02x%s'%(n/16*r,r/15*'\n'),

```

Try it online!

### How it works

For all integers **n** from **0** to **255**, we do the following.

* We compute **(n / 16) × (n % 16)**.

Over the range of **n**, both **n / 16** and **n % 16** independently cover the range **0, …, 15**, so this generates all entries of the multiplication table.
* We repeat the linefeed character (`'\n'`) **(n % 16) / 15** times, which results in the same character when **n % 16 = 15** and an empty string otherwise.
* The format string `'%02x%s'` turns the two previous results into a single string, first a lowercase hexadecimal integer representation, zero-padded to (at least) two digits, then the generated string.
* Finally, `print...,` prints the formatted results.

Since the print statement ends with a comma, Python will not append a linefeed. Also, before printing the next string, Python will prepend a space *unless* we're at the beginning of a new line. (source) This happens to format the output exactly like we want to.
> 14 votes

# Answer
# R, 42 bytes

```
as.hexmode(sapply(0:15,function(x)x*0:15))

```

Prints the following:

```
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16]
 [1,] "00" "00" "00" "00" "00" "00" "00" "00" "00" "00"  "00"  "00"  "00"  "00"  "00"  "00"
 [2,] "00" "01" "02" "03" "04" "05" "06" "07" "08" "09"  "0a"  "0b"  "0c"  "0d"  "0e"  "0f"
 [3,] "00" "02" "04" "06" "08" "0a" "0c" "0e" "10" "12"  "14"  "16"  "18"  "1a"  "1c"  "1e"
 [4,] "00" "03" "06" "09" "0c" "0f" "12" "15" "18" "1b"  "1e"  "21"  "24"  "27"  "2a"  "2d"
 [5,] "00" "04" "08" "0c" "10" "14" "18" "1c" "20" "24"  "28"  "2c"  "30"  "34"  "38"  "3c"
 [6,] "00" "05" "0a" "0f" "14" "19" "1e" "23" "28" "2d"  "32"  "37"  "3c"  "41"  "46"  "4b"
 [7,] "00" "06" "0c" "12" "18" "1e" "24" "2a" "30" "36"  "3c"  "42"  "48"  "4e"  "54"  "5a"
 [8,] "00" "07" "0e" "15" "1c" "23" "2a" "31" "38" "3f"  "46"  "4d"  "54"  "5b"  "62"  "69"
 [9,] "00" "08" "10" "18" "20" "28" "30" "38" "40" "48"  "50"  "58"  "60"  "68"  "70"  "78"
[10,] "00" "09" "12" "1b" "24" "2d" "36" "3f" "48" "51"  "5a"  "63"  "6c"  "75"  "7e"  "87"
[11,] "00" "0a" "14" "1e" "28" "32" "3c" "46" "50" "5a"  "64"  "6e"  "78"  "82"  "8c"  "96"
[12,] "00" "0b" "16" "21" "2c" "37" "42" "4d" "58" "63"  "6e"  "79"  "84"  "8f"  "9a"  "a5"
[13,] "00" "0c" "18" "24" "30" "3c" "48" "54" "60" "6c"  "78"  "84"  "90"  "9c"  "a8"  "b4"
[14,] "00" "0d" "1a" "27" "34" "41" "4e" "5b" "68" "75"  "82"  "8f"  "9c"  "a9"  "b6"  "c3"
[15,] "00" "0e" "1c" "2a" "38" "46" "54" "62" "70" "7e"  "8c"  "9a"  "a8"  "b6"  "c4"  "d2"
[16,] "00" "0f" "1e" "2d" "3c" "4b" "5a" "69" "78" "87"  "96"  "a5"  "b4"  "c3"  "d2"  "e1"

```
> 11 votes

# Answer
# Bash + coreutils, 40

* 1 byte saved thanks to @MitchellSpector

```
printf %02x\  $[{0..15}*{0..15}]|fmt -52

```
* Bash expands brace expansions before arithmetic expansions, so the string `$[{0..15}*{0..15}]` first expands to `$[0*0] $[0*1] $[0*2] ... $[0*15] $[1*0] ... $[15*15]`.
* The above series of arithmetic expansions then expand to the numerical table contents, as decimal integers.
* The `printf '%02x '` expresses this list of decimal integers as hex, zero-padded to two characters
* `fmt -52` formats the integers as 47 character wide lines, giving the desired alignment. Note `fmt` tries to make lines *goal* characters wide. By default, this is 7% shorter than width. 52\*93% -1 (for newline) = 47.

Try it online.
> 10 votes

# Answer
## C#6, 98 bytes

```
()=>{int i,j;for(i=-1;++i<16;)for(j=-1;++j<16;)System.Console.Write($"{i*j:x2} {j<15?"":"\n"}");};

```

repl.it demo

Standard nested for-loop. Only trick is to print newline when j\>=15.
> 5 votes

# Answer
## JavaScript (ES6), ~~79~~ ~~78~~ 77 bytes

```
f=(i=256)=>i?f(--i)+(i%16*(i>>4)+256).toString(16).slice(1)+`
 `[~i&15&&1]:``

document.write('<pre>'+f())
```

Edit: Saved 1 byte thanks to @ETHproductions and another byte thanks to @YairRand.
> 4 votes

# Answer
# MATL, ~~19~~ 18 bytes

```
16:q&*1YAO3Z(!48e!

```

Try it online!

```
16:q   % Push [0 1 ... 15]
&*     % 16×16 matrix of pairwise products
1YA    % Convert to hexadecimal. Gives a 256×2 char array
O3Z(   % Assign char 0 to 3rd column. Gives a 256×3 char array
!48e!  % Reshape in row-major order as a 48-column char array
       % Implicitly display. Char 0 is shown as space

```
> 3 votes

# Answer
# PowerShell, 46 bytes

```
0..15|%{$i=$_;"$(0..15|%{"{0:X2}"-f($i*$_)})"}

```

Try it online!

Loops from `0` to `15`, sets `$i` to be that current number, then loops again. Uses the `-f`ormat operator with the `X2` designation to specify the output is he`X`adecimal padded to `2` spaces with leading zeros.

Of special note, and really the only golf, is that instead of using a `(...)-join' '` to take the hex results, encapsulate them in an array, and concatenate them together into a string, we leverage the fact that the default `$OutputFieldSeparator` value for stringifying an array is a space. That means we can do a string with a script block in it `"$(...)"` instead, saving 6 bytes.

Those strings are all left on the pipeline, and output via implicit `Write-Output` at program completion gives us a newline between them for free.
> 3 votes

# Answer
# Haskell, 87 bytes

```
import Numeric
main=mapM(\x->putStrLn$do y<-s;['0'|x*y<16]++showHex(x*y)" ")s
s=[0..15]

```

Try it online!

I imagine there's a better way. Maybe depend on the `printf` package....
> 3 votes

# Answer
**K7, 36 bytes**

```
` 0:" "/:'{`hex@`c$x}''{x*/:\:x}@!16

```
> 3 votes

# Answer
# Ruby, 49 bytes

```
256.times{|i|print"%02x "%(i/16*j=i%16),$/*j/=15}

```

Pretty straightforward use of the `%` operator equivalent to `sprintf`.

`$/` is the line separator variable (`\n` by default.)

Note the use of assignments such as `j/=15` to avoid longer parentheses `(j/15)`
> 2 votes

# Answer
# Mathematica, 46 bytes

```
Grid@Array[IntegerString[1##,16,2]&,{16,16},0]

```

Straightforward implementation using the built-in `IntegerString`, in base `16`, padding to length `2`. The `Array[...,{16,16},0]` has the two variables each run from 0 to 15.
> 2 votes

# Answer
# Matlab, 53 Bytes

```
for i=[0:15]'*[0:15];fprintf('%02X ',i);disp(' ');end

```

Sample output:

```
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E
00 03 06 09 0C 0F 12 15 18 1B 1E 21 24 27 2A 2D
00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C
00 05 0A 0F 14 19 1E 23 28 2D 32 37 3C 41 46 4B
00 06 0C 12 18 1E 24 2A 30 36 3C 42 48 4E 54 5A
00 07 0E 15 1C 23 2A 31 38 3F 46 4D 54 5B 62 69
00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78
00 09 12 1B 24 2D 36 3F 48 51 5A 63 6C 75 7E 87
00 0A 14 1E 28 32 3C 46 50 5A 64 6E 78 82 8C 96
00 0B 16 21 2C 37 42 4D 58 63 6E 79 84 8F 9A A5
00 0C 18 24 30 3C 48 54 60 6C 78 84 90 9C A8 B4
00 0D 1A 27 34 41 4E 5B 68 75 82 8F 9C A9 B6 C3
00 0E 1C 2A 38 46 54 62 70 7E 8C 9A A8 B6 C4 D2
00 0F 1E 2D 3C 4B 5A 69 78 87 96 A5 B4 C3 D2 E1

```
> 2 votes

# Answer
# Perl, 48 bytes

```
for$a(@%=0..15){printf"%02x "x@%.$/,map$a*$_,@%}

```

Try it online!

I'm positive this isn't optimally golfed, but I'll be damned if I can find something better.

### Code breakdown:

```
for$a(@%=0..15){printf"%02x "x@%.$/,map$a*$_,@%}
         0..15                                    #Create a list of the range 0 - 15...
      @%=                                         #...and store it in the array @%
for$a(        ){                               }  #Loop through @% with $a as the iterator
                printf[  string   ],[ params  ]   #Perl's port of the standard printf function
                      "%02x "                     #2-digit (hexit?) padding, followed by space...
                             x@%                  #...repeated 16 times (in scalar context, @% represents the size of array @%)...
                                .$/               #...followed by a newline
                                     map$a*$_,@%  #Loops through @%, and using $_ as the iterator, returns a list composed of each member of @% multiplied by the current $a

```
> 2 votes

# Answer
# Perl 6, 42 bytes

```
.fmt("%02x").put for (^16 X*^16).rotor: 16

```

Try it

## Expanded:

```
.fmt("%02x") # format each element of list to lowercase hex
.put         # print with trailing newline

for          # for each of the following

(
  ^16  # Range upto ( and excluding ) 16
  X*   # cross multiplied with
  ^16
).rotor: 16 # break it up into chunks of 16 values

```
> 2 votes

# Answer
# C, ~~68~~ 66 bytes

```
f(i){for(i=0;i<256;)printf("%02x%c",i%16*(i++/16),i%16<15?32:10);}

```

-2 bytes thanks to ceilingcat!

Ungolfed:

```
f(i){
  for(i=0; i<256;)
    printf("%02x%c", i%16*(i++/16), i%16<15 ? 32 : 10);
}

```

Prints the zero padded result and either space or newline.
> 2 votes

# Answer
# JavaScript, 104 Bytes

```
s="";for(a=0;16>a;a++){for(b=0;16>b;b++)c=(a*b).toString(16),s=1==c.length?s+(" 0"+c):s+(" "+c);s+="\n"}

```

Call using variable `s`:

```
console.log("HEX Table: " + s)

```

Ungolfed code:

```
s=""; // Define s as empty string
for(a=0;16>a;a++){ // For y axis
  for(b=0;16>b;b++) // For x axis
    c=(a*b).toString(16),s=1==c.length?s+(" 0"+c):s+(" "+c); // Multiply and format
  s+="\n" // Add line breaks
}

```
> 2 votes

# Answer
# Japt `-R`, ~~20~~ 15 bytes

```
GÆGÇ*X sGÃùT2 ¸

```

Try It Online!

```
GÆGÇ*X sGÃùT2 ¸
G                   :16
 Æ                  :Map each X in the range [0,G)
  GÇ                :  Map the range [0,G)
    *X              :    Multiply by X
       sG           :    Convert to base-16 string
         Ã          :  End map
          ù         :  Left pad each
           T        :    With 0
            2       :    To length 2
              ¸     :  Join with spaces
                    :Implicitly join with newlines and output

```
> 2 votes

# Answer
# Python 3, 55 bytes

```
r=range(16)
for x in r:print(*['%02x'%(x*y)for y in r])

```

Using %formatting saves quite a few bytes over \[2:\] usage. So does using * splats on the print function.
> 2 votes

# Answer
# Python 2, 112 109 100 96 73 Bytes

```
R=range(16)
for i in R:print' '.join('0'*(i*j<16)+hex(i*j)[2:]for j in R)

```

Try it online!

* **saved 3 bytes**: Thanks to Wheat Wizard; predefined range(16) into R which is used twice.
* **saved 9 bytes**: Crunched up the earlier if statement into a single statement.
* **saved 4 bytes**: crunched the statements in 2nd 'for' block.
* **saved 23 bytes**: Thanks @J843136028: used list comprehension
> 1 votes

# Answer
# Python2, ~~102~~ ~~97~~ ~~92~~ ~~90~~ 89 bytes

```
i=1
exec"print' '.join('%02x'%(j-x)*(i>0)for x,j in enumerate(range(0,16*i,i)));i+=1;"*16

```

Output:

```
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
00 02 04 06 08 0a 0c 0e 10 12 14 16 18 1a 1c 1e
00 03 06 09 0c 0f 12 15 18 1b 1e 21 24 27 2a 2d
00 04 08 0c 10 14 18 1c 20 24 28 2c 30 34 38 3c
00 05 0a 0f 14 19 1e 23 28 2d 32 37 3c 41 46 4b
00 06 0c 12 18 1e 24 2a 30 36 3c 42 48 4e 54 5a
00 07 0e 15 1c 23 2a 31 38 3f 46 4d 54 5b 62 69
00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78
00 09 12 1b 24 2d 36 3f 48 51 5a 63 6c 75 7e 87
00 0a 14 1e 28 32 3c 46 50 5a 64 6e 78 82 8c 96
00 0b 16 21 2c 37 42 4d 58 63 6e 79 84 8f 9a a5
00 0c 18 24 30 3c 48 54 60 6c 78 84 90 9c a8 b4
00 0d 1a 27 34 41 4e 5b 68 75 82 8f 9c a9 b6 c3
00 0e 1c 2a 38 46 54 62 70 7e 8c 9a a8 b6 c4 d2
00 0f 1e 2d 3c 4b 5a 69 78 87 96 a5 b4 c3 d2 e1

```

Try it online!
> 1 votes

# Answer
# Octave, 34 bytes

```
disp(num2str((a=0:15)'*a,'%02x '))

```
> 1 votes

# Answer
# 05AB1E, 17 bytes

```
16F15ÝN*8o+h€¦ðý»

```

Try it online!

```
16F               For N in [0,15]
   15Ý            Push [0, ..., 15]
      N*          Multiply by N
        8o+       Add 256
           h      Take the uppercase hexadecimal representation
            €¦    Remove the leading 1 of each value
              ðý  Join with spaces
                » End for and join everything with newlines

```

There might be a better way to handle this in 05AB1E.
> 1 votes

# Answer
# VBA, 66 bytes

```
For m=0To 15:For n=0To 15:?Right(Hex(256+n*m)&" ",3);:Next:?:Next

```

Enter in Immediate window in VBA editor. Adding 256 to the expression to convert to hexadecimal is only shorter because the concatenater "&" requires a space after it to separate from alphabetic strings.
> 1 votes

# Answer
# C, 61 bytes

```
i;f(){while(i<256)printf("%02x%c",i%16*(i>>4),++i%16?32:10);}

```

Wandbox
> 1 votes

# Answer
# SmileBASIC, ~~56~~ ~~51~~ 47 bytes

```
I=RND(16)J=RND(16)LOCATE I*3,J?HEX$(I*J,2)EXEC.

```
> 1 votes

# Answer
# k, 50 bytes

```
`0:" "/'("0123456789abcdef"@16 16\)''{x*\:/:x}@!16

```

Alas, it is hindered by the lack of a built-in hexadecimal printer.

Reading right-to-left, more-or-less:

```
                                               !16 / make the array {0, 1, 2, ..., 15}
                                     {x*\:/:x}@    / cartesian product of the array multiplied by itself, results in a table
        (                         )''              / for each row, for each column
                            16 16\                 / decode int to two digits in base 16
         "0123456789abcdef"@                       / get the characters to form a string
   " "/'                                           / join the columns with a space, the table is now an array
`0:                                                / print the array, each element is one line

```
> 1 votes

# Answer
## ///, 588 bytes

```
/;/\/ //|/\/\///A/00 |B/
A|C;0|D;1|E;2|F;3|G;4|H;5|I;6|J;7|K;8/AAAAAAAAAAAAAAAAB01C2C3C4C5C6C7C8C9CaCbCcCdCeCf B02C4C6C8CaCcCeD0D2D4D6D8DaDcDe B03C6C9CcCfD2D5D8DbDeE1E4E7EaEd B04C8CcD0D4D8DcE0E4E8EcF0F4F8Fc B05CaCfD4D9DeE3E8EdF2F7FcG1G6Gb B06CcD2D8DeE4EaF0F6FcG2G8GeH4Ha B07CeD5 1cE3EaF1F8FfG6GdH4HbI2I9 B08D0D8E0E8F0F8G0G8H0H8I0I8J0J8 B09D2DbE4EdF6FfG8H1HaI3IcJ5JeK7 B0aD4DeE8F2FcG6H0HaI4IeJ8K2Kc 96 B0b 16E1EcF7G2Gd 58I3IeJ9K4Kf 9a a5 B0c 18E4F0FcG8 54I0IcJ8K4 90 9c a8 b4 B0d 1aE7F4G1GeHbI8J5K2Kf 9c a9 b6 c3 B0eDcEaF8G6H4I2J0JeKc 9a a8 b6 c4 d2 B0fDeEdFcGb 5aI9J8K7 96 a5 b4 c3 d2 e1

```

A more readable version with newlines:

```
/]
[///;/\/ //|/\/\///A/00 |B/
A|C;0|D;1|E;2|F;3|G;4|H;5|I;6|J;7|K;8/]
[AAAAAAAAAAAAAAAAB01C2C3C4C5C6C7C8C9CaCbCcCdCeCf ]
[B02C4C6C8CaCcCeD0D2D4D6D8DaDcDe B03C6C9CcCfD2D5D]
[8DbDeE1E4E7EaEd B04C8CcD0D4D8DcE0E4E8EcF0F4F8Fc ]
[B05CaCfD4D9DeE3E8EdF2F7FcG1G6Gb B06CcD2D8DeE4EaF]
[0F6FcG2G8GeH4Ha B07CeD5 1cE3EaF1F8FfG6GdH4HbI2I9]
[ B08D0D8E0E8F0F8G0G8H0H8I0I8J0J8 B09D2DbE4EdF6Ff]
[G8H1HaI3IcJ5JeK7 B0aD4DeE8F2FcG6H0HaI4IeJ8K2Kc 9]
[6 B0b 16E1EcF7G2Gd 58I3IeJ9K4Kf 9a a5 B0c 18E4F0]
[FcG8 54I0IcJ8K4 90 9c a8 b4 B0d 1aE7F4G1GeHbI8J5]
[K2Kf 9c a9 b6 c3 B0eDcEaF8G6H4I2J0JeKc 9a a8 b6 ]
[c4 d2 B0fDeEdFcGb 5aI9J8K7 96 a5 b4 c3 d2 e1

```

Pretty simple if you know how /// works. It's just a few string replacements.
> 1 votes

# Answer
# ///, 544 bytes

Well, everyone's doing /// answers now:

```
/|/\/\///Z/\/ |P/
0B|MZ9|LZ8|KZ7|JZ6|IZ5|HZ4|GZ3|FZ2|EZ1|C/BBB|B/0A|AZ0/0CCCCC0P1A2A3A4A5A6A7A8A9AaAbAcAdAeAfP2A4A6A8AaAcAeE0E2E4E6E8EaEcEeP3A6A9AcAfE2E5E8EbEeF1F4F7FaFdP4A8AcE0E4E8EcF0F4F8FcG0G4G8GcP5AaAfE4E9EeF3F8FdG2G7GcH1H6HbP6AcE2E8EeF4FaG0G6GcH2H8HeI4IaP7AeE5EcF3FaG1G8GfH6HdI4IbJ2J9P8E0E8F0F8G0G8H0H8I0I8J0J8K0K8P9E2EbF4FdG6GfH8I1IaJ3JcK5KeL7PaE4EeF8G2GcH6I0IaJ4JeK8L2LcM6PbE6F1FcG7H2HdI8J3JeK9L4LfMa a5PcE8F4G0GcH8I4J0JcK8L4M0Mc a8 b4PdEaF7G4H1HeIbJ8K5L2LfMc a9 b6 c3PeEcFaG8H6I4J2K0KeLcMa a8 b6 c4 d2PfEeFdGcHbIaJ9K8L7M6 a5 b4 c3 d2 e1

```

I replaced `\s0` through `\s9` with `A` then `E` through `M`, `0 0` with `C`, `\n00 0` with P, `/\s` with `Z` and finally `//` with `|`, adding all these at the front of the code as I went.

Try it online!
> 1 votes

# Answer
# Python 3, 66 bytes

```
r=range(16)
for i in r:print(*[('0'+hex(j*i)[2:])[-2:]for j in r])

```
> 1 votes

# Answer
# Perl 5, 45 bytes

```
for$"(@a=0..15){printf"%02x ",$_*$"for@a;say}

```

Try it online!
> 1 votes

# Answer
# PHP, ~~57~~ 56 bytes

```
while($z<256)printf("
"[$x=$z%16]."%02x ",$x*($z++>>4));

```

Run with `-nr` or try it online.

~~Note the trailing space in the first line!~~ One byte saved by @gwaugh.
> 1 votes

# Answer
# APL (Dyalog), ~~44~~ ~~43~~ ~~36~~ 33 bytes

*10 bytes saved thanks to @Adám*

Crossed out 44 is still regular 44 ;(

```
↑,/{(⎕D,⎕A)[16 16⊤⍵],' '}¨∘.×⍨⍳16

```

Uses `⎕IO←0`.

Try it online!

**How?**

`∘.×⍨⍳16` \- multiplication table of `0 .. 15`

`¨` \- for each item

`16 16⊤⍵` \- take the first 2 digits of hexadecimal encoding

`(⎕D,⎕A)[...]` \- index into `"0123456789ABCDEF..."`

`,' '` \- append space

`,/` \- join each row

\- and columnify

**Output**

```
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E
00 03 06 09 0C 0F 12 15 18 1B 1E 21 24 27 2A 2D
00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C
00 05 0A 0F 14 19 1E 23 28 2D 32 37 3C 41 46 4B
00 06 0C 12 18 1E 24 2A 30 36 3C 42 48 4E 54 5A
00 07 0E 15 1C 23 2A 31 38 3F 46 4D 54 5B 62 69
00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78
00 09 12 1B 24 2D 36 3F 48 51 5A 63 6C 75 7E 87
00 0A 14 1E 28 32 3C 46 50 5A 64 6E 78 82 8C 96
00 0B 16 21 2C 37 42 4D 58 63 6E 79 84 8F 9A A5
00 0C 18 24 30 3C 48 54 60 6C 78 84 90 9C A8 B4
00 0D 1A 27 34 41 4E 5B 68 75 82 8F 9C A9 B6 C3
00 0E 1C 2A 38 46 54 62 70 7E 8C 9A A8 B6 C4 D2
00 0F 1E 2D 3C 4B 5A 69 78 87 96 A5 B4 C3 D2 E1

```
> 1 votes

# Answer
# Java 8, ~~98~~ ~~90~~ 79 bytes

```
v->{for(int i=0;i<256;System.out.printf("%02x%c",i/16*(i++%16),i%16<1?10:32));}

```

**Explanation:**

Try it here.

```
v->{                    // Method with empty unused parameter and no return-type
  for(int i=0;          //  Index-integer, starting at 0
      i<256;            //  Loop from 0 to 256
    System.out.printf(  //   Print with format:
      "%02x             //    the lowercase 2-digit hexadecimal representation
           %c",         //    + a character
       i/16             //     `i` divided by 16 (integer division in Java truncates)
       *(i++%16)        //     multiplied by `i` modulo-16
                        //     (and increase `i` by 1 afterwards with `i++`)
       i%16<1?          //     If `i` is now a multiple of 16:
        10              //      Replace `%c` with a new-line
       :                //     Else:
        32)             //      Replace `%c` with a space instead
  );                    //  End of loop
}                       // End of method

```
> 1 votes

# Answer
# Julia, 83 75 bytes

```
r=0:15;[([print(num2hex(i*j)[15:16]," ")for i in r],print('\n'))for j in r]

```
> 1 votes

# Answer
# Ink, ~~169~~ ~~167~~ 161 bytes

```
VAR r=-1
-(l)
~temp c=0
~r++
{r>15:->END}
-(v)
{h((r*c)/16)}{h(r*c)}
~c++
{c>15:->l}<> ->v
==function h(n)
{n%16-10:
-0:a
-1:b
-2:c
-3:d
-4:e
-5:f
-else:{n%16}
}

```

Try it online!

# Ungolfed

```
VAR row=-1                                  // Declare a global variable which keeps track of the current row.
-(line)                                     // A named gather point, which can be jumped to later.

~temp column = 0                            // Declare a local varialbe called column, and set it to 0. Locals use 2 bytes more than globals, but they also reset the value if the line is later reached again.
~row++                                      // Increment the row counter.
{row>15:->END}                              // If we're about to start a 17th row, we terminate the program instead. If not, we continue onwards...

-(number)                                   // Another place to jump to
{digit((row*column)/16)}{digit(row*column)} // Calculate the two digits of the number and pass each of them to the digit function defined below to print them.
~column++                                   // Increment the column counter
{column>15:->row}<> ->number                // If we're done with this row we divert to row, to print another row. Otherwise, we concatenate a space to this row and divert to number.

== function digit(n) ==                     // Declare a function which prints a single hex digit.
{n%16-10:                                   // Multi-line conditional - basically a switch statement.
-0:a                                        // If n mod 16 is 10, write an a
-1:b                                        // If it's 11, write a b
-2:c                                        // ...etc...
-3:d
-4:e
-5:f
-else:{n%16}                                // If none of those matched, write n mod 16, as it'll be the same in hex and decimal
}                                           // End of conditional, and also of the function - it doesn't return anything.

```

Edit: Saved 2 bytes by using stitches instead of knots.
Edit: Saved 3 bytes by tweaking the printing function, and another 3 bytes by rewriting the main logic to use gathers instead of stitches.
> 1 votes

# Answer
# QBasic, 73 bytes

```
FOR x=0TO 15
FOR y=0TO 15
?HEX$(x*y\16);HEX$(x*y MOD 16);" ";
NEXT
?
NEXT

```

I golfed a custom procedure for converting to hex digits, before I realized there's a builtin for that. Now my code is shorter and more boring. :^(

Original 103-byte code:

```
FOR x=0TO 15
FOR y=0TO 15
p x*y\16
p x*y MOD 16
?" ";
NEXT
?
NEXT
SUB p(d)
?CHR$(48+d-7*(d>9));
END SUB

```
> 1 votes

# Answer
# 05AB1E, 12 bytes

```
15ÝDδ*16‰hJ»

```

Try it online.

**Explanation:**

```
15Ý           # Create a list in the range [0,15]: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
   D          # Duplicate this list
    δ*        # Multiply each pair double vectorized
      16‰     # Take the divmod 16 for each
         h    # Convert each number to hexadecimal
          J   # Join the pairs together
           »  # Join each inner list by spaces, and then each string by newlines
              # (and output the result implicitly)

```
> 1 votes

# Answer
# Vyxal `j`, 22 bytes

```
15ʀƛ15ʀ*ƛk6τ:L1=[0p];Ṅ

```

Try it Online!

```
15ʀ                    # List 0...15
   ƛ                   # Map to...
    15ʀ                # 0...15
       *               # Multiplied by (number)
        ƛ           ;  # Map to...
         k6τ           # Base16
            :L1=[0p]   # Prepend 0 as necessary
                     Ṅ # Join by spaces

```
> 1 votes

# Answer
# Pyth - ~~24~~ 23 bytes

Looking to golf the padding.

```
jjL;c16%L"%02x"*M^U16 2

```

Try it online here.
> 0 votes

# Answer
# WinDbg, ~~85~~ 68 bytes

Formatting the output manually:

```
.for(rip=0;.<100;rip=.+1){.printf"%02x%c",./10*(.%10),a+(f>.%10)*16}

```

Or using a built-in to format the output, which also outputs some bonus text. Also 68 bytes:

```
.for(rip=0;.<100;rip=.+1){eb(8<<16)+. .%10*(./10)};db/c10 8<<16 L100

```

*-17 bytes because it turns out the pseudo-register `$ip` can be read with `.`, so using that one instead of `$t0`.*

WinDbg's default base is 16 so this looks essentially like it's just code to print the 10x10 decimal multiplication table.

How it works:

```
.for (r ip=0; .<100; r ip=.+1)        * Loop 256 times
{
    .printf "%02x%c", ./10*(.%10),    * Print the result, padded to 2 places
        a+(f>.%10)*16                 * Print a space or \n if end of line
}

* OR:

.for (r ip=0; .<100; r ip=.+1)        * Loop 256 times
{
    eb (8<<16)+. .%10*(./10)          * Put the result in memory
};
db /c10 8<<16 L100                    * Print the memory as bytes in lines of length 16

```

Sample output:

```
0:000> .for(rip=0;.<100;rip=.+1){.printf"%02x%c",./10*(.%10),a+(f>.%10)*16}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
00 02 04 06 08 0a 0c 0e 10 12 14 16 18 1a 1c 1e
00 03 06 09 0c 0f 12 15 18 1b 1e 21 24 27 2a 2d
00 04 08 0c 10 14 18 1c 20 24 28 2c 30 34 38 3c
00 05 0a 0f 14 19 1e 23 28 2d 32 37 3c 41 46 4b
00 06 0c 12 18 1e 24 2a 30 36 3c 42 48 4e 54 5a
00 07 0e 15 1c 23 2a 31 38 3f 46 4d 54 5b 62 69
00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78
00 09 12 1b 24 2d 36 3f 48 51 5a 63 6c 75 7e 87
00 0a 14 1e 28 32 3c 46 50 5a 64 6e 78 82 8c 96
00 0b 16 21 2c 37 42 4d 58 63 6e 79 84 8f 9a a5
00 0c 18 24 30 3c 48 54 60 6c 78 84 90 9c a8 b4
00 0d 1a 27 34 41 4e 5b 68 75 82 8f 9c a9 b6 c3
00 0e 1c 2a 38 46 54 62 70 7e 8c 9a a8 b6 c4 d2
00 0f 1e 2d 3c 4b 5a 69 78 87 96 a5 b4 c3 d2 e1

0:000> * OR:

0:000> .for(rip=0;.<100;rip=.+1){eb(8<<16)+. .%10*(./10)};db/c10 8<<16 L100
02000000  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................
02000010  00 01 02 03 04 05 06 07-08 09 0a 0b 0c 0d 0e 0f  ................
02000020  00 02 04 06 08 0a 0c 0e-10 12 14 16 18 1a 1c 1e  ................
02000030  00 03 06 09 0c 0f 12 15-18 1b 1e 21 24 27 2a 2d  ...........!$'*-
02000040  00 04 08 0c 10 14 18 1c-20 24 28 2c 30 34 38 3c  ........ $(,048<
02000050  00 05 0a 0f 14 19 1e 23-28 2d 32 37 3c 41 46 4b  .......#(-27<AFK
02000060  00 06 0c 12 18 1e 24 2a-30 36 3c 42 48 4e 54 5a  ......$*06<BHNTZ
02000070  00 07 0e 15 1c 23 2a 31-38 3f 46 4d 54 5b 62 69  .....#*18?FMT[bi
02000080  00 08 10 18 20 28 30 38-40 48 50 58 60 68 70 78  .... (08@HPX`hpx
02000090  00 09 12 1b 24 2d 36 3f-48 51 5a 63 6c 75 7e 87  ....$-6?HQZclu~.
020000a0  00 0a 14 1e 28 32 3c 46-50 5a 64 6e 78 82 8c 96  ....(2<FPZdnx...
020000b0  00 0b 16 21 2c 37 42 4d-58 63 6e 79 84 8f 9a a5  ...!,7BMXcny....
020000c0  00 0c 18 24 30 3c 48 54-60 6c 78 84 90 9c a8 b4  ...$0<HT`lx.....
020000d0  00 0d 1a 27 34 41 4e 5b-68 75 82 8f 9c a9 b6 c3  ...'4AN[hu......
020000e0  00 0e 1c 2a 38 46 54 62-70 7e 8c 9a a8 b6 c4 d2  ...*8FTbp~......
020000f0  00 0f 1e 2d 3c 4b 5a 69-78 87 96 a5 b4 c3 d2 e1  ...-<KZix.......

```
> 0 votes

# Answer
# Scala, 56 bytes

```
for(x<-0 to 15){for(y<-0 to 15)printf("%02x ",x*y);println}

```

Ungolfed:

```
for(x<-0 to 15){
  for(y←0 to 15)
    printf("%02x ",x*y);
  println
}

```

Explanation:

```
for(x<-0 to 15){        //count from 0 to 15 using the variable x
  for(y←0 to 15)          //count from 0 to 15 using the variable y
    printf("%02x ",x*y);    //print x*y as a hex string with leading zeros and a width of 2 characters
  println                 //print a newline
}

```
> 0 votes

# Answer
# Common Lisp, ~~88~~ ~~70~~ ~~69~~ 63 bytes

```
(#1=dotimes(j 16)(#1#(k 16)(format t"~2,'0x "(* k j)))(terpri))

```

Using idea from here

### A bit of explanation

```
~2,'0x ;display in hexadecimal, padding with minimum two digits, padding symbol is 0

```
> 0 votes

# Answer
# q/kdb+, ~~46~~ 26 bytes

**Solution:**

```
-1" "sv'($)4h$x*/:x:(!)16;

```

**Example:**

```
q)-1" "sv'($)4h$x*/:x:(!)16;
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
00 02 04 06 08 0a 0c 0e 10 12 14 16 18 1a 1c 1e
00 03 06 09 0c 0f 12 15 18 1b 1e 21 24 27 2a 2d
00 04 08 0c 10 14 18 1c 20 24 28 2c 30 34 38 3c
00 05 0a 0f 14 19 1e 23 28 2d 32 37 3c 41 46 4b
00 06 0c 12 18 1e 24 2a 30 36 3c 42 48 4e 54 5a
00 07 0e 15 1c 23 2a 31 38 3f 46 4d 54 5b 62 69
00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78
00 09 12 1b 24 2d 36 3f 48 51 5a 63 6c 75 7e 87
00 0a 14 1e 28 32 3c 46 50 5a 64 6e 78 82 8c 96
00 0b 16 21 2c 37 42 4d 58 63 6e 79 84 8f 9a a5
00 0c 18 24 30 3c 48 54 60 6c 78 84 90 9c a8 b4
00 0d 1a 27 34 41 4e 5b 68 75 82 8f 9c a9 b6 c3
00 0e 1c 2a 38 46 54 62 70 7e 8c 9a a8 b6 c4 d2
00 0f 1e 2d 3c 4b 5a 69 78 87 96 a5 b4 c3 d2 e1

```

**Explanation:**

```
-1" "sv'string 4h$x*/:x:til 16; / ungolfed solution
                        til 16  / range 0..15
                      x:        / save in variable x
                  x*/:          / x multiplied by each-right (generate 0..15*0..15)
               4h$              / cast result to byte array (0x00...)
        string                  / convert byte array to string
  " "sv'                        / join (sv) each (') with space (" ")
-1                            ; / write to stdout and swallow return value

```

**Notes:**

* -20 byte saving by complete re-write.
> 0 votes

# Answer
# Proton, 60 bytes

```
x=0;eval("print(' '.join('%02x'%(x*y)for y:0..16));x++;"*16)

```

Try it online!
> 0 votes

# Answer
# Excel VBA, ~~58~~ 54 Bytes

Anonymous VBE immediate window function that takes no input and outputs the `FxF` hex multiplication table to the range `[A1:P16]`

```
[A1:P16]="=Right(0&Dec2Hex((Row()-1)*(Column()-1)),2)"

```
> 0 votes

# Answer
# , 22 bytes

```
echo,.3{."1 hfd*/~i.16

```

Try it online!
> 0 votes

# Answer
**VBA (Excel), 45 Bytes**

By using VBA Immediate Window.

```
[A1:P16]="=DEC2HEX((row()-1)*(column()-1),2)"

```
> 0 votes

# Answer
# Tcl, 98 bytes

```
time {incr i
set j 0
time {puts -nonewline [format %02x\  [expr ($i-1)*$j]]
incr j} 16
puts ""} 16

```

Try it online!

~~Tcl, 102 bytes
```
set i 0
time {set j 0
time {puts -nonewline [format %02x\  [expr $i*$j]]
incr j} 16
puts ""
incr i} 16

```
Try it online!
~~

~~Will golf it more later!~~
> 0 votes

# Answer
# Jq 1.5, 105 bytes

```
def h:[("0123456789abcdef"/"")[.[]]]|add;[range(16)*range(16)|[(./16|floor),.%16]|h]|_nwise(16)|join(" ")

```

Expanded (jq has no "%x" formatting so we roll our own)

```
def tohex:                 # convert [x,y] to hex string "xy"
  [("0123456789abcdef"/"")[.[]]] | add;

[   range(16)*range(16)    # generate values
  | [(./16|floor), .%16]   # convert to [x,y] digits base 16
  | tohex                  # convert to hex string
]
| _nwise(16)               # split into subarrays of length 16
| join(" ")                # convert subarrays to strings

```

Try it online!
> 0 votes

# Answer
# Forth (gforth), 65 bytes

```
: f 16. do cr 16. do i j * 16 /mod hex 1 .r . decimal loop loop ;

```

Try it online!

### Explanation

Nested loop from 0 to 15. Each Iteration:

* multiply row and column numbers to get result
* split into first and second digit (first digit will be 0 if result \< 16)
* set base to 16 (hexadecimal)
* print first digit with no space
* print second digit with space
* set base to 10 (decimal)

### Code Explanation

```
: f             \ start new word definition
  16. do        \ outer loop from 0 to 15
    cr          \ output newline
    16. do      \ inner loop from 0 to 15
      i j *     \ multiply loop indexes
      16 /mod   \ get quotient and remainder of dividing by 16
      hex       \ set base to 16
      1 .r      \ print quotient (equivalent to first digit) right-aligned in space of 1 (no space)
      .         \ print second digit (with space)
      decimal   \ set base back to 10 (decimal)
    loop        \ end inner loop
  loop          \ end outer loop
;               \ end word definition

```
> 0 votes

# Answer
# C# (Visual C# Interactive Compiler), 67 bytes

```
for(int i=0;i<256;)Write($"{(i%16<1?"\n":"")} {i/16*(i++%16):X2}");

```

Try it online!
> 0 votes

# Answer
# Mouse-2002, 58 bytes

```
8&WSIZE (qx.-^x.0y:(y.q<^y.x.y.*&!HEX " "y.1+y:)"!"x.1+x:)

```

Try it online!
> 0 votes

# Answer
# Pyth, 24 bytes

```
V16FZU16p+%"%02x"*ZNd)pb

```

Try it online!

Might post an explanation or ungolfed version later.
> 0 votes

# Answer
# APL(NARS), 42 chars, 84 bytes

```
{{(⎕D,⎕A)[1+16∣(⌊⍵÷16),⍵]}¨×/¨m∘.,m←0,⍳15}

```

I copy something from others... `×/¨m∘.,m←0,⍳15` would build the multiplication table of `0,⍳15`; the function `{(⎕D,⎕A)[1+16∣(⌊⍵÷16),⍵]}` convert each number in the multiplication table in hex for only 2 digits.

```
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
 00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E
 00 03 06 09 0C 0F 12 15 18 1B 1E 21 24 27 2A 2D
 00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C
 00 05 0A 0F 14 19 1E 23 28 2D 32 37 3C 41 46 4B
 00 06 0C 12 18 1E 24 2A 30 36 3C 42 48 4E 54 5A
 00 07 0E 15 1C 23 2A 31 38 3F 46 4D 54 5B 62 69
 00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78
 00 09 12 1B 24 2D 36 3F 48 51 5A 63 6C 75 7E 87
 00 0A 14 1E 28 32 3C 46 50 5A 64 6E 78 82 8C 96
 00 0B 16 21 2C 37 42 4D 58 63 6E 79 84 8F 9A A5
 00 0C 18 24 30 3C 48 54 60 6C 78 84 90 9C A8 B4
 00 0D 1A 27 34 41 4E 5B 68 75 82 8F 9C A9 B6 C3
 00 0E 1C 2A 38 46 54 62 70 7E 8C 9A A8 B6 C4 D2
 00 0F 1E 2D 3C 4B 5A 69 78 87 96 A5 B4 C3 D2 E1

```

I see how using functions and `¨` problems are break in simple problems...
> 0 votes

# Answer
# Charcoal, ~~16~~ 15 bytes

```
Ｅ¹⁶⭆¹⁶﹪%02x ×ιλ

```

Try it online! Link is to verbose version of code.

Alternative 16-byter using automatic grid output of Wolfram lists: `▷LＥ¹⁶Ｅ¹⁶﹪%02x×κμ`

### Explanation

```
Ｅ¹⁶                      Map for i from 0 to 15 (with k as index variable, but here it's the same as i)
    ⭆¹⁶                  Map for l from 0 to 15 (with m as index variable), then join with "" into a string
       ﹪                Modulo (used for Python's string format here)
         %02x            Input formatted (%), padded with zeros (0) to length two (2)
                         as a hexadecimal number (x), with a space ( ) at the end
              ×ιλ        i * l

```
> 0 votes

# Answer
## Perl 6, ~~49~~ 36 bytes

```
say ($_ <<*<<^16).fmt("%02x")for ^16

```

Old solution:

```
for ^16 ->\a {printf "%02x ",a*$_ for ^16;say ""}

```
> 0 votes

# Answer
# MathGolf, 16 bytes

```
☻r■mÉε*¢0═ uM∞/n

```

Try it online!

## Explanation

It might be shorter to do it with a loop, I'll have to try that.

```
☻                  push 16
 r                 range(0, n)
  ■                cartesian product with itself
   mÉ              explicit map using next 3 operators
     ε*            reduce list by multiplication
       ¢           convert to/from hexadecimal
        0          push 0
         ═         pad list elements with zeroes to equal length
                   space character
           u       join with separator (joins on space)
            M      push 24
             ∞     pop a, push 2*a = 48 (each line is 48 characters long)
              /    pop a, b : push(a/b), split strings
               n   newline char, or map array with newlines

```
> 0 votes

# Answer
# Factor, 56 bytes

```
16 iota dup '[ _ [ * "%02X "printf ] with each nl ] each

```

Try it online!

I went through a progression as I realized matrix words are too long:

```
{ 16 16 } matrix-coordinates [ Π "%02X"sprintf ] matrix-map simple-table.
{ 16 16 } matrix-coordinates [ [ Π "%02X "printf ] each nl ] each
16 iota dup [ * "%02X"sprintf ] cartesian-map simple-table.
16 iota [ 16 iota [ * "%02X "printf ] with each nl ] each
16 iota dup '[ _ [ * "%02X "printf ] with each nl ] each

```
> 0 votes

---
Tags: code-golf, kolmogorov-complexity, hexadecimal
---