警告:这有点长。
我决定建立我自己的随机函数--我称之为“随机蛋糕”
这个函数应该得到0到99999之间的整数值。
1 x DateTime function
1 x Sin : Radians
1 x Absolute Value
1 x π
a dash of multiplication, division and addition这是做这些糕点的食谱
得到当前的日期和时间..。(1)
"23/05/2019 17:39:42.631" 将其分解为毫秒、秒、分钟、小时、日、月和年
加1到毫秒.(2)
1 + 631 = 632加1到秒.(3)
1 + 42 = 43将结果乘以(2)和(3),然后搅拌.(4)
632 * 43 = 27,176将结果从(4)除以360,然后使用Sin(π) =0,Sin(π/2) =1.(5)
27,176 / 360 = 75.48888889
Sin(75.48888889) in Rad = 0.09054103861然后将步骤5的结果乘以1000 .(6)
0.09054103861 * 1000 = 90.54103861注意这个值可能是负值,这里没有问题。
把这个放在冰箱里直到凉下来
在另一碗里,我们加3小时,然后乘以分钟.(7)
(3 + 17) * 39 = 780现在,我们将最后一步的结果(7)添加到步骤(6)中的冷却混合物中。(8)
780 + 90.54103861 = 870.54103861我们快到了,耐心点
得到步骤(8)的绝对值,因为它可能是负的.(9)
Abs(870.54103861) = 870.54103861添加菜谱的味道
步骤(9)结果中的前2位(不带前导零)将表示我们口味的位置,即π在π的十进制表示中排在该位置之后的5位.(10)
例如:
Here is the value of π: 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481
Results of step (9) was 870.54103861
First 2 non zero digits are 87
So we go to digit number 87 after the decimal point in π for the length of 5 digits
which is 48253
if your result was 0.001045678 then your 2 non zero digits are 10
the point is the number does not start with 0
so if your number anything like 0.000012345 then plz ignore all initial zeros till you get to the meat > 0在某些语言中,您比其他语言更准确,因此我认为您必须手动完成其余的数字:)
如果您的语言给出了π= 3.14,那么您必须添加π对它来说
将步骤(10)中的数字添加到步骤(9)的结果中……(11)
48253 + 870.54103861 = 49,123.54103861与步骤(11)的最终结果相乘日月.(12)
23 *5 * 49,123.54103861 = 5,649,207.21944015忽略小数,翻转你得到的值.(13)
5,649,207.21944015 ==> 5,649,207 ==> 7029465取这个数字的前5位.(14)
7029465 ==> 70294把它放进烤箱里加热。
这是我们的随机数
邦·阿佩蒂..。
另一个例子
另一个测试用例
Step 1 :
Date Time = "23/07/2016 04:59:31.407"
Step 2 :
1 + 407 = 408
Step 3 :
1 + 31 = 32
Step 4 :
408 * 32 = 13,056
Step 5 :
13,056 / 360 = 36.26666667
Sin(36.26666667) = -0.9904447352
Step 6 :
-0.9904447352 * 1000 = -990.4447352
Step 7 :
(3 + 04) * 59 = 413
Step 8 :
413 + (-990.4447352) = -577.4447352
Step 9 :
Abs(-577.4447352) = 577.4447352
Step 10 :
First 2 digits (without leading zeroes) ==> 57
π Position 57 (5 numbers)==> 49445
Step 11 :
49445 + 577.4447352 = 50,022.4447352
Step 12 :
50,022.4447352 * 23 * 07 = 8,053,613.6023672
Step 13 :
8,053,613.6023672 ==> 8,053,613
8,053,613 ==> 3163508
Step 14 :
First 5 Number 3163508 ==> 31635https://codegolf.stackexchange.com/questions/185988
复制相似问题