| Bytes | Lang | Time | Link |
|---|---|---|---|
| 126 | Setanta | 250806T214239Z | bb94 |
| 016 | Vyxal 3 | 250806T144059Z | Themooni |
| 060 | AWK | 250806T141507Z | xrs |
| 026 | Pip S | 161002T221220Z | DLosc |
| 048 | K4 | 200226T193441Z | mkst |
| 017 | 05AB1E | 200226T081448Z | Kevin Cr |
| 034 | Burlesque | 200225T225244Z | DeathInc |
| 052 | Perl 5 | 200224T135125Z | andytech |
| 023 | Jelly | 160611T051553Z | Dennis |
| 125 | Racket | 161002T165633Z | rnso |
| 567 | /// | 161002T161212Z | Erik the |
| 058 | Julia | 160611T062745Z | Dennis |
| 081 | PHP | 160611T054851Z | Julie Pe |
| 076 | Python 2 | 160611T170051Z | Dennis |
| 027 | Pyth | 160611T052444Z | Denker |
| 028 | MATL | 160611T103709Z | Luis Men |
| 115 | JavaScript ES7 | 160611T101814Z | Neil |
Setanta, 126 bytes
t:=''le i idir(1,65){s:=dearbh@mata(sin@mata(i))le k idir(0,8){s*=16t+='0123456789abcdef'[s//1%16]}t+=(i%8&' ')|'
'}scriobh(t)
Vyxal 3, 16 bytes
④ƛ∆s⦷k5×⌊}Hʀ‹8Ϣ'
④ƛ∆s⦷k5×⌊}Hʀ‹8Ϣ'
ƛ } # map over implicit range...
④ # 0..64
⌊ # floor(
k5 # 2^32
× # *
⦷ # abs(
∆s # sin(n)
Hʀ‹ # convert to hex, lowercase, pad with 0 to 8 chars
8Ϣ # split into sections of length 8
' # join sublists on spaces and the result on newlines, implicit print
💎
Created with the help of Luminespire.
Pip -S, 36 26 bytes
S*LC(E32*UABSI\,64)TB16<>8
Pretty straightforward implementation. Dennis's approach for left-padding the results with 0 saves quite a few bytes over my original approach. Attempt This Online!
S*LC(E32*UABSI\,64)TB16<>8
\,64 Numbers 1 through 64
SI Sine
AB Absolute value
U Increment (adding a digit to the left side of the
hex version for 0-padding purposes)
E32* Multiply by 2^32
( )TB16 Convert to hex (implicitly truncating to int)
LC Lowercase--Pip's base conversion uses uppercase
S* Remove first character of each (undoing the
increment from earlier)
<>8 Group into sublists of size 8
Print separated first by newline then by space (-S)
Since this is an older challenge, I figured I'd also show an equivalent solution in Pip Classic, 30 bytes:
@>*LC(2**32*++ABSI\,64)TB16<>8
K4, 48 bytes
Solution:
-1@" "/:'8 8#(,/$4_0x0\:)'_abs sin[1+!64]*/32#2;
Example:
q)k)-1@" "/:'8 8#(,/$4_0x0\:)'_abs sin[1+!64]*/32#2;
d76aa478 e8c7b756 242070db c1bdceee f57c0faf 4787c62a a8304613 fd469501
698098d8 8b44f7af ffff5bb1 895cd7be 6b901122 fd987193 a679438e 49b40821
f61e2562 c040b340 265e5a51 e9b6c7aa d62f105d 02441453 d8a1e681 e7d3fbc8
21e1cde6 c33707d6 f4d50d87 455a14ed a9e3e905 fcefa3f8 676f02d9 8d2a4c8a
fffa3942 8771f681 6d9d6122 fde5380c a4beea44 4bdecfa9 f6bb4b60 bebfbc70
289b7ec6 eaa127fa d4ef3085 04881d05 d9d4d039 e6db99e5 1fa27cf8 c4ac5665
f4292244 432aff97 ab9423a7 fc93a039 655b59c3 8f0ccc92 ffeff47d 85845dd1
6fa87e4f fe2ce6e0 a3014314 4e0811a1 f7537e82 bd3af235 2ad7d2bb eb86d391
Explanation:
First pass, probably a few tricks left to golf further...
-1@" "/:'8 8#(,/$4_0x0\:)'_abs sin[1+!64]*/32#2; / the solution
32#2 / take 2, 32 times (2 2 2 2 2...)
*/ / product beginning with left argument
sin[ ] / built-in sine function
!64 / range 0..63
1+ / add 1, so 1..64
abs / built-in abs function
_ / floor
( )' / do this together for each
0x0\: / convert to byte representation
4_ / drop first 4 elements
$ / convert to string
,/ / flatten
8 8# / reshape to 8x8
" "/:' / join each with a single space
-1@ ; / print to stdout and swallow return
05AB1E, 19 17 bytes
64LŽĞJ*hl8jð0:8ô»
-2 bytes by taking inspiration from @Dennis' Jelly answer regarding the leading 0s, so make sure to upvote him!
Outputs with trailing newline.
Explanation:
64L # Push a list in the range [1,64]
Ž # Take the sine of each
Ä # Take the absolute value of that
> # Increase it by 1 (to avoid having to pad leading 0s later on)
žJ* # Multiply it by builtin 4294967296
h # Convert it from integer to hexadecimal
# (which implicitly truncates the decimals; and uses uppercase [A-F])
l # Convert that hexadecimal string to lowercase
€¦ # Remove the first character from each (undoing the earlier increment)
8ô # Split the list into parts of size 8
» # Join each inner list by spaces, and then those strings by newlines
# (after which it is output implicitly with trailing newline)
Burlesque, 34 bytes
64{Tsab2 32**.*pd-.b68'0lp}GO8cosp
64 # Literal 64
{
Ts # Sin
ab # Abs
2 32** # 2**32
.* # Times-by
pd # Floor
-. # Decrement by 1
b6 # To base 16
8'0lp # Left pad to length 8 with 0s
}GO # Range from [1, 64] and map
8co # Chunks of 8
sp # Pretty print array
Perl 5, 56 54 52 bytes
printf'%08x%s'x64,map{0|2**32*abs sin,$_%8?$":$/}1..64
Saved 2 4 bytes thanks to @XCali
Jelly, 26 24 23 bytes
64RÆSA‘æ«32Ḟb⁴Ḋ€‘ịØhs8G
How it works
64RÆSA‘æ«32Ḟb⁴Ḋ€‘ịØhs8G Main link. No arguments.
64R Yield [1, ..., 64].
ÆS Apply sine to each.
A Take absolute values.
‘ Increment.
This avoid padding the hex strings to 8 characters.
æ«32 Left-shift by 32 units.
Ḟ Floor.
b⁴ Convert to base 16 (list of integers).
Ḋ€ Remove the first digit of each, undoing the increment.
‘ Increment each base 16 digit (for 1-based indexing).
ịØh Index into "0123456789abcdef".
s8 Split into chunks of length 8.
G Grid; separate columns by spaces, rows by linefeeds.
Racket 125 bytes
(λ()(for((i(range 1 65)))(printf"~x "(inexact->exact(floor(*(expt 2 32)(abs(sin i))))))(when(= 0(modulo i 8))(printf"~n"))))
Ungolfed:
(define f
(λ ()
(for ((i (range 1 65)))
(printf "~x " (inexact->exact(floor (*(expt 2 32) (abs (sin i)) ))))
(when(= 0 (modulo i 8)) (printf "~n"))
)))
Testing:
(f)
Output:
d76aa478 e8c7b756 242070db c1bdceee f57c0faf 4787c62a a8304613 fd469501
698098d8 8b44f7af ffff5bb1 895cd7be 6b901122 fd987193 a679438e 49b40821
f61e2562 c040b340 265e5a51 e9b6c7aa d62f105d 2441453 d8a1e681 e7d3fbc8
21e1cde6 c33707d6 f4d50d87 455a14ed a9e3e905 fcefa3f8 676f02d9 8d2a4c8a
fffa3942 8771f681 6d9d6122 fde5380c a4beea44 4bdecfa9 f6bb4b60 bebfbc70
289b7ec6 eaa127fa d4ef3085 4881d05 d9d4d039 e6db99e5 1fa27cf8 c4ac5665
f4292244 432aff97 ab9423a7 fc93a039 655b59c3 8f0ccc92 ffeff47d 85845dd1
6fa87e4f fe2ce6e0 a3014314 4e0811a1 f7537e82 bd3af235 2ad7d2bb eb86d391
///, 568 567 bytes
/!/ f//@/fa/d76aa478 e8c7b756 242070db c1bdceee!57c0@f 4787c62a a8304613!d469501
698098d8 8b44f7af!fff5bb1 895cd7be 6b901122!d987193 a679438e 49b40821
f61e2562 c040b340 265e5a51 e9b6c7aa d62f105d 02441453 d8a1e681 e7d3fbc8
21e1cde6 c33707d6!4d50d87 455a14ed a9e3e905!ce@3f8 676f02d9 8d2a4c8a
ff@3942 8771f681 6d9d6122!de5380c a4beea44 4bdec@9!6bb4b60 bebfbc70
289b7ec6 eaa127@ d4ef3085 04881d05 d9d4d039 e6db99e5 1@27cf8 c4ac5665
f4292244 432aff97 ab9423a7!c93a039 655b59c3 8f0ccc92!feff47d 85845dd1
6@87e4f!e2ce6e0 a3014314 4e0811a1!7537e82 bd3af235 2ad7d2bb eb86d391
Too bad I can only golf 6 7 bytes :-(
To convince you that I can't golf it further, I challenge you to do better in just ///, should you accept it. If you do, you're a magician, since Martin Ender's code says otherwise (checked)!
People that won the challenge and are worth of crediting (format: name (id), bytes_golfed):
- daHugLenny (56258), 1
Julia, 69 63 58 bytes
[@printf "%08x%c"√sin(n)^2÷.5^32 n%8>0?32:10for n=1:64]
How it works
For each n between 1 and 64, we compute √sin(n)^2÷.5^32 and n%8>0?32:10, apply string formatting with "%08x%c" and print to STDOUT.
√sin(n)^2computes the absolute value of sin(n).abs(sin(n))is equally short (in bytes), but it would require a space to separate it from the format string.÷.5^32divides the previous result by 0.532 = 1 / 232, effectively multiplying it by 232. However,÷performs integer divsion, so the result is truncated.n%8>0?32:10returns 32 (the code point of a space) whenever n is not divisible by 8 and 10 (the code point of a linefeed) otherwise."%08x%c"turns the first result into lowercase hexadecimal representation, left-padded with zeroes to length 8; and the second result into a character.
Finally, the array comprehension returns an array of 64 instances of Nothing, the return value of @printf. Outside a REPL, this does not affect output.
PHP, 131 81 bytes
for(;++$i<65;){echo str_pad(dechex(2**32*abs(sin($i))),8,"0",0).($i%8?" ":"\n");}
This is a pretty straight-forward loop with a few conditions for spacing.
@insertusernamehere's shortcuts cut it down by 50 bytes.
Python 2, 86 77 76 bytes
import math
n=0;exec(",\nn+=1;print'%08x'%(2**32*abs(math.sin(n)))"*8)[1:]*8
Test it on Ideone.
How it works
Python 2's print statement has a quirk: It appends a newline to the result of its expression, unless it is followed by a trailing ,; in this case, it appends a space. While that's usually annoying when golfing (as there's no short way to print without trailing whitespace), it's perfect for this task.
We repeat the string ,\nn+=1;print'%08x'%(2**32*abs(math.sin(n))) eight times, chop off the leading comma with [1:], and repeat the result eight times. The string that exec executes composed of eight identical copies of the following code.
n+=1;print'%08x'%(2**32*abs(math.sin(n))),
n+=1;print'%08x'%(2**32*abs(math.sin(n))),
n+=1;print'%08x'%(2**32*abs(math.sin(n))),
n+=1;print'%08x'%(2**32*abs(math.sin(n))),
n+=1;print'%08x'%(2**32*abs(math.sin(n))),
n+=1;print'%08x'%(2**32*abs(math.sin(n))),
n+=1;print'%08x'%(2**32*abs(math.sin(n))),
n+=1;print'%08x'%(2**32*abs(math.sin(n)))
Each line increments the variable n (initialized by n=0), applies the format string %08x (lowercase hexadecimal representation, left-padded with zeroes to length 8, of the integer part of its argument) to 232 times the absolute value of the sine of n, and prints the resulting string either with a trailing space or a trailing linefeed.
Pyth, 31 27 bytes
Thanks to @Dennis for saving 4 bytes!
jjL;c8mt.Hs*^2 32h.a.tdZS64
Explanation
jjL;c8mt.Hs*^2 32h.a.tdZS64
m S64 # map over [1...64]
s*^2 32h.a.tdZ # floor(2^32 * abs(sin(d))+1)
t.H # convert to hex-string and discard the first digit
c8 # split into 8 parts
jjL; # join on whitespaces and then on newlines
MATL, 28 bytes
64:Y,|32W*k16YAkZ{Zc72e!3LZ)
Pretty straightforward computation. Getting the required output format takes almost half the byte count.
JavaScript (ES7), 115 bytes
_=>`_ _ _ _ _ _ _ _
`.repeat(8).replace(/_/g,_=>(0+(Math.abs(Math.sin(++n))*2**32>>>0).toString(16)).slice(-8),n=0)
Includes the trailing newline.