Questions tagged «parsing»

此标签表示挑战,其中解析输入很大/挑战的主要部分。

13
扩大比较链
与大多数语言不同,Python a<b<c会像在数学中一样进行评估,实际上是比较三个数字,而不是将布尔值a<b与进行比较c。用C(以及许多其他语言)编写此代码的正确方法是a<b && b<c。 在这个挑战中,您的任务是将这样任意长度的比较链从Python /直观表示扩展到如何用其他语言编写。 技术指标 您的程序必须要处理运算符:==, !=, <, >, <=, >=。 输入将具有仅使用整数的比较链。 不用担心一路比较的真实性,这纯粹是语法/语法上的挑战。 输入将没有任何空格,以防止答案因分割空格而使解析变得琐碎。 但是,您的输出可能只有一个空格,要么仅包含&&,要么包含比较运算符和&&,或者两者都不包含,但是要保持一致。 测试用例 Input Output --------------------------------------------------------------- 3<4<5 3<4 && 4<5 3<4<5<6<7<8<9 3<4 && 4<5 && 5<6 && 6<7 && 7<8 && 8<9 3<5==6<19 3<5 && 5==6 && 6<19 10>=5<7!=20 10>=5 && 5<7 && 7!=20 15==15==15==15==15 …
9 code-golf  parsing  conversion  syntax  code-golf  sequence  primes  code-challenge  geometry  optimization  code-golf  graph-theory  code-golf  number-theory  primes  integer  code-golf  source-layout  cops-and-robbers  code-golf  source-layout  cops-and-robbers  code-golf  sequence  primes  integer  code-golf  math  number-theory  primes  rational-numbers  code-golf  math  sequence  number-theory  primes  code-golf  string  code-golf  math  combinatorics  permutations  restricted-complexity  code-golf  array-manipulation  code-golf  number  sequence  code-golf  number  sequence  code-golf  binary-matrix  code-golf  math  tips  javascript  algorithm  code-golf  string  code-golf  number  sequence  code-golf  math  arithmetic  parsing  code-golf  number  sequence  primes  code-golf  string  ascii-art  geometry  integer  code-golf  geometry  code-golf  number  array-manipulation  code-golf  math  geometry  code-golf  number  sequence  arithmetic  integer  code-golf  string  kolmogorov-complexity  code-golf  number  code-golf  number  chess  code-golf  sequence  decision-problem  subsequence  code-golf  math  number  primes  code-golf  primes  permutations  code-golf  integer  probability-theory  statistics  code-golf  string  code-golf  sequence  decision-problem  parsing  board-game  code-golf  binary  graph-theory  code-golf  board-game  classification  tic-tac-toe  code-golf  ascii-art  polyglot  code-golf  date  code-golf  geometry 

30
给定int输入n,输出n * reversed(n)
给定一个整数n,打印输出n * reversed(n) reversed(n)是当您reverse的数字为时得到的数字n。 reverse(512) = 215 reverse(1) = 1 reverse(101) = 101 >>>>>>>> func(5) = 5*5 = 25 func(12) = 12*21 = 252 func(11) = 11*11 = 121 func(659) = 659*956 = 630004 最短的代码胜出! 排行榜 显示代码段 var QUESTION_ID=144816,OVERRIDE_USER=71625;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var …
9 code-golf  math  arithmetic  code-golf  math  integer  code-golf  arithmetic  integer  code-golf  sequence  base-conversion  palindrome  code-golf  math  primes  integer  code-golf  parsing  conversion  syntax  code-golf  sequence  primes  code-challenge  geometry  optimization  code-golf  graph-theory  code-golf  number-theory  primes  integer  code-golf  source-layout  cops-and-robbers  code-golf  source-layout  cops-and-robbers  code-golf  sequence  primes  integer  code-golf  math  number-theory  primes  rational-numbers  code-golf  math  sequence  number-theory  primes  code-golf  string  code-golf  math  combinatorics  permutations  restricted-complexity  code-golf  array-manipulation  code-golf  number  sequence  code-golf  number  sequence  code-golf  binary-matrix  code-golf  math  tips  javascript  algorithm  code-golf  string  code-golf  number  sequence  code-golf  math  arithmetic  parsing  code-golf  number  sequence  primes  code-golf  string  ascii-art  geometry  integer  code-golf  geometry  code-golf  number  array-manipulation  code-golf  math  geometry  code-golf  number  sequence  arithmetic  integer  code-golf  string  kolmogorov-complexity  code-golf  number  code-golf  number  chess  code-golf  sequence  decision-problem  subsequence  code-golf  math  number  primes  code-golf  primes  permutations  code-golf  integer  probability-theory  statistics  code-golf  string  code-golf  sequence  decision-problem  parsing  board-game  code-golf  binary  graph-theory  code-golf  board-game  classification  tic-tac-toe  code-golf  ascii-art  polyglot  code-golf  date  code-golf  geometry 

14
是增加,减少,还是没有?
就拿两个输入,包含数字的非空矢量/列表1和2和一个字符串(不,你可能不会采取0/1替代)。字符串将是以下内容之一(小写,如下所示): increasing decreasing ones twos all none 如果字符串是____,则应返回索引___: increasing...列表从更改1为的位置2(2紧接在之后的所有内容1) decreasing...列表从更改2为的位置1(1紧接在之后的所有内容2) ones ...的所有数字 1 twos ...的所有数字 2 all ...所有数字 none...没有数字。0如果列表为1索引,则很好。如果列表为0索引,则负数为好。您也可以输出一个空列表或字符串。 测试用例: 这些是1索引的。您可以选择是1索引还是0索引。在测试案例中,相同的向量用于不同的字符串。 -------------------------------- Vector: 1 1 2 2 2 1 2 2 1 1 2 String - Output increasing - 3, 7, 11 decreasing - 6, 9 ones - 1, 2, …

11
创建变量组的每个组合,最高可达n
规格 给定m变量,按order创建每个组合n。例如, 将两个变量(a和b)映射到顺序的输出为1: 一个 b b 将两个变量(a和b)映射到顺序的输出为2: 一个 一个2 b b 2 b 一个2 b 抗体2 a 2 b 2 将两个变量(a和b)映射到顺序的输出为3: 一个 一个2 一个3 b b 2 b 3 b 一个2 b 一个3 b a 3 b 2 抗体2 腹3 a 2 b 3 a 2 b 2 a 3 …

2
一百个最常用的单词
之所以写这个问题,是因为“ Thing Explainer”很有趣,并且给了我一个主意。 编写“使计算机做事的东西”,以读取/获取一组字母,数字和类似的东西"#%|?,True / 1如果所有单词都属于该集合,则返回。 如果所有单词都不属于该集合,请返回不属于该集合的单词。 在任何情况下都可以认为本网站是正确的。编写规则是为了遵守该站点上的规范。 例子: Truthy: 如果将第一条水平线上方的整个文本粘贴为输入,则代码应返回真实值。 以下几行应返回真实值(输入之间用分隔###) This returns "Hello, World!" ### tHiS rEtUrNs TrUe... ### Thing Explainer is a book written by a man. The man writes books with simple words. ### This set of stuff "#!^{>7( must return true 虚假的: 在以下示例中,输入和输出用分隔***。不同的测试用例用分隔###。 This code …
9 code-golf  string  parsing  code-golf  array-manipulation  random  permutations  code-golf  string  code-golf  parsing  code-golf  string  quine  code-golf  string  parsing  comment  code-golf  string  counting  natural-language  code-golf  string  decision-problem  code-golf  math  code-challenge  metagolf  test-battery  code-golf  string  code-golf  math  number  arithmetic  source-layout  code-golf  number  primes  decision-problem  code-golf  math  arithmetic  code-golf  date  code-golf  string  cryptography  code-golf  code-golf  chess  board-game  code-golf  geometry  grid  puzzle-solver  set-partitions  code-golf  number  natural-language  code-golf  ascii-art  code-golf  math  code-golf  string  ascii-art  kolmogorov-complexity  code-golf  string  natural-language  code-golf  game  board-game  tic-tac-toe  code-golf  ascii-art  hexagonal-grid  code-golf  string  comment  code-golf  internet  code-golf  sorting  code-golf  kolmogorov-complexity  unicode  code-golf  tips  code-golf  string  natural-language  code-golf  string  kolmogorov-complexity  source-layout  hello-world  code-golf  string  kolmogorov-complexity  counting  natural-language  code-golf  random  quine  code-golf  string  math  bitwise  code-golf  permutations  code-golf  string  code-golf  arithmetic 

3
解析和处理键语言输入
让我们解析和处理键语言!给定一系列键盘按键和/或特殊键的输入,编写一个程序,功能等,当根据以下键盘处理了所有操作时,该产品就会输出产品: +-------------------------------------------------------+ | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | - | + | | | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 …

5
DCSS停尸房文件解析器
在此挑战中,您需要解析来自Roguelike游戏《地牢爬行石汤》的停尸间文件,并将其输出到STDOUT。 这些太平间文件是什么? 死后,将生成一个文本文件,其中包含该字符的数据。您可以看到角色拥有的装备,在最近几回合中发生了什么以及他杀死了多少怪物。 您可以在此处找到一个太平间文件示例 挑战 您的工作是制作一个程序,以从STDIN中获取这些文件之一,进行解析,然后将数据输出至STDOUT。 为了使这一挑战变得容易一些,您只需解析第一段文本。(直到......为止The game lasted <time> (<turns> turns). 您需要解析并输出以下信息: 版本号。 比分。 角色名称,标题,种族和阶级。 角色等级。 死亡/胜利的原因。 运行的转数持续。 例: Dungeon Crawl Stone Soup version <version number> character file. <score> <name> the <title> (level <level>, 224/224 HPs) Began as a <race> <class> on Mar 16, 2015. Was the Champion of …

1
你来自哪里?
INTERCAL是一种很棒的语言,但是要理解他人的代码并不总是那么容易。如果他们使用COME FROM语句,则尤其如此。 挑战定义 编写一个程序或函数,以INTERCAL程序的源代码作为文本/数据流。如果编写函数,建议您还提供一个程序来调用该函数,但它不会计入您的分数。 根据以下说明,函数输出将是程序进行的跳转的文本/数据流。输出不需要打印,但确实需要是单个文本,而不是字符串数组(例如)。 输出的每一行都将包含将为COME FROM的语句及其COME FROM语句的行号,并以分隔->。一个例子: (310) DO .4 <- .3 -> 55 您可以修剪这些行的源代码,但这不是必须的。 测试用例将仅由未计算的标签(即整数标签)组成。 输出必须按照将是COME FROM的语句的源代码顺序(而不是其标签)或COME FROM语句或其标签的顺序进行排序。 多个语句可能来自同一标签。在这种情况下,必须对COME FROM行号进行排序,并用逗号分隔。 有可能使用COME FROM语句本身。 COME FROM语句可以以NOT语句为前缀。在这种情况下,行号必须用方括号括起来。 单词COME FROM可以出现在注释中,必须忽略。您不需要完全解析文件:如果在文件后跟标签(括号中的数字),则可以认为它是一个真实的语句。 计分 参赛者将通过其程序或功能的字符长度进行评分。 测试用例 这些测试用例全部来自calvinmetcalf / intercal Github存储库。尽管任何有用的应用程序都可以安全地接受任何输入,但是出于此挑战的目的,您只需要考虑这五个测试用例。 rot13.i (10) PLEASE DON'T GIVE UP -> 87 (33) DON'T GIVE UP -> 92 primes.i …

5
简单标签解析器
这是宽容HTML解析器的模型。在此代码中,代替解析HTML和提取属性,标记解析器将很简单。 编写一个解析标记结构并返回其括号形式的函数。开头标签由一个小写字母组成,结束标签由一个大写字母组成。例如,aAbaAB解析为(a)(b(a))或以HTML形式解析<a></a><b><a></a></b>。当然,标签可以并列和嵌套。 必须处理“过早”的关闭标签。例如,在中abcA,A闭合最外面a,因此将其解析为(a(b(c)))。 多余的结束标记将被忽略:aAB解析为(a)。 不处理重叠的标签。例如,根据先前的额外结束标记(-> ()+ (extra))abAB解析为(a(b)),而不是。(a(b))(b)abABabA(a(b))B 假设输入中没有空格和其他非法字符。 您无权使用任何库。 这是参考实现和测试用例列表: #!/usr/bin/python def pars(inpu): outp = "" stac = [] i = 0 for x in inpu: lowr = x.lower() if x == lowr: stac.append(x) outp += "(" + x i = i + 1 else: while len(stac) > 1 and …
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.