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

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

30
VBAでのゴルフのヒント
これ、これ、およびこの質問に似ています... ゴルフの一般的なヒントは何VBAですか?私は、少なくともある程度特定のゴルフ問題全般のコーディングに適用できるアイデアを探していますVBA(たとえば、「コメントの削除」は答えではありません)。回答ごとに1つのヒントを投稿してください。 私は他の言語で仕事をしてきましたが、私はで最も強く、このサイトでVBA使用VBAしているゴルファーはあまりいません。
16 code-golf  tips  vba  basic 


3
Octaveの匿名関数を使用してベクターの要素を交換する方法は?
Octaveでは、ベクトル/マトリックス内の2つの要素を交換するのは非常に簡単です。 x='abcde'; x([4,1])=x([1,4]) x = dbcae 残念ながら、匿名関数内でこれを行う方法をまだ見つけていません。以下の関数は構文的には正しいですが、xベクトル全体ではなく、スワップされる2つの要素のみを返します。 f=@(x)(x([4,1])=x([1,4])) f(x) ans = ad 匿名関数を使用してゴルフのように望ましい動作を達成する方法はありますか?無名関数を使用して、この方法で複数の要素を交換できますか? 私は可能性がインデックスベクトルを作成しますf=@(x)x([4,2,3,1,5])が、動的なベクトルを作成する可能性があまりにもバイトの多くがかかります。

6
ハスクでのゴルフのヒント
Huskは、PPCGユーザーのLeoとZgarbによって作成された、まったく新しいゴルフ言語です。Jellyや05AB1Eなど、非常に簡潔であることが知られている言語の近くにとどまるか、さらには打ち負かすことさえあります。 ハスク特有のゴルフテクニックをいくつか挙げてみましょう。いつものように、回答ごとに1つのヒントを投稿してください。
15 code-golf  tips 

7
振動の平等
on [l, r]から始まる、時間単位ごとに1単位の速度で、2つの整数点間で振動するオブジェクトがあります。あなたが仮定することができます。たとえば、オブジェクトがで振動する場合、次のようになります。lt=0l < r[3, 6] t=0 -> 3 t=1 -> 4 t=2 -> 5 t=3 -> 6 t=4 -> 5 t=6 -> 4 t=7 -> 3 t=8 -> 4 しかし、オブジェクトは継続的に振動するため、ともt=0.5 -> 3.5ありt=3.7 -> 5.3ます。 、の間[l1, r1]で振動する2つのオブジェクトが与えられた[l2, r2]場合t、2つのオブジェクトが同じ位置を共有するような時間が存在するかどうかを判断します。l1, r1, l2, r2任意の便利な形式でテイクを作成し、真実/偽の値を出力します。 真実の入力: [[3, 6], [3, 6]] [[3, 6], [4, 8]] …
15 code-golf  array-manipulation  decision-problem  code-golf  math  number-theory  palindrome  integer-partitions  code-golf  math  decision-problem  geometry  code-golf  string  random  code-golf  ascii-art  code-golf  kolmogorov-complexity  primes  code-golf  kolmogorov-complexity  code-golf  graphical-output  code-golf  number-theory  primes  integer  factoring  code-golf  sequence  array-manipulation  integer  code-golf  array-manipulation  matrix  code-golf  sequence  binary  code-golf  game  cellular-automata  game-of-life  binary-matrix  code-golf  string  ascii-art  code-golf  random  generation  logic  code-golf  string  code-golf  code-golf  sequence  array-manipulation  random  apl  code-golf  code-golf  sequence  primes  code-golf  math  sequence  integer  code-golf  number  arithmetic  array-manipulation  decision-problem  code-golf  ascii-art  number  code-golf  restricted-source  quine  code-golf  chess  board-game  code-golf  math  sequence  code-golf  number  sequence  kolmogorov-complexity  code-golf  number  sequence  arithmetic  code-golf  math  number  alphabet  code-golf  ascii-art  classification  statistics  apl  code-golf  array-manipulation  matrix  code-golf  string  kolmogorov-complexity  code-golf  sequence  binary  base-conversion  binary-matrix  code-golf  string  classification  code-golf  tips  python  code-golf  combinatorics  binary  subsequence  restricted-time  code-golf  number  number-theory  code-golf  math  number  complex-numbers  code-golf  string  code-golf  string  code-golf  string  random  game  king-of-the-hill  python  code-golf  number  sequence  code-golf  number  sequence  code-golf  code-golf  math  number  array-manipulation  code-golf  array-manipulation  decision-problem  code-golf  string  code-golf  sequence  integer 

30
Parrotプログラムを作成する
入力が与えられると、その入力の後に改行が際限なく続きます。 入力は、印刷可能なASCII文字(0x20-0x7E)と改行(0x0A)のみで構成される文字列になります。 入力の長さが0の場合、改行を無限に出力します。 これはコードゴルフなので、各言語で最も少ないバイトです勝ちます!
15 code-golf  string  sequence  combinatorics  fastest-code  number  code-challenge  restricted-source  rosetta-stone  code-golf  arithmetic  decision-problem  integer  factorial  code-golf  arithmetic  decision-problem  integer  bitwise  code-golf  kolmogorov-complexity  code-golf  tips  vim  code-golf  quine  code-generation  code-golf  string  restricted-source  code-golf  string  random  unicode  code-golf  audio  code-golf  ascii-art  code-golf  decision-problem  code-golf  puzzle-solver  code-golf  restricted-source  code-golf  kolmogorov-complexity  permutations  hexagonal-grid  code-golf  string  math  combinatorics  fastest-code  code-golf  restricted-source  code-golf  string  code-golf  arithmetic  code-golf  math  number  code-golf  string  decision-problem  balanced-string  code-golf  binary  code-golf  string  number  code-challenge  restricted-source  code-golf  ascii-art  printable-ascii  interactive  code-golf  string  ascii-art  code-challenge  restricted-source  source-layout  code-golf  arithmetic  tips  functional-programming  golfing-language  code-golf  binary  encryption 

10
チャコールでのゴルフのヒント
木炭は、ASCIIアートの課題に特化したASCII専用およびDLoscによって作成された言語です。 チャコールでゴルフをするためのヒントはありますか?明らかに、すべてではないにしてもほとんどの言語に適用できるものではなく、特に炭に関連するヒントを探しています。
15 code-golf  tips 

3
Javaアスタリスクの長方形[閉じた]
閉じた。この質問には詳細または明確さが必要です。現在、回答を受け付けていません。 この質問を改善したいですか?詳細を追加し、この投稿を編集して問題を明確にします。 2年前に閉店。 私のCSクラスでは、インストラクターが、Javaで斜めの線が描かれたアスタリスクで作られた長方形を作成する割り当てを与えてくれました。 彼はまた、できる限り少ないバイト数で書き込むように言っています。190バイトに削減しましたが、このコードをさらに単純化してバイト数を減らすためにいくつかを見つける必要があります。誰でもこれで私を助けることができますか? このコードは機能的です: interface d{static void main(String[]a){for(int z=0,w=new Byte(a[0]),h=new Byte(a[1]);z<h*w;){int y=z/w,x=z++%w;System.out.print((x>w-2)?"*\n":(y%(h-1)*x*((y-x)%3)==0)?"*":" ");}}} 入力は10 10です。 出力: ********** ** * * * * * * ** * * * * ** * * * * * * ** * * * * ** * * * * * * …
15 tips  java 

2
ファットアロー関数を短縮する方法はありますか?
ここPPCGで私が見てきたことから、太い矢印関数を含むほとんどのJavaScriptエントリは、2つの陣営のうちの1つである傾向があります。 単一のステートメントとして実行し、すぐに答えを返すことができるシンプルなもの x=(a,b)=>a*a+b ループを使用しているために通常中括弧があり、結果としてreturnステートメントを使用する必要がある、より複雑なもの。p=b=>{m=b;for(a=1;~-m;)--m,a*=m*m;return a%b} 概念実証として中括弧の概念を持つカテゴリ2から上記の例を取り上げreturnます。これは、JSゴルファーのコードから8バイトを削除できる可能性があるため(これが常に発生するというわけではない)、これを求めているだけです。このインスタンスで使用できるテクニックはありますか?私は再帰を試みましたが、このm=b声明は揺るがすことができないように思われるので、ちょっとしたバグであることが証明されました。 上記のコードの場合、returnゴルフが短くなるかどうかに関係なく、どのようにしてさらにゴルフがステートメントを削除するでしょうか?

9
ラケット/スキームでのゴルフのヒント
ラケット / スキームでゴルフをするための一般的なヒントは何ですか?私は、少なくともラケット/スキームに特有のゴルフ問題全般のコーディングに適用できるアイデアを探しています(例えば、「コメントを削除する」は答えではありません)。 SchemeとRacket(以前のPLT Scheme)は技術的に異なる言語ですが、多くの点で非常に似ており、多くのコード(どちらかといえば)が意図したとおりに実行されることは承知しています。ヒントが前述の言語のいずれかにのみ適用される場合は、そのように注意してください。
15 code-golf  tips  lisp 

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

1
FASMでコンパイルされたx86 ASMのEXEサイズを減らす方法は?
演習として、x86アセンブリ言語でこの課題に対する簡単なソリューションを作成しました。これをWindowsのFASMで実行しています。これが私のソースコードです。 format PE console entry start include 'WIN32A.inc' section '.text' code executable start: push char ; Start at 'A' call [printf] ; Print the current letter 4 times call [printf] call [printf] call [printf] inc [char] ; Increment the letter cmp [char], 'Z' ; Compare to 'Z' jle start ; …

14
[N]とM反復の再帰的に連結された累積和
2つの正の整数NをM取得し[N]、M反復での連結累積和を作成します。最後の反復の結果を出力します。 連結累積合計の定義: 数字Nから始めてシーケンスを定義するX = [N] 追加Xの累積和X 手順を2 M回繰り返します。 ベクトルの累積合計X = [x1, x2, x3, x4]は次のとおり[x1, x1+x2, x1+x2+x3, x1+x2+x3+x4]です。 例N = 1とM = 4: P =累積和関数。 M = 0: [1] M = 1: [1, 1] - X = [1, P(1)] = [[1], [1]] M = 2: [1, 1, 1, 2] - X …
14 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 


12
そして、すべての人々が言っ​​た...
目的文字[またはを含まないテキストの入力を前提として]、次のアクションを実行します。 すべてのインスタンスのためのAmen少なくとも一つの大文字で(そのすべてのインスタンスAmenを除くamen)、同じことを出力Amen(時価総額を保持)。 /all the people said[?: ]/i(正規表現である)のすべてのインスタンスに対して、出力も行いますAmen(どんな場合でも問題ありません)。 すべての出力の後に、改行、スペース、無などの定数セパレーターを選択できます。 これはcode-golfであるため、バイト単位の最短プログラムが優先されます。 IOの例 Input: I said AMEN! AMEN, PEOPLE! Output: AMENAMEN ; any separator is fine, I choose none. Input: amen amen amen amen Output: ; nothing Input: ; empty Output: ; nothing Input: *blah blah blah* And all the people said? Output: …

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