Questions tagged «permutations»

排列是某些对象列表的特定顺序。用置换标记的问题通常涉及查找或生成置换,包括文本的字谜。

15
手动逻辑门
编写一个模拟基本逻辑门的程序。 输入:一个全大写单词,后跟2个1位二进制数字,以空格分隔,例如OR 1 0。门OR,AND,NOR,NAND,XOR,和XNOR需要。 输出:输入的逻辑门的输出将被赋予两个数字:1或0。 例子: AND 1 0成为0 XOR 0 1变得1 OR 1 1成为1 NAND 1 1成为0 这是codegolf,所以最短的代码获胜。
13 code-golf  logic-gates  hashing  code-golf  code-golf  number  array-manipulation  integer  code-golf  string  unicode  text-processing  cops-and-robbers  boggle  cops-and-robbers  boggle  code-golf  ascii-art  code-golf  word-puzzle  king-of-the-hill  python  code-golf  sequence  kolmogorov-complexity  code-golf  source-layout  code-golf  string  kolmogorov-complexity  math  number  code-golf  date  code-golf  combinatorics  recursion  game  king-of-the-hill  javascript  code-golf  array-manipulation  code-golf  radiation-hardening  self-referential  code-golf  integer  code-golf  number  code-golf  set-theory  code-golf  sequence  code-golf  string  sorting  natural-language  code-golf  decision-problem  number-theory  primes  code-golf  code-golf  ascii-art  code-challenge  array-manipulation  sorting  rubiks-cube  regular-expression  code-golf  counting  file-system  recursion  code-golf  string  kolmogorov-complexity  color  code-golf  game  code-challenge  permutations  encode  restricted-time  decode  code-golf  math  decision-problem  matrix  integer  palindrome  code-golf  matrix  statistics  king-of-the-hill  king-of-the-hill  python  card-games  code-golf  string  natural-language  code-golf  sequence  number-theory 

8
找到所有的字谜和子字谜!
这个问题很大程度上是基于这个问题,但是应该带来许多其他困难。 你的任务 您必须编写一个程序或函数,该程序或函数在接收到字符串时会打印出所有可能的字谜。出于这个问题的目的,一个字谜是一个字符串,它包含与原始字符串相同的字符,但不是原始字符串。子字谜是输入字符串的子字符串的字谜。字谜和子字谜不一定是或包含实际单词。 输入值 您可以通过任何标准输入法接受长度大于0的字符串。它可以包含任何ASCII字符。 输出量 您可以以任何标准方式输出输入字符串的所有可能的字谜和子字谜。您不得输出相同的字符串两次,也不能输出与输入相等的字符串。 其他规定 不允许使用标准漏洞 计分 这是代码高尔夫球,最少字节获胜。

16
属于回文的字符串排列数
您的输入将是由小英文字母组成的字符串。 您的任务是确定作为回文的原始字符串的不同排列的数量。 输入字符串最多包含100个字母。在较长的字符串的情况下,结果可能会很大,因此输出应为模数666013的排列数。 例如, cababaa -> 3 可能的排列是: aabcbaa abacaba baacaab 这是代码高尔夫球,所以最短的答案会成功!

8
生成蚂蚁排列
介绍 我在较早的挑战中定义了蚂蚁排列的类别。作为提醒,置换p的数字从0到R-1是坐立不安,如果对于每一个条目P [I]除了第一,有一些较早条目P [IK] ,使得P [I] == P [ ik]±1。作为一个有趣的事实,我还说过,对于r≥1,正好有2个r-1长度为r的蚁群。这意味着长度为r的蚂蚁排列与长度为r-1的二元向量之间存在一一对应的关系。在这个挑战中,您的任务是实现这种对应关系。 任务 你的任务是写一个程序或函数,它在长度的二元载体1≤N≤99,并输出长度的坐立不安排列的n + 1。排列可以是基于0的基于1的(但是必须一致),并且输入和输出可以采用任何合理的格式。此外,不同的输入必须始终提供不同的输出。除此之外,您可以自由返回任何想要的蚂蚁排列。 最低字节数获胜。 例 长度为4的(从0开始)蚁群排列是 0 1 2 3 1 0 2 3 1 2 0 3 1 2 3 0 2 1 0 3 2 1 3 0 2 3 1 0 3 2 1 0 并且您的程序应针对长度3的八个位向量中的每一个返回其中之一: …

13
斐波那契产品
您可以将大于0的数字分解为正Fibonacci数字的唯一和。在这个问题中,我们通过重复减去最大可能的正斐波那契数来做到这一点。例如: 1 = 1 2 = 2 3 = 3 4 = 3 + 1 12 = 8 + 3 + 1 13 = 13 100 = 89 + 8 + 3 现在,我将斐波那契乘积称为与上面相同的列表,但加法运算被乘积代替。例如,f(100) = 89 * 8 * 3 = 2136。 编写一个给定正整数n的程序或函数,该函数将返回该数字的斐波那契乘积。 测试用例: 1: 1 2: 2 3: 3 4: …
13 code-golf  math  sequence  fibonacci  code-golf  word  code-golf  cipher  code-golf  string  math  subsequence  code-golf  regular-expression  code-golf  brainfuck  assembly  machine-code  x86-family  code-golf  math  factorial  code-golf  math  geometry  code-golf  math  arithmetic  array-manipulation  math  number  optimization  stack  metagolf  code-golf  tips  assembly  code-golf  tips  lisp  code-golf  number-theory  path-finding  code-golf  number  sequence  generation  code-golf  math  geometry  code-golf  grid  permutations  code-golf  code-golf  graphical-output  geometry  fractal  knot-theory  code-golf  math  arithmetic  code-golf  interpreter  balanced-string  stack  brain-flak  code-golf  math  set-theory  code-golf  math  array-manipulation  code-golf  code-golf  string  natural-language  code-golf  code-golf  math  linear-algebra  matrix  code-golf  string  encode 

6
给定长度的幻数
您的程序必须接受输入(n出于描述目的)并输出n数字长的数字的所有排列,且没有重复的数字,其中位于其索引之前和包括其索引的每个数字都可以通过其所属数字的位置来整除。 。 您可以在此处阅读有关幻数的信息。 规则: 1 <= n <= 10 不能重复数字 前0必须存在(如果适用) x数字的第1至第一个数字(从第一个字符开始为1)必须可被整除x,即,在中30685,3可被1 30整除,被2 306整除,被3 3068整除,被4整除,并且30685被5 整除。 程序必须采用整数作为输入(通过命令行,作为函数参数等),并打印所有满足规则的排列。 输出必须用1个或多个空格字符分隔 排列可能从零开始(因此从技术上讲不是魔术数字)。 输出顺序无关紧要 你不会需要处理突发输入 以字节为单位的最少字符获胜 例子 给定1: 0 1 2 3 4 5 6 7 8 9 给定2: 02 04 06 08 10 12 14 16 18 20 24 26 28 30 32 …

4
获取吸气剂
任务 我想每个人都喜欢自动代码生成并节省工作时间。您白天必须创建许多类和成员,而又不想getters手动创建所有这些类和成员。 任务是编写一个程序或函数,该程序或函数getters将为您自动为所有类成员生成。 输入 在我们的语言中,对象非常简单。类和成员的名称必须以字符开头,[a-zA-Z]并且只能包含字符[a-zA-Z0-9]。这是一个例子: class Stack { public overflow; protected trace; private errorReport; } 输出 这是基于给定示例的有效输出: class Stack { public overflow; protected trace; private errorReport; public function getOverflow() { return this->overflow; } public function getTrace() { return this->trace; } public function getErrorReport() { return this->errorReport; } } 吸气剂 getter方法的要求是: …
13 code-golf  string  syntax  code-golf  math  primes  rational-numbers  code-golf  graphical-output  image-processing  code-golf  kolmogorov-complexity  music  audio  code-golf  string  code-golf  math  geometry  code-golf  math  sequence  combinatorics  code-golf  game  grid  board-game  code-golf  restricted-source  array-manipulation  source-layout  code-golf  base-conversion  binary  code-golf  math  physics  code-golf  math  number  date  expression-building  code-golf  array-manipulation  graph-theory  decision-problem  popularity-contest  error-correction  code-golf  kolmogorov-complexity  geometry  grid  code-challenge  arithmetic  combinatorics  set-partitions  code-golf  kolmogorov-complexity  sequence  fibonacci  code-golf  restricted-source  pristine-programming  code-golf  code-golf  string  kolmogorov-complexity  code-golf  arithmetic  code-golf  string  parsing  code-golf  code-golf  sorting  counting  permutations  3d  code-golf  code-golf  ascii-art  music  code-golf  string  code-golf  string  ascii-art  code-golf  string  code-golf  quine  polyglot  code-golf  math  string  code-golf  internet 


3
Brainfuck中的按位运算符
您的任务是为以下每个二进制运算符创建一个Brainfuck程序。每个程序应从输入中获取一个或两个8位数字(A和B)并计算指定的运算: A XOR B A AND B A OR B A Shifted Left by 1 (circular shift) NOT A 您不必全部实施5。得分的计算方式为: #totalCharacters + {4000 * #problemsNotCompleted} 因此,有效分数是从零(最佳)到20,000(未完成)。 我不在乎您将结果存储在哪里,也不管您是否保留输入。假设8位单元以及仅在右侧需要的空单元数。 您可能会认为数字已经在最适合您的任何内存位置中,因此您无需担心IO操作。
13 code-golf  binary  brainfuck  code-golf  code-golf  ascii-art  random  code-golf  code-golf  code-challenge  sorting  code-golf  code-challenge  java  code-golf  statistics  code-golf  code-challenge  fastest-code  code-golf  math  code-golf  math  kolmogorov-complexity  code-golf  code-golf  array-manipulation  combinatorics  code-golf  kolmogorov-complexity  popularity-contest  underhanded  code-golf  math  floating-point  code-golf  interpreter  code-golf  music  code-golf  code-golf  cryptography  code-challenge  scrabble  code-golf  code-challenge  popularity-contest  quine  code-golf  quine  cryptography  code-golf  kolmogorov-complexity  code-golf  printable-ascii  code-golf  chess  code-golf  math  number-theory  code-challenge  c  code-golf  random  popularity-contest  hello-world  code-shuffleboard  code-golf  compression  grammars  code-golf  tips  code-golf  sequence  code-golf  string  code-challenge  sorting  permutations  code-golf  string  code-challenge  optimization  code-golf  interpreter  code-challenge  string  code-golf  math  number  fibonacci  string  compression  c#  code-golf  chemistry  popularity-contest  math  c  c++  java  code-golf  math  function  code-golf  complex-numbers  code-golf  geometry 

6
找出有理生成函数的系数
如果我们写一个数字序列作为幂级数的系数,则该幂级数称为该序列的(普通)生成函数(或Gf)。也就是说,如果对于某些函数F(x)和整数系列,a(n)我们有: a(0) + a(1)x + a(2)x^2 + a(3)x^3 + a(4)x^4 + ... = F(x) 然后F(x)是的生成函数a。例如,几何级数告诉我们: 1 + x + x^2 + x^3 + x^4 + ... = 1/(1-x) 因此,的生成函数1, 1, 1, ...为1/(1-x)。如果我们对上面方程的两边求和并乘以x得到以下等式: x + 2x^2 + 3x^3 + 4x^4 + ... = x/(1-x)^2 因此,的生成函数1, 2, 3, ...为x/(1-x)^2。生成函数是一个非常强大的工具,您可以使用它们来做很多有用的事情。在这里可以找到简短的介绍,但是要获得真正彻底的解释,请参见惊人的图书生成功能学。 在此挑战中,您将有理函数(两个具有整数系数的多项式的商)作为两个整数系数数组的输入作为输入,首先是分子,然后是分母。例如,功能f(x) = x …
12 code-golf  math  integer  polynomials  code-golf  math  abstract-algebra  restricted-time  code-golf  math  primes  code-golf  math  number  arithmetic  code-golf  quine  code-golf  number  sequence  code-golf  string  number  code-golf  array-manipulation  code-golf  number  code-golf  string  code-golf  arithmetic  code-golf  string  array-manipulation  rubiks-cube  code-golf  math  number  code-golf  tips  bash  code-golf  ascii-art  music  code-golf  arithmetic  code-golf  math  number  arithmetic  integer  code-golf  number  array-manipulation  code-golf  geometry  grid  set-partitions  code-golf  math  number  code-golf  combinatorics  code-golf  regular-expression  code-golf  permutations  code-golf  ascii-art  code-golf  number  array-manipulation  matrix  code-golf  kolmogorov-complexity  compile-time  cops-and-robbers  polyglot  cops-and-robbers  polyglot  code-golf  string  code-golf  string  ascii-art  matrix  animation  code-golf  ascii-art  code-golf  string  balanced-string  code-golf  integer  integer-partitions  expression-building 

14
用零填充文件
今天的任务是获取一个现有文件,并将零添加到该文件,直到达到一定大小为止。 您必须编写一个程序或函数,该程序或函数采用当前目录中文件的名称f和字节数b。在保留的原始内容的同时f,您必须在末尾写入零(空字节,而不是ascii 0),以便其新大小为b字节。 您可以假设名称中f仅包含字母数字的ascii,您对此具有完全权限,其初始大小不大于b,但可能与一样大b,并且有无限的可用磁盘空间。 您可能不会假设f它是非空的,或者它不已经包含空字节。 执行结束后,不应修改其他现有文件,也不应该存在新文件。 测试用例 f的内容| b | f的结果内容 12345 | 10 | 1234500000 0 | 3 | 000 [空] | 2 | 00 [空] | 0 | [空] 123 | 3 | 123
12 code-golf  file-system  code-golf  code-golf  string  code-golf  string  code-golf  random  game  compression  code-golf  array-manipulation  sorting  code-golf  number  arithmetic  primes  code-golf  geometry  code-golf  code-golf  decision-problem  regular-expression  code-golf  string  math  code-challenge  restricted-source  integer  palindrome  code-golf  string  palindrome  code-challenge  busy-beaver  code-golf  ascii-art  code-golf  string  code-golf  string  permutations  code-golf  code-golf  string  permutations  code-golf  number  primes  function  set-theory  code-challenge  hello-world  code-golf  math  number  decision-problem  code-golf  code-golf  sequence  arithmetic  integer  code-golf  math  number  arithmetic  decision-problem  code-golf  kolmogorov-complexity  alphabet  code-golf  combinatorics  graph-theory  tree-traversal  code-golf  set-theory  code-golf  interpreter  brainfuck  substitution  code-golf  quine  permutations 

10
从前到后的排列索引
挑战 给定项目数n,在非空的已排序列表中,输出索引, 如果按字典顺序对排列进行排列,则i(n)其 “ 从前到后排列 ” 将位于所有排列的列表中。 结果可能是基于0或1的,只说哪个(即i不是n)。 从后到前的排列 ...是通过重复获取向前排序的列表(从左至右)的后(右)然后前(左),直到所有项都移至新列表,来构建项列表的结果,就像这样: Input being consumed Output being built ----------------------+---------------------- [1,2,3,4,5,6,7] | [] [1,2,3,4,5,6] | [7] [2,3,4,5,6] | [7,1] [2,3,4,5] | [7,1,6] [3,4,5] | [7,1,6,2] [3,4] | [7,1,6,2,5] [4] | [7,1,6,2,5,3] [] | [7,1,6,2,5,3,4] ----------------------+---------------------- Result: [7,1,6,2,5,3,4] 排列指数 如果n为7(如上面的从前到后的示例)7! = 5040,则(不同的)项目可能存在排列。 所有这些排列的按字典顺序排序的列表中的第一个(如果愿意,则为零)项目[1,2,3,4,5,6,7]本身就是它自己。 第二项是[1,2,3,4,5,7,6]。 …

3
音位错误
性格 我们将这些Unicode字符称为英语IPA辅音: bdfhjklmnprstvwzðŋɡʃʒθ 我们将这些Unicode字符称为 英语IPA元音: aeiouæɑɔəɛɜɪʊʌː (是的,ː这只是长元音标记,但出于此挑战的目的,请将其视为元音。) 最后,这些是主要和次要压力标记: ˈˌ 注意,ɡ(U + 0261)不是小写的g,主应力标记ˈ(U + 02C8)不是撇号,并且ː(U + 02D0)不是冒号。 你的任务 给出一个单词,将元音堆叠在跟随的辅音之上,并将重音标记放置在其跟随的辅音下方。(正如问题标题所暗示的,这样的书写系统将辅音元音序列作为一个单元打包在一起,称为abugida。)给定输入ˈbætəlʃɪp,产生输出: æə ɪ btlʃp ˈ 甲字被保证是声母,韵母和应力标记的字符串,如上面所定义。永远不会有连续的重音标记,它们将始终放置在单词的开头和/或辅音之前。 测试用例 可能有连续的元音。例如,kənˌɡrætjʊˈleɪʃən变为 ɪ ə æ ʊeə knɡrtjlʃn ˌ ˈ 如果一个词以元音开头,打印在“基线”与辅音:əˈpiːl变 ː i əpl ˈ 一个测试用例的初始,强调元音:ˈælbəˌtrɔs变 ə ɔ ælbtrs ˈ ˌ 一句话:ˌsuːpərˌkaləˌfrædʒəˌlɪstɪˌkɛkspiːæləˈdoʊʃəs变成 æ ː ː ʊ uə aə …

2
解释基普尔!
介绍 Kipple是Rune Berg于2003年3月发明的基于堆栈的深奥编程语言。 Kipple有27个堆栈,4个运算符和一个控制结构。 堆栈 堆栈被命名为a- z并包含32位带符号整数。还有一个特殊的堆栈,@使输出数字更加方便。当将数字压入时@,实际上将压入该数字的ASCII值。(例如,如果您将12推到@,它将推49,然后推50。@) i在执行程序之前,将输入压入输入堆栈。解释器将i在执行之前要求存储值。执行完成后,输出堆栈上的所有内容o都会弹出以ASCII字符形式输出。由于这是Kipple唯一的IO机制,因此无法与Kipple程序进行交互。 经营者 操作数可以是堆栈标识符或带符号的32位整数。 推送:>或< 语法:Operand>StackIndentifier或StackIndentifier<Operand Push运算符将操作数向左移并将其推入指定的堆栈。例如,12>a将值12推入stack a。a>b将从堆栈中弹出最高值a并将其推入堆栈b。弹出空堆栈总是返回0 a<b相当于b>a。a<b>c从弹出最高值,b并同时推入c和a。 加: + 句法: StackIndentifier+Operand Add运算符将堆栈上最顶层项目和操作数之和压入堆栈。如果操作数是堆栈,则从中弹出值。例如,如果堆栈的最高值为a1,a+2则将3压入堆栈。如果a为空,a+2则将2推入。如果堆叠的最值a和b是1和2,然后a+b将从栈中弹出的值2 b和3推入堆栈a。 减去: - 句法: StackIndentifier-Operand 减法运算符的工作方式与加法运算符完全相同,只是它减去而不是加法。 明确: ? 句法: StackIndentifier? 如果最上面的项目为0,则Clear运算符将清空堆栈。 解释器将忽略操作符旁边不存在的所有内容,因此以下程序将起作用:a+2 this will be ignored c<i。但是,添加注释的正确方法是使用#字符。#执行前,a 和行尾字符之间的所有内容都将被删除。ASCII字符#10在Kipple中定义为行尾。 操作数可以由两个运算符共享,例如a>b c>b c?可以写为a>b<c?。 该程序1>a<2 a+a将导致a包含值[1 4](从下到上),而不是[1 3]。对于-操作员也是如此。 控制结构 Kipple中只有一种控制结构:循环。 句法: (StackIndentifier code …
12 code-golf  interpreter  code-golf  string  code-golf  math  string  code-golf  ascii-art  path-finding  code-golf  string  ascii-art  code-golf  interpreter  binary  logic-gates  logic  code-golf  ascii-art  code-golf  graph-theory  code-golf  string  code-golf  number  sorting  code-golf  number-theory  random  cryptography  polynomials  code-golf  number  code-golf  math  number  sequence  code-golf  quine  code-generation  code-golf  arithmetic  set-theory  code-golf  sequence  code-golf  code-golf  string  math  fastest-code  optimization  code-golf  code-golf  internet  stack-exchange-api  code-golf  array-manipulation  code-golf  string  internet  string  code-challenge  internet  test-battery  code-golf  math  pi  code-golf  arithmetic  primes  code-golf  array-manipulation  code-golf  string  code-golf  string  palindrome  code-golf  sequence  number-theory  fastest-algorithm  code-golf  math  number  base-conversion  code-golf  number-theory  sorting  subsequence  search  code-golf  permutations  code-challenge  popularity-contest  code-generation 

2
旋转安全的拉丁方格
拉丁方是在X或Y列中没有重复符号的正方形。例如: ABCD DABC CDAB BCDA 是一个这样的广场。请注意,每一列和每一行如何包含相同的4个字母的排列。 但是,我们的拉丁方有一个问题: 如果我将第二行(DABC)1向左旋转,我将得到ABCD,这与上面的排列相同。 如果不可能旋转任何一列/行并获得另一列/行,那么我们认为正方形是旋转安全的。 例如: ABCD BDAC CADB DCBA 是旋转安全的。网格具有以下属性: 点[0,N]使用第N个符号 点[0,N]和[N,0]始终是相同的符号。(我也想说[x,y]和[y,x]也总是相同的字母,但我无法证明它) 您的任务是在传递N时打印出1个旋转安全的拉丁方格。 我不在乎是否输出字母,数字,列表或2D数组。 如果使用数字,则第一列和第一行必须是0,1,2,3,...(按此顺序)。如果使用字母,则必须是A,B,C,D,.... 例如,如果输入为4,则应打印: 0,1,2,3 0,1,2,3 1,3,0,2 or 1,0,3,2 2,0,3,1 2,3,1,0 3,2,1,0 3,2,0,1 没有大小小于4的旋转安全拉丁方。如果N小于4,我不在乎您的程序会做什么。出于好奇,旋转安全方数为(从4开始): 2,5,5906,(too long to calculate) 这是一个代码问题,所以请尝试使用您喜欢的语言尽可能短地回答!

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.