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

この課題はPython言語に関連しています。回答が特定の言語である必要がある課題は、一般的には推奨されません。

3
私と一緒にゴルフ言語を構築する
多くのPPCGユーザーが、チャットとサンドボックスの両方で、特にMartin Ender、AdmBorkBork、Emigna、およびuser202729でこの課題の作成を支援しました。 私たちのコミュニティは、ゴルフのために特別に設計された一連の言語、つまり「ゴルフ言語」を作成する必要があると考えています。このような言語は、かつては見栄えがよく、今ではぎこちないGolfScriptから、JellyやHuskなどの洗練された簡潔な言語に進化しました。ご覧のとおり、これらの言語は、一連のタスクでますます短くなっています。ですから、ここの周りのゴルフの言語に関する明白な専門家として、私たちは競争する勇気がある他のすべての言語を打ち負かすために一緒に言語を設計するべきです。ビューグルの紹介! ラッパ:頭字語からBuGoL:Bu ilt Go lfing L anguage。 この課題の仕組み 導入部で私がほのめかしているものが得られなかった場合、この課題は回答連鎖課題であり、それぞれが新しいゴルフ言語の通訳者に何かを提供し、各回答でPPCGで競争する能力を向上させます。 言語仕様/通訳の基礎からなる最初の回答を投稿しますが、他のすべての回答はそれから継続します。新規提出により、次のものが提供されます。 言語の仕様の変更 最新の通訳者で、変更点に正確に対応しているもの 言語の更新されたスコア(詳細は少し) 次の3つの方法のいずれかで仕様を変更できます。 単一のコマンドを追加できます 2つの新しいコマンドを追加できます 1つの既存のコマンドの動作を編集できます 新しいインタープリターに関しては、Pythonで書かれた最新バージョンを使用する必要があります。ゴルフする必要はありません。以前に追加したコマンドはすべて、最新のインタープリターと最新のコマンド(追加したコマンド)でテスト可能でなければなりません。また、コメントや文字列リテラルなどのように、インタープリターを更新するときは、攻撃的な言語を使用しないでください。 追加されたコマンドは、あなたが望むことをするかもしれません。唯一の要件は次のとおりです。 攻撃的な出力を生成しません 別のコマンドとは異なります サンプルの課題の1つが完了するのを妨げません これらとは別に、必要に応じて特定または一般的なものにすることができます。また、任意の文字を使用できます。追加したコマンドが「新しいコマンド」であるかどうかわからない場合は、コメントでお気軽にお問い合わせください。 言語のスコア あなたは、すべての新しい提出物に言語のスコアを含める必要があることに気づいたかもしれません。そのスコアは、このチャレンジが永遠に続くことを防ぐものであり、次のように定義されます。 現在のスコアは、言語が20以下のタスクを完了するために必要なバイトカウントの合計です。 各タスクには、標準I / Oルールが適用され、標準の抜け穴が適用されます。 20のタスク: "こんにちは世界!" –文字列を出力するHello, World! 1、2、Fizz、4、Buzz – 1から100までの各整数を別々の行に出力します。3のFizz倍数が、5のBuzz倍数が、両方の倍数が、FizzBuzz ソースコードに数字を含めずに数字2014を生成する – 外部変数やランダムシードにアクセスせずに、ソースコードの文字を使用せずに数字2014を出力します0123456789 難読化されたHello World – Hello, World!次のセットの少なくとも2つの文字を使用せずに文字列を出力します:hlwd、eor01および27(大文字と小文字を区別しない) お気に入りのプログラミング言語にハッピーバースデーを歌う –選択した言語で、次を出力します。 Happy Birthday …

3
素数検定式
あなたの目標は、特定の数nが最小バイトで素数であるかどうかを判断することです。しかし、あなたのコードは、単一でなければならないのPython 2のみからなる数字で表現 オペレーター 入力変数 n 整数定数 括弧 ループなし、割り当てなし、組み込み関数なし、上記のリストのみ。はい、可能です。 オペレーター Python 2のすべての演算子のリストを次に示します。算術演算子、ビット演算子、論理演算子が含まれます。 + adddition - minus or unary negation * multiplication ** exponentiation, only with non-negative exponent / floor division % modulo << bit shift left >> bit shift right & bitwise and | bitwise or ^ bitwise xor ~ bitwise …

30
賢い人のMira気楼
むかしむかし、Quoraでこの質問/回答を読んでいた FizzBu​​zzテストに合格できないコンピューターサイエンスの学位を持つプログラマーは本当にいますか このコードは明白な答えとして与えられます for i in range(1, 100): if i % 3 == 0 and i % 5 == 0: print "FizzBuzz" elif i % 3 == 0: print "Fizz" elif i % 5 == 0: print "Buzz" else: print i もちろん、FizzBu​​zzは死ぬまでゴルフにかけられましたが、それはこの質問の目的ではありません。あなたはコメントで、4の倍数の印刷「ジャズ」などの追加条件を簡単に追加できるので、この明白な答えは素晴らしいと誰かが言及していることがわかります(同意しません。このスキームを拡張するにはO(2 ** n )コード行。) あなたの挑戦は、仲間によって判断されるようにFizzJazzBuzzの最も美しいバージョンを書くことです。 投票者が考慮すべき事項: ドライ 除算/モジュラス演算の効率 Quoraに関する回答の多くはPythonを使用していましたが、ここではそのような言語の制限はありません。 …
29 popularity-contest  code-challenge  word  popularity-contest  string  grid  language-design  code-golf  source-layout  math  fastest-algorithm  assembly  code-golf  json  code-golf  arithmetic  array-manipulation  code-golf  ascii-art  code-golf  crossword  code-golf  string  restricted-complexity  code-golf  ascii-art  kolmogorov-complexity  code-golf  string  decision-problem  balanced-string  syntax  code-golf  grid  puzzle-solver  hexagonal-grid  code-golf  math  number  sequence  code-golf  string  decision-problem  code-golf  cryptography  king-of-the-hill  code-challenge  fastest-code  code-golf  number  code-golf  code-golf  string  code-golf  cryptography  king-of-the-hill  java  code-golf  number-theory  base-conversion  code-golf  code-golf  array-manipulation  code-golf  array-manipulation  sorting  code-challenge  restricted-source  quine  code-golf  tips  python  king-of-the-hill  code-golf  source-layout  fractal  code-golf  tips  game  king-of-the-hill  path-finding  grid  code-golf  kolmogorov-complexity  natural-language  code-golf  tips  python  code-golf  number  arithmetic  sequence  array-manipulation  code-golf  number  combinatorics  random  integer-partitions  code-golf  string  code-golf  vim  comment  code-golf  combinatorics  counting  code-challenge  rosetta-stone  code-golf  combinatorics  sequence  subsequence  code-golf  code-challenge  restricted-source  primes  printable-ascii  popularity-contest  graphical-output  image-processing 

13
廃inの冒険者
テストドライバー • チャレンジディスカッション • 冒険家を提出する (画像ソース) 数人のライバルの冒険者が宝物のために廃insを襲撃していますが、彼らは一度に多くを運ぶことができるだけで、持久力の限界があります。彼らは最も価値のある宝物を手に入れ、疲れすぎて続行できない前に出たいと思っています。彼らは略奪するシェナンガンから可能な限り金持ちになろうとしています。 ゲームプレイ それぞれの冒険者は、1000個のスタミナポイントとバックパックに50kgのスペースがあるダンジョンの最初の部屋から始まります。 ゲームはターンベースの方法で動作し、すべてのプレイヤーが同時にターンを解決します。ターンごとに、次のアクションのいずれかを実行できます。 次の部屋に移動します。 前の部屋に移動します。 宝を取るためにスタミナを入札します。 宝物をドロップします。 部屋間を移動するには、10スタミナに加えて、現在バックパックに入っている5 kgごとに1スタミナが必要です。たとえば、3kgの宝物を運ぶ冒険者の移動には11体のスタミナが必要で、47kgの宝物の移動には20体のスタミナが必要です。 宝をドロップするには、ドロップする宝に関係なくスタミナが1つ必要です。 廃insを出ると、プレイヤーはこれ以上ターンを行いません。 プレーヤーがこれらのアクションのいずれかを実行できない場合(スタミナの不足または宝物の欠如)、冒険者は疲弊して死に、保有している宝物を現在占有されている部屋にこぼします。同様に、プレイヤーが無効なアクションを行おうとすると、冒険者は代わりにトラップで殺され、同じ宝物が流出します。 入札 宝の最低入札価格は、宝の重さ1kgにつき1スタミナです。宝物を獲得する可能性が高くなるように、追加のスタミナポイントを入札することもできます。入札されたスタミナは、結果がどうであれ消費されます。 複数のプレイヤーが同じ宝を獲得するために入札した場合、最高額を入札したプレイヤーが宝を獲得します。複数のプレイヤーが最高入札を行った場合、誰も宝を受け取りません。 勝利条件 宝物の合計値が最大のプレイヤーが勝者です。まれにネクタイが発生した場合、タイは最小の総重量、次に最小の宝物数、次に最も価値のある宝物、2番目に貴重なもの、3番目...に至るまで続きます。ほぼ不可能なこの時点で引き分けがある場合、テストドライバーは「それをねじ込む」と言い、勝者はそれによって任意に決定されます。 トーナメントの文脈では、プレイヤーは1位で10ポイント、2位で9ポイント、3位で8ポイント、などとランク付けされます。 遺跡について 各部屋は、最初の間に含まと宝物。(は部屋番号です)⌊ R3⌋ + 3⌊r3⌋+3\lfloor{r \over 3}\rfloor + 3⌊ R2⌋ + 5⌊r2⌋+5\lfloor{r \over 2}\rfloor + 5rrr 冒険者のスタミナと探検意欲によってのみ制限される、任意の多くの部屋があります。 各宝には、金銭的価値(全体で$)と重量(全体でkg)があります。 遺跡の奥深くに行くほど、宝物はより価値があり、豊富になる傾向があります。 宝物を生成するための具体的な式は次のとおりです:(サイコロロールに表記を使用) x dyxdyxdy 式(最小1)を使用して最初に重みが生成されます2 D6 − …

18
回転対称性のある数
整数、出力所与truthyのそれは同じ逆さまである場合、値または(180°回転)falsyそうでない場合、値を。 0、1、及び8回転対称性を持っています。6となり9、逆もまた同様です。 真実の結果を生み出す一連の数字:OEIS A000787 0, 1, 8, 11, 69, 88, 96, 101, 111, 181, 609, 619, 689, 808, 818, 888, 906, 916, 986, 1001, 1111, 1691, 1881, 1961, 6009, 6119, 6699, 6889, 6969, 8008, 8118, 8698, 8888, 8968, 9006, 9116, 9696, 9886, 9966, 10001, 10101, 10801, 11011, 11111, 11811, 16091, …
27 code-golf  number  sequence  decision-problem  code-golf  string  parsing  c  code-golf  sorting  integer  code-golf  number  sequence  rational-numbers  graphical-output  atomic-code-golf  assembly  box-256  code-golf  geometry  tips  python  code-golf  number  sequence  arithmetic  number-theory  code-golf  ascii-art  kolmogorov-complexity  geometry  code-golf  graphical-output  code-golf  math  code-golf  grid  cellular-automata  game-of-life  code-golf  string  subsequence  code-golf  arithmetic  rational-numbers  code-golf  tips  dc  code-golf  ascii-art  kolmogorov-complexity  date  code-golf  string  primes  code-golf  string  natural-language  conversion  code-golf  sequence  code-golf  number-theory  primes  base-conversion  code-golf  math  primes  base-conversion  code-golf  ascii-art  fractal  code-golf  matrix  code-golf  math  tips  geometry  python  string  code-challenge  keyboard  code-golf  graphical-output  code-golf  string  code-golf  number  sequence  cops-and-robbers  number  sequence  cops-and-robbers 

3
簡易カーニングを実装する
前書き カーニングとは、テキストの文字間の間隔を調整することを意味します。例として、Top次の3つのグリフで書かれた単語を考えます。 ##### ..... ..... ..#.. ..... ..... ..#.. ..##. .###. ..#.. .#..# .#..# ..#.. .#..# .#..# ..#.. ..##. .###. ..... ..... .#... ..... ..... .#... グリフ間のギャップをドットで埋めて完了させることもできますが、ギャップはどうやら広すぎるように見えます。代わりに、グリフを左にスライドさせて、ほとんど触れないようにします。 #####........ ..#.......... ..#..##..###. ..#.#..#.#..# ..#.#..#.#..# ..#..##..###. .........#... .........#... これはずっと良く見える!のバーがTの左の境界線の上にあることに注意してくださいo。この課題では、このような長方形のグリフに簡単なカーニングプログラムを実装することがタスクです。 カーニングプロセス 二長方形の2次元文字配列考える.と#同じ形状を。単純なカーニングプロセスでは、最初に1列の.sを挟んで配列を並べて配置します。次に、#右と左の配列のいくつか#が直交または斜めに隣接するまで、右の配列のそれぞれを左に1ステップ移動します。カーニングの結果は、隣接するを導入する前のステップ#です。あなたの仕事は、このプロセスを実装することです。 例を見てみましょう: Inputs: ..### #.... #.... ..##. ...#. ...## ..### ....# Process: ..###....#. …
24 code-golf  grid  code-challenge  atomic-code-golf  code-golf  combinatorics  probability-theory  card-games  code-golf  number  geometry  code-golf  decision-problem  chess  code-golf  math  number  sequence  code-golf  string  regular-expression  code-golf  arithmetic  integer  code-golf  math  array-manipulation  code-golf  number  decision-problem  integer  code-golf  string  ascii-art  kolmogorov-complexity  code-golf  decision-problem  graph-theory  binary-matrix  code-golf  string  parsing  code-golf  string  code-golf  morse  code-golf  code-golf  string  code-golf  ascii-art  cellular-automata  code-golf  binary  base-conversion  code-golf  arithmetic  decision-problem  integer  checksum  code-golf  matrix  linear-algebra  code-golf  code-golf  game  code-golf  sequence  binary  code-golf  combinatorics  optimization  code-golf  decision-problem  quine  code-golf  rational-numbers  bitwise  code-golf  string  permutations  code-golf  kolmogorov-complexity  unicode  code-golf  ascii-art  number  code-golf  number  integer  binary  base-conversion  code-golf  array-manipulation  code-golf  chemistry  code-golf  number  sequence  fibonacci  code-golf  matrix  optimization  code-golf  number  code-golf  math  number  sequence  code-golf  math  array-manipulation  matrix  linear-algebra  code-golf  kolmogorov-complexity  cops-and-robbers  cops-and-robbers  code-golf  tips  basic  code-golf  decision-problem  binary  tiling  game  king-of-the-hill  python  code-golf  c  code-golf  ascii-art  code-golf  string  kolmogorov-complexity  alphabet  code-golf  number  code-golf  string  code-golf  number  sequence  integer  code-golf  number  permutations  restricted-complexity  restricted-time 

10
最短の一意に識別する部分文字列
文字列のリストが与えられたら、各文字列を、空でない部分文字列の1つで置き換えます。これは、リスト内の他の文字列の部分文字列ではなく、できるだけ短くします。 例 リストを考えると["hello","hallo","hola"]、"hello"ただで置き換える必要があり"e"、この部分文字列がに含まれていないとして、"hallo"そして"hola"、それはできるだけ短くしています。"hallo"いずれかで置き換えることができる"ha"か、"al"と"hola"のいずれかによって"ho"、"ol"または"la"。 ルール 文字列は空ではなく、同じ大文字と小文字のアルファベットのみを含むと想定できます。 このような部分文字列はリスト内の各文字列に存在すると仮定できます。つまり、リスト内の文字列は他の文字列の部分文字列にはなりません。 入力と出力は任意の合理的な形式にすることができます。 これはcode-golfなので、選択した言語でできるだけ少ないバイトを使用するようにしてください。 テストケース ほとんどの場合、可能な出力は1つだけです。 ["ppcg"] -> ["p"] (or ["c"] or ["g"]) ["hello","hallo","hola"] -> ["e","ha","ho"] ["abc","bca","bac"] -> ["ab","ca","ba"] ["abc","abd","dbc"] -> ["abc","bd","db"] ["lorem","ipsum","dolor","sit","amet"] -> ["re","p","d","si","a"] ["abc","acb","bac","bca","cab","cba"] -> ["abc","acb","bac","bca","cab","cba"] 関連:最短識別サブストリング -同様のアイデアですが、より複雑なルールと扱いにくい形式です。
23 code-golf  string  code-golf  string  code-golf  array-manipulation  code-golf  quine  code-golf  array-manipulation  integer  matrix  classification  code-golf  quine  code-golf  string  matrix  conversion  code-golf  string  number  code-golf  string  code-golf  number  sequence  integer  code-golf  decision-problem  matrix  code-golf  string  code-golf  math  code-golf  math  array-manipulation  combinatorics  code-golf  random  code-golf  code-golf  alphabet  code-golf  python  c  code-golf  base-conversion  code-golf  string  counting  code-challenge  code-generation  fastest-code  code-golf  kolmogorov-complexity  matrix  code-golf  string  code-golf  array-manipulation  decision-problem  random  sudoku  code-golf  chess  code-golf  card-games  encode  code-golf  decision-problem  code-golf  code-golf  math  array-manipulation  matrix 

10
自然ログのアリ
これは良い初心者の挑戦であり、良い時間のキラーです。 タイトルが短すぎたため、自然対数だけを言いました。これは対数とは関係ありません。 与えられた2つの変数: アリの数n。 ログの幅w。 幅のログwをnアリで出力します(例はw=3、n=6) | | | \O/ \O/ \O/ | | -O- -O- -O- | | /o\ /o\ /o\ | | ^ ^ ^ | | | | \O/ \O/ \O/ | | -O- -O- -O- | | /o\ /o\ /o\ | | ^ ^ ^ | …

7
Pythonでメンバー関数をエイリアスするにはどうすればよいですか?
Pythonでは、繰り返し使用される関数をエイリアスすることでバイトを節約できます。例えば: r=range a=r(100) b=r(200) c=r(300) ただし、関数が一緒にメンバー関数である場合、チェーンを可能にする方法でそれらをエイリアスする方法がわかりません。例えば: s='Hello' // Plain code s=s.replace('H','J').replace('e','i').replace('l','m').replace('o','y') // What I am trying to do q=replace s=s.q('H','J').q('e','i').q('l','m').q('o','y') 明らかに、私がやろうとしていることは無効です。そして、これもどちらでもありません: q=s.replace s=q('H','J') // Replaces the 'H' in 'Hello' s=q('e','i') // Replaces the 'e' in 'Hello'... and the J is gone. s=q('l','m') s=q('o','y') メンバー関数とチェーン関数をエイリアスして文字を保存する別の方法はありますか?
23 code-golf  tips  python 

23
アスキーアートオクタゴン
入力整数を指定するとn > 1、n文字で構成される辺の長さのASCIIアートオクタゴンを出力します。以下の例を参照してください。 n=2 ## # # # # ## n=3 ### # # # # # # # # # # ### n=4 #### # # # # # # # # # # # # # # # # #### n=5 ##### # # # # # # …
22 code-golf  ascii-art  code-golf  geometry  code-golf  balanced-string  code-golf  cops-and-robbers  code-challenge  cops-and-robbers  code-golf  code-golf  random  cryptography  code-golf  array-manipulation  number  code-challenge  integer  code-golf  math  integer  code-golf  math  math  parsing  image-processing  test-battery  math  number  combinatorics  fastest-code  code-golf  code-golf  math  number-theory  rational-numbers  polynomials  code-golf  math  geometry  code-golf  code-golf  number-theory  primes  factoring  code-golf  restricted-source  code-golf  string  decision-problem  counting  code-golf  math  sequence  fibonacci  code-golf  array-manipulation  counting  code-golf  array-manipulation  number-theory  code-golf  array-manipulation  code-golf  random  code-golf  string  hexadecimal  code-golf  string  code-challenge  sorting  code-golf  number  floating-point  code-golf  sorting  code-golf  decision-problem  fibonacci  code-golf  number  combinatorics  code-golf  string  code-golf  math  code-golf  electrical-engineering  code-golf  javascript  code-golf  base-conversion  code-golf  array-manipulation  matrix  binary-matrix  code-golf  kolmogorov-complexity  python  perl  ruby  code-golf  number  code-golf  optimization  integer-partitions  code-golf  string  code-golf  ascii-art 

24
ogl-edocfチャレンジ
入力 範囲のASCII文字で構成される空でないシャッフルされた文字列。[ 32..126 ][32..126][32..126] 出力 出力は、入力文字列に連続した回転を適用することにより取得されます。 [a-zA-Z]入力文字列の各文字()について、左から右へ: 文字が大文字の場合、その前のすべての文字を左に1ポジションだけ回転します 文字が小文字の場合、その前のすべての文字を1つ右に回転します 例 入力:「Cb-Ad」 最初の文字は「C」です。左に回転する必要がありますが、この「C」の前に文字はありません。したがって、回転するものは何もありません。 次の文字は「b」です。「C」を右に回転します。単一の文字であるため、変更されません。 文字「-」は文字ではないため、回転をトリガーしません。 次の文字は「A」です。「Cb-」を左に回転すると、「bC Ad」が得られます 4番目の最後の文字は「d」です。「b-CA」を右に回転させると、「Ab-C d」が得られます したがって、予想される出力は「Ab-Cd」です。 ルール 入力は、文字列または文字の配列として受け取ることができます。これは、言語に応じて、同じである場合とそうでない場合があります。 文字列の代わりに文字の配列を出力することもできます。 これはogl-edocf code-golfです テストケース "cbad" -> "abcd" "ACBD" -> "ABCD" "Cb-Ad" -> "Ab-Cd" "caeBDF" -> "aBcDeF" "aEcbDF" -> "abcDEF" "ogl-edocf" -> "code-golf" "W o,ollelrHd!" -> "Hello, World!" "ti HIs …
22 code-golf  string  code-golf  string  code-golf  string  parsing  brainfuck  code-challenge  python  hello-world  error-message  code-golf  string  code-golf  number  integer  counting  subsequence  code-golf  string  cipher  code-golf  array-manipulation  arithmetic  integer  matrix  code-golf  math  sequence  code-golf  restricted-source  pi  popularity-contest  cops-and-robbers  polyglot  popularity-contest  cops-and-robbers  polyglot  code-golf  file-system  king-of-the-hill  code-golf  number  sequence  integer  rational-numbers  string  code-challenge  source-layout  code-golf  ascii-art  king-of-the-hill  code-golf  array-manipulation  sorting  code-golf  string  code-golf  restricted-source  source-layout  tips  math  code-challenge  permutations  logic-gates  code-golf  number  random  integer  code-golf  math  code-golf  math  number  decision-problem  king-of-the-hill  python  board-game  code-challenge  brainfuck  busy-beaver  code-golf  number  cops-and-robbers  polyglot  obfuscation  answer-chaining  code-golf  number  integer  conversion  code-golf  string  parsing  code-golf  ascii-art  number  king-of-the-hill  javascript  code-golf  source-layout  radiation-hardening  code-golf  array-manipulation  matrix  code-golf  string  graph-theory  code-golf  array-manipulation  decision-problem  code-golf  string  ascii-art  code-golf  string  code-golf  array-manipulation 

30
最初に0ではなく、個別の数字でランダムなn桁の数字を取得します
私はこの質問を読み、それがいい挑戦になると思った。 仕事 入力0<n<10で乱数を生成する 正確にn桁 最初ではない 0 そう f(n)>10**(n-1)-1 個別の数字 受賞基準 これはコードゴルフなので、最短のコードが優先されます。 ランダム ランダムに均等に分散されるということです。そのため、プログラムの観点からは、考えられる各数字には同じチャンスがあります。あなたが書いている言語が奇妙な乱数ジェネレーターを持っているなら、それを使用しても大丈夫です。 例 ランダムに選択する値のリストn=2は次のとおりです。 [10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 47, 48, …
22 code-golf  number  random  grid  game  king-of-the-hill  javascript  code-golf  arithmetic  statistics  code-golf  math  code-golf  math  code-golf  string  palindrome  code-golf  string  interactive  code-golf  quine  polyglot  code-golf  string  stack-exchange-api  code-golf  number-theory  decision-problem  code-golf  tips  code-golf  string  internet  code-golf  graphical-output  image-processing  fractal  code-golf  ascii-art  geometry  hexagonal-grid  code-golf  string  restricted-source  hello-world  code-golf  game  code-golf  cipher  code-golf  permutations  cops-and-robbers  permutations  cops-and-robbers  code-golf  internet  stack-exchange-api  code-golf  ascii-art  random  code-golf  tips  code-golf  ascii-art  code-golf  code-golf  kolmogorov-complexity  code-golf  string  unicode  code-golf  number  sequence  primes  palindrome  code-golf  game  decision-problem  code-golf  math  geometry  code-golf  graphical-output  interactive  code-golf  set-partitions  code-golf  number  arithmetic  restricted-source  code-golf  decision-problem  python  recursion  code-golf  ascii-art  code-golf  source-layout  code-golf  function  recursion  functional-programming  code-golf  game  combinatorics  permutations  code-golf  string  file-system  code-golf  string  hashing  code-golf  stack-exchange-api  code-golf  string  code-golf  math  number  arithmetic  polyglot 

1
ゴルフのPython文字列リテラル
バックグラウンド Python 3には多くの種類の文字列リテラルがあります。たとえば、文字列this 'is' an exa\\m/pleは次のように表すことができます。 'this \'is\' an exa\\\\m/ple' "this 'is' an exa\\\\m/ple" r"this 'is' an exa\\m/ple" '''this 'is' an exa\\\\m/ple''' """this 'is' an exa\\\\m/ple""" r'''this 'is' an exa\\m/ple''' r"""this 'is' an exa\\m/ple""" ご覧のとおり、文字列に異なる区切り文字を使用すると、特定の文字に必要なエスケープを変更することで文字列を延長または短縮できます。一部の区切り文字はすべての文字列に使用できません:上にr'ありません(説明については後述)。あなたの弦を知ることは、コードゴルフで非常に役立ちます。 複数の文字列リテラルを1つに結合することもできます。 'this \'is\' an ''''exa\\\\m/ple''' "this 'is' an "r'exa\\m/ple' チャレンジ 課題は、印刷可能なASCII文字列が与えられた場合、Pythonで最短のリテラル表現を出力することです。 弦力学の詳細 文字列を使用して区切ることができ'、"、'''と"""。開始デリミタがエスケープされずに再びヒットすると、文字列は終了します。 文字列リテラルがで始まる'''か"""、区切り文字として使用される場合。それ以外の場合、'または"使用されます。 文字をエスケープするには、\それらの前にを配置します。これにより、文字列に文字が挿入され、その特殊な意味が排除されます。たとえば'a …

3
人生がレモンを与えたら、レモネードを作りなさい
チャレンジ あなたはどこにでも単語が、入力文字列が与えられます"Lemon"、それはに変換する必要が発見され"Lemonade" たがa、d、およびe文のどこかから借りなければなりません。 例 入力例: 子供の頃にレモンを見つけました 出力例: 私は子供の頃レモネードを作りました レモネードは、元から次の上付き文字を盗んで作成されました 私はフン日間レモネードWH 電子を nは私がいた子供 これは、「e」、「d」、および「a」という可能な出力例の1つにすぎません。これはどこからでも取得できます(もちろん、単語以外はlemon) コメント •、、またはsが十分eでない場合は、指定された文字で実行可能なことを出力する必要があります。たとえば、入力は出力されますadbdblemonbblemond • lemonテキストは常にスタンドアロン(各側のスペース)であるとは限りません。たとえばlemons、入力のどこかに単語があり、出力は次のようになります。lemonades •入力にはlemon、0であっても任意の数のsを含めることができますlemon(この場合、出力は入力と同一になります)。 •レモネードを大文字と小文字で作成できます。たとえば、にleMonなる可能性がleMonadeあり、ade借りたものはどのような場合でも可能です(したがって、になる可能性もありますleMonADe)。あなたが借りた手紙のケースは、あなたがそれを借りたときの状態のままでなければなりません。(入力例->出力、he hAD lemOn-> h h lemOnADe) •完全なプログラムである必要はありません。機能だけで十分です。 •入力はCP437文字セットのみであると仮定できます。 コードゴルフ これはcode-golfであるため、バイト数が最も少なくなります! 擬似テストケース *注意:特定の入力に対して複数の出力が存在する可能性があるため、プログラムはこれらのテストケースのように正確に出力されない場合があります。これは、人々がロジックを理解できるようにするためです。 入力:EpaD leMons 出力:p LeMonaDEs 入力:hello world 出力:hello world 入力:レモンレモン 出力:レモンレモン *( 、、 文字は別の「レモン」から取られてはいけません)ead 入力:HE HADレモネード 出力:HH lemonADEade 入力:あなたはレモンが好きですか?あなたはレモンで私を苦しめました! 出力:o lemonADesが好きですか?あなたはレモネードを盛り上げました! …
21 code-golf  string  code-golf  parsing  internet  stack-exchange-api  code-challenge  kolmogorov-complexity  restricted-source  brain-flak  python  logic  pyth  code-golf  string  search  optimized-output  code-golf  tips  language-design  golfing-language  code-golf  tips  language-design  code-golf  number  sorting  pi  code-golf  math  number  code-golf  string  balanced-string  classification  brain-flak  code-golf  math  number-theory  decision-problem  code-golf  tips  code-golf  number  sequence  code-golf  balanced-string  brain-flak  code-golf  math  sequence  arithmetic  fibonacci  code-golf  math  parsing  code-golf  string  keyboard  code-golf  code-golf  string  source-layout  whitespace  code-golf  math  rational-numbers  code-golf  string  code-golf  string  code-golf  math  sequence  code-golf  number  floating-point  code-golf  string  decision-problem  subsequence  code-golf  string  kolmogorov-complexity  code-golf  string  permutations  balanced-string  brain-flak  code-golf  string  math  number  code-golf  string  primes  cipher  code-golf  string  ascii-art  chemistry  code-golf  ascii-art  grid  counting  code-golf  math  arithmetic  integer  code-golf  number  kolmogorov-complexity  code-golf  ascii-art  kolmogorov-complexity  sequence  metagolf  brain-flak  code-golf  ascii-art  kolmogorov-complexity  code-golf  string  whitespace 

30
指定された幅で#の中空の正方形を描画します
私はCodingameからこの課題を受け取り、私のものよりも優れたソリューションに興味があります。 標準入力を使用して幅を指定すると、指定された幅と長さで「#」の中空の四角形が描画されます。 例: 5の結果 ##### # # # # # # ##### 私はこれを解決するためにPythonを使用したので、他のPythonコードに特に興味があります。ただし、必要な言語でソリューションを投稿してください。
21 code-golf  string  ascii-art  number  code-golf  grid  code-golf  string  ascii-art  code-golf  alphabet  cipher  code-golf  math  number  code-golf  quine  code-golf  palindrome  polyglot  code-golf  number  array-manipulation  counting  logic  code-golf  string  primes  binary  decision-problem  code-golf  ascii-art  kolmogorov-complexity  popularity-contest  code-golf  probability-theory  code-golf  string  code-golf  python  polyglot  programming-puzzle  c++  code-golf  math  code-golf  binary  integer  bitwise  code-golf  rational-numbers  code-golf  string  palindrome  code-golf  ascii-art  code-golf  code-golf  string  fibonacci  code-golf  math  sequence  code-golf  code-golf  string  palindrome  code-golf  string  code-golf  math  primes  source-layout  code-golf  sequence  binary  integer  code-golf  math  arithmetic  game  code-golf  restricted-source  palindrome  code-golf  restricted-source  palindrome  code-golf  combinatorics  binary  code-golf  string  math  code-golf  ascii-art  number  code-golf  cipher  code-golf  base-conversion  counting  code-golf  sequence  random  classification  code-golf  string  subsequence  code-golf  permutations  code-golf  string  code-golf  string  cipher  code-golf  kolmogorov-complexity  arithmetic  integer  code-golf  quine  markov-chain  code-golf  string  code-golf  code-golf  ascii-art  maze 

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