My grandfather always predicted how old people would get, and right before he passed away he revealed his secret!
In honor of my grandfather‘s memory we will write a function using his formula!
predictAge(65, 60, 75, 55, 60, 63, 64, 45) === 86
Note: the result should be rounded down to the nearest integer.
Some random tests might fail due to a bug in the JavaScript implementation. Simply resubmit if that happens to you.
section .text global predict_age predict_age: imul rdi, rdi imul rsi, rsi imul rdx, rdx imul rcx, rcx imul r8, r8 imul r9, r9 mov r10, [rsp + 8] imul r10, r10 mov rax, [rsp + 16] imul rax, rax add rsi, rdi add rcx, rdx add r9, r8 add rax, r10 add rcx, rsi add rax, r9 add rax, rcx cvtsi2ss xmm0, rax sqrtss xmm0, xmm0 cvttss2si rax, xmm0 shr rax, 1 ret
相关指令:http://www.yjxsoft.com/forum.php?mod=viewthread&tid=6164
题目地址:https://www.codewars.com/kata/5aff237c578a14752d0035ae/solutions
原文:https://www.cnblogs.com/pppyyyzzz/p/13633738.html