タグ付けされた質問 「tips」

特定の言語でゴルフするためのヒント、特定のチャレンジタグで上手くいく、または特定のコードを改善するための質問。

2
パウダートイでのゴルフのヒント
これを楽しんでください。パウダートイは、特にフィルトロジックに関して、ゴルフにとって興味深い挑戦です。 TPTが課題となるのは、問題に取り組むための多くの方法です。 Should I use Cellular Automaton rules, SWCH logic, Filt logic, subframe filt logic, and/or wall logic? そのため、TPTゴルフのヒントの場所は非常に役立つので、この質問のスレッドを作成しました。 このスレッドは、多くの略語を使用する可能性があります。それらの多くはゲーム内の要素になるため、Wikiでそれらを検索すると、それらが何であるかなど、それらに関する多くの情報が表示されます。 以下は、このスレッドに表示される可能性が最も高いもので、検索に行きたくない人のために、ゲーム内の説明(およびフルネーム)が添付されています。 SPRK:電気。TPTのすべての電子機器の基礎は、ワイヤーおよびその他の導電性要素に沿って移動します。 FILT:フィルター。フォトンをフィルターし、色を変更します。 ARAY:レイエミッター。レイは、衝突したときにポイントを作成します。 BTRY:バッテリー。無限の電力を生成します。 DRAY:複製光線。その前にあるパーティクルのラインを複製します。 CRAY:パーティクルレイエミッタ。tmpによって設定された範囲で、ctypeによって設定されたパーティクルのビームを作成します。 SWCH:スイッチ。スイッチを入れたときにのみ導通します。(PSCNはオン、NSCNはオフ) すべての要素のリスト
9 code-golf  tips  the-powder-toy  code-golf  number  array-manipulation  integer  code-golf  string  decision-problem  boggle  code-golf  array-manipulation  average  code-golf  math  code-golf  decision-problem  restricted-source  code-golf  code-golf  math  primes  code-golf  random  code-golf  tips  perl  code-golf  string  parsing  code-golf  math  number  decision-problem  code-golf  math  number  code-golf  string  alphabet  code-golf  math  geometry  code-golf  interpreter  brainfuck  code-golf  code-golf  decision-problem  boggle  code-golf  math  number  sequence  code-golf  math  code-golf  ascii-art  code-challenge  restricted-source  quine  code-golf  math  decision-problem  number-theory  primes  code-golf  ascii-art  code-golf  integer  graph-theory  chess  code-golf  math  interpreter  code-golf  code-golf  code-golf  ascii-art  code-golf  arithmetic  number-theory  code-golf  string  kolmogorov-complexity  code-golf  string  decision-problem  code-golf  primes  factoring  encode  code-golf  decision-problem  code-golf  geometry  grid  code-golf  quine  code-golf  matrix  code-golf  matrix  code-golf  code-golf  number  array-manipulation  code-golf  array-manipulation  sorting  code-golf  matrix  code-golf  brain-flak 

2
複数行にわたる関数の作成
複数行にわたって関数を作成しようとしています。 課題のパラメータ: 関数は 'barbarian'を返します 1行に2文字のみ 最大40行。私はファットアローを使用して関数を宣言しようとしていますが、ファットアローを接続していないと機能しません。 チャレンジのソース:https : //www.codewars.com/kata/multi-line-task-plus-plus-hello-world 私の現在の仕事: f= ( )=> '\ b\ a\ r\ b\ a\ r\ i\ a\ n\ s\ ' これは機能しますが、「)=>」は3文字です。関数の作成を拡張することさえ可能かどうかを知りたいだけです。明らかにあまり実用的ではないので、どこにも情報はありません。

7
pseudoprimesをゴルフしましょう!
はじめに/背景 で、最近の議論で暗号チャット私は議論するために/のヘルプ挑戦されたフェルマー素数判定テストとカーマイケル数を。このテストは、a^(p-1) mod p==1常に素数に当てはまるがp、常にコンポジットには当てはまらないという前提に基づいています。カーマイケル番号は、基本的にはフェルマートのテストで最悪の敵です。取得するために同時に素数にならないように選択aする必要がある番号です。が共素数でない場合、本質的には、自明ではない因子を見つけましたpa^(p-1) mod p!=1apそして、誰もが知っているように、因数分解は非常に難しい場合があります。特に、すべての要素が十分に大きい場合。これで、Fermatテストが実際にはあまり使用されない理由がよくわかります(より優れたアルゴリズムがあります)。これは、(セキュリティの観点から)防御者としてのあなたが同じような量の作業を行わなければならない数があるためです。攻撃者(つまり、数を因数分解します)。 これらの数値が魅力的である理由がわかったので、可能な限り最短の方法で数値を生成します。必要に応じて、生成したコードを記憶することができます。 カーマイケル番号は、OEISではA002997としても知られています。関連する課題はすでに ありますが、サイズではなく速度が最適化されているため、ここからのエントリは競争力がありません。同じ議論が逆の方向にも当てはまり、ここのエントリはサイズを優先して速度とトレードオフをする可能性があります。 仕様 入力 これは標準のシーケンスチャレンジなので、正または負でない整数nを入力として使用します。n必要に応じて、0または1のインデックスを付けることができます(指定してください)。 出力 出力は、必要にn応じて、-番目のカーマイケル番号または最初のnカーマイケル番号のいずれかになります(指示してください)。 仕様 整数xは、xが複合である場合にのみカーマイケル数であり、のすべての整数yについてgcd(x,y)=1、それを保持しy^(x-1) mod x==1ます。 誰が勝ちますか? これはcode-golfなので、バイトで最短のコードが優先されます!標準のIOと抜け穴のルールが適用されます。 テストケース 最初のいくつかのカーマイケル番号は次のとおりです。 561,1105,1729,2465,2821,6601,8911,10585,15841, 29341,41041,46657,52633,62745,63973,75361,101101, 115921,126217,162401,172081,188461,252601,278545, 294409,314821,334153,340561,399001,410041,449065, 488881,512461
9 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 

13
比較チェーンを拡張
ほとんどの言語と異なり、Python a<b<cは数学で行われるように評価し、ブール値a<bをと比較するのではなく、実際には3つの数値を比較し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 && …
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 

4
ロゴでのゴルフのヒント
ロゴは1967年に設計されたプログラミング言語であり、他の言語に比べて比較的少ないバイト数でグラフィックを作成できる可能性が非常に高いです。 ロゴは、タートルグラフィックスを利用した教育用プログラミング言語です。 ロゴには、次のような興味深い実装がいくつかあります。 Appleロゴ アタリロゴ LibreLogo(私の個人的なお気に入り) Texas Instrumentsロゴ UCBLogo そして他の多くの ... さらに、複数のロゴインタープリターをオンラインで見つけることができます。 このページは、ロゴプログラミング言語の実装に関するコードゴルフのヒントのハブとなることを目的としています。 出典:ジム・マラーによるグレート・ロゴ・アドベンチャー(1998)
9 code-golf  tips 

2
1000の最も一般的な単語
この質問は、「物事の説明者」が楽しく読めるから書いてありました。 文字、数字、およびこのようなもののセットを読み取り/受け取り、すべての単語がこのセットの一部である場合に"#%|?戻る「コンピュータに物事を実行させるもの」を記述します。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 doesn't return …
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 

5
Lispでのゴルフのヒント
Lisp(あらゆる方言)でゴルフをする上での一般的なヒントは何ですか?回答ごとに1つのヒントを投稿してください。Lispの方言に固有の回答のみ(たとえば、「コメントの削除」は回答ではありません)。 ヒントが適用されるLispの方言をヒントとともに投稿してください。
9 code-golf  tips  lisp 

1
Python 3-割り当てをゴルフしてみた
注:これはゴルフの課題ではありません。それはゴルフの提案を求めるよりもです。 最近、コーディングできるかどうかを確認するために、Web開発クラスにPythonを割り当てました。私はすでにPythonに慣れているので、それを試してみることにしました。そして、私が逃したことを人々が指摘できるかどうか疑問に思いました。 一部の場所に余分なスペースがあることはすでに知っていますがwhile r:、rが変数である場合に使用し、それが「実行」されるのを待つなど、概念的なものに興味があります。 割り当て import random from collections import Counter s=l='' c=['yellow','blue','white','green','Black', 'purple', 'silver', 'cyan', 'magenta', 'red'] n=[10,15,1,10,6,15,10,25,1,12,5,10,4,6,5,12,0,10,1,1] o=i=0 for y in c:l+=y[0]*(random.randint(n[o],n[o+1]));o+=2 l=list(l) print("Welcome to the CIMS Gumball Machine Simulator\nYou are starting with the following gumballs:") for b in c:print(str(l.count(b[0])) + " "+b);random.shuffle(l) print("Here are your random purchases:") …


4
OCamlでのゴルフのヒント
他の「言語xyzでゴルフするためのヒント」の品揃えに触発されました。通常どおり、一般的なプログラミングではなく、OCamlに固有のヒントのみを提案してください。回答ごとに1つのヒントを入力してください。
9 code-golf  tips 


3
実行可能な最小のMach-O実行可能ファイル
x86_64で実行可能な最小の実行可能なMach-O実行可能ファイルは何ですか?プログラムは何もできません(戻りコードを返すことさえできません)が、有効な実行可能ファイルでなければなりません(エラーなしで実行する必要があります)。 私の試み: GNUアセンブラー(null.s): .text .globl _main _main: retq コンパイルとリンク: as -o null.o null.s ld -e _main -macosx_version_min 10.12 -o null null.o -lSystem サイズ:4248バイト 16進数の値を見ると、おそらく削除できるゼロパディングがたくさんあるようですが、方法はわかりません。また、libSystemをリンクせずにexectubaleを実行できるかどうかもわかりません...

6
Emotinomiconでのゴルフのヒント
Emotinomiconでゴルフをするための一般的なヒントはありますか?私は、コードゴルフの問題全般に適用できる、少なくともある程度エモティノミコンに固有のアイデアを探しています(たとえば、「コメントの削除」は回答ではありません)。 回答ごとに1つのヒントを投稿してください。
8 code-golf  tips 

16
平らな地球を旅する
平地の世界の座標は、緯度(x)と経度(y)で構成されます。これらは0〜9999の範囲の整数です。ガウス整数によく似ていますが、常に次の表記法を使用して記述されています。 411S 370E すなわちであり、SまたはN緯度に付加し、EまたはW2つのコンポーネント間の空間(S)と、経度に付加します。 ゴール 空白で区切られた2つの座標を読み取り、それらの合計を出力するプログラム(関数ではない)を記述します。最初の座標は開始点、2番目の座標は変位、出力は結果の位置です。 入出力 この課題は部分的にフォーマットに関するものであるため、入力形式と出力形式を明確に定義するようにします。 推奨される入力形式では、座標コンポーネント間に1つのスペースがあり、先行ゼロはなく、2つの座標間に改行文字があります。プログラムは、優先フォーマットを読み取ることができる必要があります。 出力には、任意の量の空白と先行ゼロを含めることができます。推奨される入力形式と異なる場合、プログラムはこの形式も読み取ることができる必要があります。 明確にするために、入力には追加の書式設定文字を含めることはできません(含めません)。必要なスペースと改行だけ。 得点 これは新しい勝利条件の実験です。数週間以内に回答を受け入れて、勝者を選びます。その後、より適切な回答が出た場合は、回答を変更します。 プログラムのスコアはそのバイト数です。優勝したプログラムは、400バイトより短く、バイト数が最も少ないプログラムですが、最も冗長なプログラミング言語で書かれています。勝者を決定するには: バイト数が400以上のプログラムを削除します(参加できますが、勝つことはできません)。 各プログラミング言語の最短プログラムのみを検討する 最長のプログラムの勝利 ポリグロットは、有効なすべての言語のプログラムと競合します(たとえば、プログラムが両方bashで有効である場合、sh両方の言語のプログラムと競合します)。 テストケース テストケースでは、最初の2行が入力で、3行目が出力です。 0S 0E 0S 0W 0N 0E (ゼロの方向は、入力と出力の両方で重要ではありません) 0S 9999E 9999N 9999W 9999N 0E (最大値) 42S 314W 42N 2718W 0N 3032W (ゼロの方向は出力では関係ありません) 5555N 8888W 7777S 0E 2222S 8888W (負の値はありません。符号を変更する必要がある場合は方向を変更してください) 0001N 4545W …
8 code-challenge  arithmetic  parsing  code-golf  interpreter  code-golf  random  classification  code-golf  ascii-art  code-golf  code-golf  string  number  array-manipulation  code-golf  math  rational-numbers  code-golf  internet  classification  code-golf  string  integer  code-golf  number  graphical-output  typography  king-of-the-hill  code-golf  number  sequence  palindrome  code-golf  math  code-golf  math  probability-theory  code-challenge  image-processing  test-battery  code-golf  number-theory  code-golf  tips  swift  code-golf  graphical-output  image-processing  color  code-golf  string  conversion  code-golf  string  array-manipulation  code-golf  encryption  king-of-the-hill  code-golf  string  ascii-art  code-golf  code-golf  string  compression  decision-problem  code-golf  ascii-art  number-theory  division  code-golf  ascii-art  code-golf  code-golf  number  array-manipulation  code-golf  ascii-art  code-golf  code-golf  string  code-golf  sequence  number-theory  code-golf  math  geometry  code-golf  combinatorics  code-golf  integer  code-golf  arithmetic  number-theory  code-golf  arithmetic  restricted-source  number-theory  restricted-complexity 

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.