Questions tagged «s.i.l.o.s»

22
自然派#0-摇滚
目标 创建一个接受输入的程序/函数N,检查N随机整数对是否相对质数,然后返回sqrt(6 * N / #coprime)。 TL; DR 这些挑战是仅需要自然和大脑(也许还有一些可重复使用的资源)才能逼近Pi的算法模拟。如果您在僵尸启示录期间确实需要Pi,那么这些方法不会浪费弹药!还有另外八个挑战。检出沙盒帖子以提出建议。 模拟 我们在模拟什么?好吧,两个随机整数是相对质数(即coprime或gcd == 1)的概率是6/Pi/Pi,因此计算Pi的自然方法是挖出两个桶(或少数几个)的岩石。数他们;看看他们的gcd是否为1;重复。这样做后,一对夫妇很多次,sqrt(6.0 * total / num_coprimes)会趋向Pi。如果计算世界末日后的平方根使您感到紧张,请不要担心!有牛顿法。 我们如何模拟这一点? 接受输入 N 请执行以下N次数: 均匀生成随机正整数,i并且j 用 1 <= i , j <= 10^6 如果gcd(i , j) == 1:result = 1 其他: result = 0 取N结果的总和,S 返回 sqrt(6 * N / S) 规格 输入值 …
39 code-golf  math  random  pi  approximation  popularity-contest  code-golf  sequence  number-theory  binary  coding-theory  code-golf  math  3d  code-golf  code-golf  math  number  code-golf  kolmogorov-complexity  code-golf  ascii-art  graphical-output  binary-tree  code-golf  ascii-art  code-golf  ascii-art  kolmogorov-complexity  code-golf  array-manipulation  hexadecimal  code-golf  math  number  set-theory  code-golf  math  arithmetic  number-theory  integer  code-golf  string  kolmogorov-complexity  code-golf  math  sequence  arithmetic  decision-problem  code-golf  code-golf  ascii-art  code-golf  array-manipulation  parsing  code-golf  string  ascii-art  kolmogorov-complexity  code-challenge  code-golf  sequence  code-golf  number  array-manipulation  sorting  code-golf  string  function  code-golf  arithmetic  code-golf  math  sequence  number-theory  primes  restricted-source  javascript  code-challenge  polyglot  rosetta-stone  code-golf  code-golf  regular-expression  code-golf  math  code-golf  math  primes  code-golf  ascii-art  kolmogorov-complexity  binary  code-golf  math  sequence  code-golf  sequence  subsequence  code-golf  string  code-golf  parsing  music  code-golf  grid  game  path-finding  board-game  code-golf  string  binary  code-golf  array-manipulation  balanced-string  code-golf  code-golf  algorithm  code-golf  string  number  arithmetic  array-manipulation  code-golf  array-manipulation  binary-tree  tree-traversal  code-golf  code-golf  tips  code-golf  string  base-conversion  code-golf  tips  s.i.l.o.s  code-golf  string  ascii-art  code-golf  code-challenge  code-golf  game 

11
解释松散范围
解释松散范围 ListSharp是一种解释型编程语言,具有许多功能,其中一个功能是基于1索引的范围创建器,其工作方式如下: 您可以将范围定义为(INT) TO (INT)或仅定义(INT)两个int可以从min到max int32值的范围 然后,您可以使用这些范围来提取数组的元素,而不必担心会超出其边界 因此: 1 TO 5 产生: {1,2,3,4,5} 3 产生: {3} 范围可以使用AND运算符相加 1 TO 5 AND 3 TO 6 产生: {1,2,3,4,5,3,4,5,6} 记住这也适用于负数 3 TO -3 产生: {3,2,1,0,-1,-2,-3} 挑战如下: 输入值 字符数组和先前定义的range子句作为字符串 输出量 范围中基于1索引位置的元素(不存在/负索引会转换为空字符) 如何取胜 作为代码高尔夫球挑战,您应该创建具有最少字节数的程序以获胜 有人指出不存在空字符,因此您应该忽略它们(我仅在此处显示它们是为了使它们更易于理解,但却使人感到困惑) 测试用例: input array is: {'H','e','l','l','o',' ','W','o','r','l','d'} range clause: "1 TO …
13 code-golf  array-manipulation  parsing  code-golf  string  ascii-art  kolmogorov-complexity  code-challenge  code-golf  sequence  code-golf  number  array-manipulation  sorting  code-golf  string  function  code-golf  arithmetic  code-golf  math  sequence  number-theory  primes  restricted-source  javascript  code-challenge  polyglot  rosetta-stone  code-golf  code-golf  regular-expression  code-golf  math  code-golf  math  primes  code-golf  ascii-art  kolmogorov-complexity  binary  code-golf  math  sequence  code-golf  sequence  subsequence  code-golf  string  code-golf  parsing  music  code-golf  grid  game  path-finding  board-game  code-golf  string  binary  code-golf  array-manipulation  balanced-string  code-golf  code-golf  algorithm  code-golf  string  number  arithmetic  array-manipulation  code-golf  array-manipulation  binary-tree  tree-traversal  code-golf  code-golf  tips  code-golf  string  base-conversion  code-golf  tips  s.i.l.o.s  code-golf  string  ascii-art  code-golf  code-challenge  code-golf  game 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.