2のない数字を表示する


22

1から100までの数字(昇順)を表示しますが、数字2はシーケンスのどこにも表示されません。そのため、たとえば、数字の2(2)または23(23)が連続してはいけません。

次に、数値を区切る改行を使用した出力例を示します。

1
3
4
5
6
7
8
9
10
11
13
14
15
16
17
18
19
30
31
33
34
35
36
37
38
39
40
41
43
44
45
46
47
48
49
50
51
53
54
55
56
57
58
59
60
61
63
64
65
66
67
68
69
70
71
73
74
75
76
77
78
79
80
81
83
84
85
86
87
88
89
90
91
93
94
95
96
97
98
99
100

7
勝利の基準はコードゴルフだと思いますか?
ルイスフェリペデジェススムニョス

4
このサイトは、Stack Exchangeネットワークの他のサイトと同じようには機能しません。受け入れられた回答については、ジョナサンアランからのこのコメントを考慮してください。そして、勝利基準を追加してください。
アーナルド

1
投稿する前に、今後サンドボックスを使用して課題に関するフィードバックを取得することをお勧めします
ジョーキング


4
@ user202729任意の制限は好ましくなく、禁止されていません。
ジョナサンフレッチ

回答:



26

タクシー2399 2391 2370 1783 1773 1706バイト

特定の乗客をサニーサイドパークに永遠に置き去りにする代わりに、リバービューブリッジから追い払うほうが価値があることを認識したため、-8バイト。ああ、なんて素敵な町なんだろう。

私が愚かに残したコメントを取り出すための-21バイト。

私がこれについて行った方法全体を変更するだけで-587バイト(明らかに短い方法は算術です; [17、27、37、47、...]を9で整数で除算するとシーケンスが得られますが、 20代です。)

スペースなしの引用符で囲まれた文字列は、引用符を必要としないことを認識するために-17バイト(Jo Kingに感謝!)

改行がオプションであることを認識するための-67バイト。

17 is waiting at Starchild Numerology.Go to Starchild Numerology:w 1 l 2 r 1 l 1 l 2 l.Pickup a passenger going to Cyclone.Go to Cyclone:e 1 l 2 r.[B]Pickup a passenger going to Cyclone.Pickup a passenger going to Divide and Conquer.9 is waiting at Starchild Numerology.Go to Starchild Numerology:s 2 l 2 r.Pickup a passenger going to Divide and Conquer.Go to Divide and Conquer:e 1 l 2 r 3 r 2 r 1 r.Pickup a passenger going to Trunkers.Go to Trunkers:e 1 r 3 r 1 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:e 1 r 1 r.Pickup a passenger going to Post Office.\n is waiting at Writer's Depot.Go to Writer's Depot:n 5 l 2 l.Pickup a passenger going to Post Office.Go to Post Office:n 1 r 2 r 1 l.Go to Cyclone:s 1 r 1 l 2 r.Pickup a passenger going to Addition Alley.Pickup a passenger going to Equal's Corner.177 is waiting at Starchild Numerology.Go to Starchild Numerology:s 2 l 2 r.Pickup a passenger going to Equal's Corner.Go to Equal's Corner:w 1 l.Switch to plan C if no one is waiting.Pickup a passenger going to Sunny Skies Park.100 is waiting at Starchild Numerology.Switch to plan D.[C]10 is waiting at Starchild Numerology.[D]Go to Starchild Numerology:n 1 r.Pickup a passenger going to Addition Alley.Go to Sunny Skies Park:w 1 r.Go to Addition Alley:n 1 r 1 r 1 r.Pickup a passenger going to Cyclone.Go to Cyclone:n 1 l 1 l.Pickup a passenger going to Cyclone.Pickup a passenger going to Equal's Corner.917 is waiting at Starchild Numerology.Go to Starchild Numerology:s 2 l 2 r.Pickup a passenger going to Equal's Corner.Go to Equal's Corner:w 1 l.Switch to plan E if no one is waiting.Switch to plan F.[E]Go to Go More:n 1 l.Go to Cyclone:w 1 r.Switch to plan B.[F]

オンラインでお試しください!

これはすぐに私にコードゴルフ大会に勝つことはありませんが、私はエソランタクシーを試してみることにしました。

タクシーは、架空の町タウンズバーグのさまざまな停留所で乗客を乗降させることによってすべてのプログラミングが行われるエソランです。もちろん、タクシーでガソリンが切れることもあるので、ガソリンスタンドを頻繁に訪れ、運賃として受け取ったクレジットを使用して支払う必要があります(この場合、私はガソリンのために停止する必要があります-Go More-ループ反復ごとに1回!)。

私はそのようなような方向言い換えとしてファイルサイズビットを削減するいくつかのトリック、使用east 1st left, 2nd rightなどをe 1 l 2 r、言葉取り除くtheことは任意であり、そして私の目的地のすべて(必ずしも最短経路)に向けた最も複雑なルートを使用します。

私が最初に思いついたものよりもこの短い解決策が嫌いです。ここでのこのソリューションは、タスクを達成するためのより一般的な方法であり、任意の場所で開始および終了できます。ここに、全体があります。

2245バイト(より一般的な方法)

1 is waiting at Starchild Numerology.Go to Starchild Numerology:w 1 l 2 r 1 l 1 l 2 l.Pickup a passenger going to Cyclone.Go to Cyclone:e 1 l 2 r.[B]Pickup a passenger going to Addition Alley.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:n 2 r 2 r.Pickup a passenger going to Cyclone.Go to Cyclone:n 5 l 2 l.Pickup a passenger going to Chop Suey.Go to Zoom Zoom:n.0 is waiting at Writer's Depot.Go to Writer's Depot:w.Pickup a passenger going to Narrow Path Park.Go to Narrow Path Park:n 3 r 1 l 1 r.Go to Chop Suey:e 1 r 1 l 1 r.[C]Switch to plan E if no one is waiting.Pickup a passenger going to Crime Lab.2 is waiting at Writer's Depot.Go to Writer's Depot:n 1 l 3 l.Pickup a passenger going to Crime Lab.Go to Crime Lab:n 3 r 2 r.Switch to plan D if no one is waiting.Pickup a passenger going to KonKat's.Go to Narrow Path Park:n 5 l.Pickup a passenger going to KonKat's.Go to KonKat's:e 1 r.Pickup a passenger going to Narrow Path Park.Go to Narrow Path Park:n 2 l.Go to Chop Suey:e 1 r 1 l 1 r.Switch to plan C.[D]Go to Chop Suey:n 5 r 1 l.Switch to plan C.[E]Go to Narrow Path Park:n 1 l 1 r 1 l.Pickup a passenger going to Crime Lab.0 is waiting at Writer's Depot.Go to Writer's Depot:w 1 l 1 r 2 l.1 is waiting at Starchild Numerology.Pickup a passenger going to Crime Lab.Go to Crime Lab:n 3 r 2 r.Switch to plan F if no one is waiting.Pickup a passenger going to Riverview Bridge.Go to Cyclone:n 4 l 2 l.Pickup a passenger going to Post Office.Go to Riverview Bridge:n 2 r.\n is waiting at Writer's Depot.Go to Writer's Depot:w 2 l.Pickup a passenger going to Post Office.Go to Post Office:n 1 r 2 r 1 l.Go to Starchild Numerology:s 1 r 1 l 1 l 2 l.Switch to plan G.[F]Go to Cyclone:s 1 r 1 l 2 r.Pickup a passenger going to Riverview Bridge.Go to Riverview Bridge:n 2 r.Go to Starchild Numerology:w 2 l 3 l 2 r.[G]Pickup a passenger going to Addition Alley.Go to Addition Alley:e 1 l 2 r 3 r 1 r.Pickup a passenger going to Magic Eight.101 is waiting at Starchild Numerology.Go to Starchild Numerology:n 1 l 1 l 3 l 2 r.Pickup a passenger going to Magic Eight.Go to Magic Eight:w 1 r 2 r 1 r.Switch to plan H if no one is waiting.Pickup a passenger going to Cyclone.Go to Cyclone:n 1 l 2 r.Switch to plan B.[H]

オンラインでお試しください!

巨大な不正行為が許可されている場合、これは最後の2つのいずれよりもはるかに短くなります。

456バイト(完全に不正行為)

1\n3\n4\n5\n6\n7\n8\n9\n10\n11\n13\n14\n15\n16\n17\n18\n19\n30\n31\n33\n34\n35\n36\n37\n38\n39\n40\n41\n43\n44\n45\n46\n47\n48\n49\n50\n51\n53\n54\n55\n56\n57\n58\n59\n60\n61\n63\n64\n65\n66\n67\n68\n69\n70\n71\n73\n74\n75\n76\n77\n78\n79\n80\n81\n83\n84\n85\n86\n87\n88\n89\n90\n91\n93\n94\n95\n96\n97\n98\n99\n100 is waiting at Writer's Depot.Go to Writer's Depot:w 1 l 2 r 1 l 2 l.Pickup a passenger going to Post Office.Go to Post Office:n 1 r 2 r 1 l.

オンラインでお試しください!


それは引用のことは有用なものです、ありがとう。ただし、「タクシーガレージに行く必要はありません」ということには同意しません。エラーで終了できますか?これに関する一般的なルールの良いセットを見つけることができません。
-JosiahRyanW

ええ、一般的にSTDERRは無視されます。関連メタ
ジョーキング

私の答えのいくつかはそれから利益を得ることができました。
-JosiahRyanW

22

Python 2、39バイト

k=7
exec"k+=10;print(k>177)*10+k/9;"*81

オンラインでお試しください!

2のない数値を生成するためにのみ算術演算を使用します。

kは算数の累進17, 27, 37, 47, ...に従います。9でフロア除算すると1,3,4,5,6,7,8,9,10,11,13,14,...、2で終わらない数をカウントアップします。20〜29をスキップするには、特定のしきい値を超えて出力が10増加します。


14

JavaScript(ES6)、43バイト

シーケンスをコンマ区切りの文字列として返します。

f=(n=98)=>n?f(n-=n-27?n%10?1:2:11)+[,n+3]:1

オンラインでお試しください!

どうしてこのようにするのですか?

1から100まで反復して/2/.test(n)、を使用して各数値をテストできます。しかし、このシナリオでは、次のようなもので空のエントリを処理する必要があります(/2/.test(n)?'':...)あり、さらに2バイト追加されます。

たとえば、これは45バイトで機能します

f=(n=1)=>n>99?n:(/2/.test(n)?'':[n,,])+f(n+1)

または、先頭のコンマが許容される場合、これは44バイトで機能します

f=(n=100)=>n?f(n-1)+(/2/.test(n)?'':[,n]):''

全体として(および他の方法で証明されるまで)、2を含むnのすべての値をすぐスキップするために短くなることがわかりました。n2

コメント済み

f =                 // f is a recursive function taking:
(n = 98) =>         // n = counter, initialized to 98
  n ?               // if n is not equal to 0:
    f(              //   prepend the result of a recursive call:
      n -=          //     update n:
        n - 27 ?    //       if n is not equal to 27:
          n % 10 ?  //         if n is not a multiple of 10:
            1       //           subtract 1 from n
          :         //         else:
            2       //           subtract 2 from n
        :           //       else (n = 27):
          11        //         subtract 11 from n (--> 16)
    ) +             //   end of recursive call
    [, n + 3]       //   append a comma, followed by n + 3; notice that this is the value
                    //   of n *after* it was updated for the recursive call; at the first
                    //   iteration, we have: n = 98 -> updated to 97 -> n + 3 = 100
  :                 // else (n = 0):
    1               //   output the first term '1' and stop recursion

1
これはとてもクールです!
エミグナ

1
先行するコンマがある場合は、トリックを使用し41バイト
オリバー

12

R、19バイト

grep(2,1:100,inv=T)

オンラインでお試しください!


grep(2,1:100,inv=T)19
J.Doe

2
ハ-これは私が最初に試したものでしたが、v=F明らかに、私は自分自身に考えたので、インデックスではなく値が欲しいので...
-ngm

正規表現自体の反転は1バイト短くなります(この場合)。
-ngm

動作しませんが、まだ2秒経過します。あなたは^[^2]*$どちらが短いかではない必要があります。
-J.Doe

4
何、今すぐ答えを確認することになっていますか?
ngm


10

Perl 6、22バイト

put grep {!/2/},1..100

オンラインでお試しください!

コードブロックを実行するより良い方法はおそらくありますが、一致を反転させる正規表現副詞が見つかりませんでした。


数字の周りの括弧を削除します。それ以外の場合は問題ありません。
モノリカ

@Monolica修正済み
ジョーキング

1
@Monolicaリストとして印刷することが許可されていないとして、あなたが私の答えを選んだのは少し奇妙に思えます。一方、それは、任意のバイトので、何でも私に費用がかからない
ジョー・キング

7

PowerShell22 16バイト

1..100-notmatch2

オンラインでお試しください!

mazzyのおかげで-6バイト

範囲1を生成してから100、それらのオブジェクトを取り出し-notmatchて番号を指定し2ます。-notmatchこのような配列に対してを実行すると、配列のフィルターのように機能します。各アイテムはパイプラインに残り、出力は暗黙的です。


1..100-notmatch2
奇抜な

@mazzyもちろん、なぜそう思わなかったのですか?ありがとう!
AdmBorkBork

6

Haskell48 33 31バイト

15バイト保存してくれた@JonathanFrechと、さらに2バイト保存してくれた@xnorに感謝します!大きなゴルフを見逃しましたmain=print$が、省略できることに気づきませんでした。

filter(all(/='2').show)[1..100]

オンラインでお試しください!

を変更することで簡単に拡張でき100ます。すべての数値を文字列化し、のない数値のみを保持し'2'ます。


こちらをご覧ください。これmain=print$は必要ありません。コードをテストしましたか?これelem'2'は有効な構文ではないと思います。なんでmap?単にfilter(not.elem '2'.show)[1..100]仕事をします。
ジョナサンフレッチ

@JonathanFrechうわー、それを見逃した。:/そのスペースがどこに行ったのか見当もつかない!それは... TIOにあります
Khuldraeseth na'Barya

2
HaskellにはありますnotElemnot.elem、さらに短いのはall(/='2')です。
-xnor



5

Java 10、67バイト

v->{for(int i=0;++i<101;)if(i%10!=2&i/10!=2)System.out.println(i);}

オンラインでお試しください。

説明:

v->{                           // Method with empty unused parameter and no return-type
  for(int i=0;++i<101;)        //  Loop `i` in the range (0, 101)
    if(i%10!=2                 //   If `i` modulo-10 is not 2
       &i/10!=2)               //   And `i` integer-divided by 10 is not 2 either
      System.out.println(i);}  //    Print `i` with a trailing newline

5

網膜19 17バイト


100*
.
$.>`¶
A`2

オンラインでお試しください!編集:@ovsのおかげで2バイト保存されましたが、最後の行には改行が含まれています。説明:


100*

100文字を挿入します。

.
$.>`¶

各文字を、その文字までの文字数と改行で置き換えます。

A`2

を含むすべてのエントリを削除します2


. $.>`¶第2段階で機能しますか?
-ovs

@ovs以前はもっと複雑なものがありL$、先頭の改行を避けるように切り替えていたので、元に戻すことができることに気づかなかった、ありがとう。
ニール


4

Wolfram言語(Mathematica)、42バイト

Print@⌈Range[1,100,10/9]~Drop~{18,26}⌉

オンラインでお試しください!

算術シーケンス1、19 / 9、29 / 9、39 / 9、...は、上限を取得すると2で終わるすべての数値がスキップされるのと同じ速度で成長しDropます。インデックス18〜26。


コンセンサスPrintが必要かどうかはわかりませんが、とにかく誰が本当に気にしますか。
ミシャラブロフ

[...]しかし、とにかく本当に気にしている人。-精神だ...
ジョナサンFRECH

やる\[LeftCeiling]\[RightCeiling]本当に:)シングルバイトとしてカウント
user6014

@ user6014ユニコードで占める3バイトとしてカウントしていますが、それでも実際のCeilingコマンドよりも少し安いです。
ミシャラヴロフ

@MishaLavrov Soundsフェア!きちんとしたソリューション。
user6014


4

Powershell、19バイト

1..100-split'.*2.*'

このスクリプトは、「内部に2のある数値」ではなくnull値を表示し、「数値2はシーケンスのどこにも表示されない」タスクを完全に解決します。

出力:

1


3
4
5
6
7
8
9
10
11


13
14
15
16
17
18
19




















30
31


33
34
35
36
37
38
39
40
41


43
44
45
46
47
48
49
50
51


53
54
55
56
57
58
59
60
61


63
64
65
66
67
68
69
70
71


73
74
75
76
77
78
79
80
81


83
84
85
86
87
88
89
90
91


93
94
95
96
97
98
99
100

Powerhsell(出力にはヌル値は含まれません)、24バイト

1..100-split'.*2.*'-ne''

4

sh + coreutils、16文字

seq 100|sed /2/d

1から100までのシーケンスを生成し、「2」が含まれる行を削除します。


このコードは、Digital Traumaによる回答と同じです。
ルスラン

ああくそー、私はチェックしたにもかかわらず、それを見なかった。私が後で投稿されたので、これを削除する必要がありますか?
therealfarfetched

4

Z80Golf49 48バイト

00000000: 1630 2e0a 5faf f57b fe02 2818 82ff f182  .0.._..{..(.....
00000010: ff92 3cf5 7dff f1bd 280a fe02 2803 f518  ..<.}...(...(...
00000020: e63c 18fa 7b3c bd20 db3e 31ff 3dff ff76  .<..{<. .>1.=..v

オンラインでお試しください!

アセンブリ:

ld d, 30h			; ascii '0' character
ld l, 0Ah			; number 10 and ascii newline
tens:
	ld e,a			; store tens digit
	xor a			; reset ones digit to 0
	push af			; store initial ones digit 0
	ones:
		ld a,e		; get stored tens digit
		cp 2
		jr z,cont	; if tens digit==2(e.g.20-29),skip loop
		add d
		rst 38h 	; print tens digit
		pop af		; get stored ones digit
		add d
		rst 38h 	; print ones digit
		sub d
		inc a		; increment ones digit
		push af		; store ones digit
		ld a, l
		rst 38h 	; print newline
		pop af		; get stored ones digit again
		cp l
		jr z,cont	; if ones digit==10, break loop
		cp 2
		jr z,inc_again	; if ones digit==2, incr again
		repeat_loop:
		push af		; store ones digit again
		jr ones		; repeat print loop
		inc_again:
			inc a
			jr repeat_loop
		
	cont:
	ld a,e			; get stored tens digit
	inc a			; increment tens digit
	cp l
	jr nz, tens		; if tens place!=10, continue loop
ld a,31h
rst 38h				; print '1'
dec a
rst 38h				; print '0'
rst 38h				; print '0'
halt

repeat_loopジャンプで1バイト保存


4

Pythonの353の51 50 49 46バイト

['2'in str(n)or print(n)for n in range(1,101)]

オンラインでお試しください!

このタスクのための最強の言語ではありませんが、私はゴルフを始めたばかりです。

コメンターのヒントに感謝します!


PPCGへようこそ!if。の前のスペースを削除することで50ラウンドにすることができます。
エルペドロ

[print(n)for n in range(1,101)if"2"not in str(n)]動作します。
-JosiahRyanW

あるいは、Python 2の回答の1つに基づいて:n=17;exec("print((n>177)*10+n//9);n+=10;"*81)
JosiahRyanW

@JosiahRyanW暗黙の印刷を知らなかった、ありがとう!
ギガフロップ

1
'2'in str(n)or print(n)理解度ガードよりも短いです。
ジョナサンフレッチ

4

Tcl、44バイト

time {if ![regexp 2 [incr i]] {puts $i}} 100

オンラインでお試しください!


Tcl、47バイト

time {if [incr i]%10!=2&$i/10!=2 {puts $i}} 100

オンラインでお試しください!

Tcl、50バイト

time {if {2 ni [split [incr i] ""]} {puts $i}} 100

オンラインでお試しください!


Tcl、49バイト time {if [string f 2 [incr i]]==-1 {puts $i}} 100outgolfに失敗しました!
セルジオ

あなたがあなたのテストを置き換えることができますregexp![regexp 2 [incr i]]-3バイトのために
デヴィッド・

@david正規表現を使用するというあなたから提案された解決策がなかったのはどうしてですか?ありがとう。
セルジオ


3

Bash、31バイト

printf %d\\n {1..100}|grep -v 2

オンラインでお試しください!

短いループのDigital Traumaに感謝します。


1
PPCGへようこそ!echo $iprintfの代わりにどうですか?それとももっと良いprintf %d\\n {1..100}|grep -v 2ですか?
デジタル外傷

そうだね。回答を更新します。
ケトン

私は実際に学んでいますが、私はそんなに感謝しません。
ケトン

私を打ち負かすecho {1..100}|tr ' ' \\n|grep -v 2
マークペリーマン

sed /2/d代わりに-1バイトを使用する場合grep -v 2
ルスラン

3

ORK、1092バイト

There is such a thing as a t
A t can w a number
A t can d a number
A t has a t which is a number

When a t is to w a number:
I have a mathematician called M
M's first operand is the number
M's second operand is 1
M is to add
The number is M's result
My t is 0
I have a number called n
n is the number
I am to d n
M's first operand is my t
M's second operand is 1
M is to compare
I have a scribe called W
If M says it's less then W is to write the number
If M says it's less then W is to write " "
M's first operand is the number
M's second operand is 100
M is to compare
If M says it's less then I am to loop

When a t is to d a number:
I have a mathematician called M
M's first operand is the number
M's second operand is 10
M is to modulo
I have a mathematician called N
N's first operand is M's result
N's second operand is 2
N is to compare
If N says it's equal then my t is 1
M is to divide
The number is M's result
M's first operand is the number
M's second operand is 0
M is to compare
If M says it's greater then I am to loop

When this program starts:
I have a t called T
T is to w 0

オンラインでお試しください!

O bjects R K 001を。出力は、スペースで区切られた数字のリストです。

これは、(およそ)次の擬似コードに変換されます。

class t {
	int t;
	
	void w(number) {
		label T_W;
		mathematician M;
		M.first_operand = number;
		M.second_operand = 1;
		M.add();
		number = M.result;
		t = 0;
		int n = number;
		d(n);
		M.first_operand = t;
		M.second_operand = 1;
		M.compare();
		scribe W;
		if M.its_less { W.write(number); }
		if M.its_less { W.write(" "); }
		M.first_operand = number;
		M.second_operand = 100;
		M.compare();
		if M.its_less { goto T_W; }
	}
	
	void d(number) {
		label T_D;
		mathematician M;
		M.first_operand = number;
		M.second_operand = 10;
		M.modulo();
		mathematician N;
		N.first_operand = M.result;
		N.second_operand = 2;
		N.compare();
		if N.its_equal { t = 1; }
		M.divide();
		number = M.result;
		M.first_operand = number;
		M.second_operand = 0;
		M.compare();
		if M.its_greater { goto T_D; }
	}
}

void main() {
	t T;
	T.w(0);
}

ご覧のとおり、すべては、基本的な数学およびIO関数を含むオブジェクトを使用して行われます(組み込みの数学者およびスクライブクラスを使用)。ループできるのは関数全体だけです。これは、2つの関数を持つオブジェクトが作業を行う必要性を説明しています。




3

PHP 7.1、40バイト

while($i++<100)strstr($i,50)||print$i._;

アンダースコアで区切られた数値を出力します。で実行する-nr、オンラインで試してください


PHPの奇抜な振る舞いをうまく使って数字を分けます、笑
ロベルト・マルドナド

1
preg_filter()ベース1は面白いです。(その関数を使用したことはありません。🤫)次のようにすると短くなりpreg_grep()ます<?=join(_,preg_grep("/2/",range(1,100),1));
マナトワーク


2

brainfuck、176バイト

---------[[-<]-[>]>[>]-[-<]<++]-[>-<+++++++++]>--[>[->]<[<<<]>>[->]>-]<<,<-[-<]>[>]<[.[->+<]++++++++++.,<]>>[>]>>->-<<<<[>>>[<<[<]<.>>[>]>.[-<+>]++++++++++.,>]<<[<]<,<]>>>>.<..

オンラインでお試しください!

短くすることは間違いなく可能です。これは、数値を生成1,3,4,5,6,7,8,9し、0,1,3,4,5,6,7,8,9。最初に最初のリストの各数値を出力し、次に最初と2番目のリストのすべての組み合わせを出力し、最後にjustを出力し100ます。

説明:

---------   Push minus 9
[           Repeat 9 times
  [-<]-[>]    Add the negative of the number to the first list
  >[>]-[-<]<  Add the negative of the number to the second list
  ++          Increment the counter
]
Tape: 255 254 253 252 251 250 249 248 247 0' 0 246 247 248 249 250 251 252 253 254
-[>-<+++++++++]>--  Push 197
Tape: 255 254 253 252 251 250 249 248 247 0 197' 246 247 248 249 250 251 252 253 254
[
  >[->]<    Subtract 197 from every element in both lists to convert to digits
  [<<<]>>
  [->]>-
]
Tape: 58 57 56 55 54 53 52 51 49 0' 49 50 51 52 53 54 55 56 57
<<,<-[-<]>[>]<  Remove the 0 and the 2 from the first list
Tape: 58 57 56 55 54 53 52 51 0 0 0' 49 50 51 52 53 54 55 56 57
[  Loop over the first list
  .[->+<]        Print digit
  ++++++++++.,<  Print a newline
]
>>[>]>>->-   Remove the 2 from the second list
<<<<      
[  Loop over first list
  >>>
  [  Loop over second list
    <<[<]<.        Print first digit
    >>[>]>.        Print second digit
    [-<+>]         Move second digit over one
    ++++++++++.,>  Print a newline
  ]
  <<[<]<,<  Remove the digit from the first list and move to the next
]
>>>>.<..  Print 100 using the second list

2

SimpleTemplate、51バイト

これは楽しいチャレンジでした!そして、それは私の言語がうまくいくことができる挑戦です。

{@forfrom 1to100}{@if_ is notmatches"<2>"}{@echol_}

1から100までのすべての値を循環し、2を持たない値を改行で区切って出力します。

あなたはhttp://sandbox.onlinephpfunctions.com/code/2c97a2b6954c29844f1079938da771d51e2e0d99でそれを試すことができます

ゴルフをしていない:

{@for i from 1 to 100}
    {@if i is not matches "<2>"}
        {@echo i, "\n"}
    {@/}
{@/}

{@/}閉じるために使用される{@for ...}{@if ...}、しかし任意です。
PHPにコンパイルするとき、必要な終了を追加します。


好奇心が強い場合、ゴルフのコードは次のPHPコードになります。

// {@forfrom 1to100}
// ~ optimization enabled ~ inlining the results
foreach(array(...) as $DATA['_']){

    // {@if_ is notmatches"<2>"}
    if(!(preg_match("<2>", (isset($DATA['_'])?$DATA['_']:null)))) {

        // {@echol_}
        echo implode('', $FN['array_flat']((isset($DATA['_'])?$DATA['_']:null)));echo PHP_EOL;


// AUTO-CLOSE
};};

$FN['array_flat']このコードの外部で定義されている場所。

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