所有列表项目,包括第一个重复项目

时间:2017-07-16 05:54:49

标签: j

考虑:

x =. 0 1 2 3 4 1 3 4 99
v =. [ {.~ (>: @ i.&1 @ (#@~. = #\))
v x   NB. => 0 1 2 3 4 1

行为是正确的。但正如你所看到的,v是可耻的冗长。有更好的解决方案吗?

1 个答案:

答案 0 :(得分:5)

你想要monad import random cond = True while cond: print('Hello there! Please enter a number between 1 and 9 including the extremes.') x=random.randint(1,9) for i in range (10): z=int(input()) if int(z)<x: print('Too low. Please try again.') elif int(z)>x: print('Too high. Please try again.') elif int(z)==x: print('You guessed it right!') import sys if i==0: print('It took you a single turn! Nice') else: print('it took you ' + str(i+1)+' turns.') print('Do you want to play again? Yes or No?') j=input() if j.lower()=='yes': break else: cond = False sys.exit() nub sieve):

~:

代码审核:

  • 外部代码 - 高尔夫情境,请勿使用 v =: {.~ 1 + 0 i.~ ~: x =: 0 1 2 3 4 1 3 4 99 v x 0 1 2 3 4 1 代替#\。它太可爱了,难以维护,并且不会被特殊代码优化器识别。
  • 不要指定名称i.@#xyuvm(特殊情况除外)环境,并且总是在明确的背景下本地化。)