2가없는 표시 번호


22

1부터 100까지 (순서대로) 숫자를 표시하지만 순서 2에는 숫자 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
우승 기준이 코드 골프라고 가정합니까?
Luis felipe De jesus Munoz

4
우리 사이트는 Stack Exchange 네트워크의 다른 사이트와 같은 방식으로 작동하지 않습니다. 허용 된 답변에 대해서는 Jonathan Allan의이 의견 을 고려하십시오. 그리고 승리 기준을 추가하십시오.
Arnauld

1
게시하기 전에 앞으로 샌드 박스 를 사용 하여 문제에 대한 피드백을받는 것이 좋습니다 .
Jo King

1
@Monolica 가장 짧은 답변이 이기면 태그가 필요합니다 [code-golf]. 다음은 나중에 참조 할 수있는 모든 우승 기준 태그 목록입니다.
Kevin Cruijssen

4
@ user202729 임의의 제한은 환영받지 않으며 허용되지 않습니다.
Jonathan Frech

답변:



26

택시 , 2399 2391 2370 1783 1773 1706 바이트

-8 바이트는 Sunny Side Park에 특정 승객을 영원히 떠나는 대신 Riverview Bridge에서 버리는 것이 좋습니다. 아,이 얼마나 아름다운 마을입니까.

내가 멍청하게 남긴 의견을 가져 오기위한 -21 바이트.

-587 바이트는 단순히 내가 갔던 전체 방식을 변경하여 (명확히 짧은 방법은 산술입니다. [17, 27, 37, 47, ...]을 9로 정수 나누면 시퀀스가 ​​생성되지만 건너 뛰어야합니다. 20은 당신입니다.)

공백없이 따옴표로 묶은 문자열에는 따옴표가 필요하지 않습니다. (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]

온라인으로 사용해보십시오!

이것은 곧 나에게 어떤 코드 골프 대회에서도 이길 수는 없지만 esolang Taxi를 사용해보기로 결정했습니다.

Taxi는 가상의 Townsburg 타운의 여러 정거장에서 승객을 태우고 내려서 모든 프로그래밍을 수행하는 esolang입니다. 물론 택시에는 때때로 가스가 고갈되기 때문에 주유소를 자주 방문하고 요금으로받는 크레딧을 사용하여 지불해야합니다 (이 경우에는 가스를 위해 중지하면됩니다)-More More 루프 반복 당 한 번!).

나는 그런 같은 방향의 문구를 수정과 파일 크기를 조금 줄 몇 가지 트릭, 사용 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]

온라인으로 사용해보십시오!

그리고 거대 부정 행위가 허용된다면, 이것은 마지막 두 가지 중 하나보다 훨씬 짧습니다.

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은 무시됩니다. 관련 메타
Jo King

내 대답 중 일부는 그 혜택을 누릴 수 있습니다.
JosiahRyanW

22

파이썬 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

자바 스크립트 (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)?'':...)하므로 몇 바이트가 더 추가됩니다.

예를 들어 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
이거 대박!
Emigna

1
선행 쉼표를 사용할 수 있다면 트릭을 사용 하여 41 바이트 .
Oliver

12

R , 19 바이트

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

온라인으로 사용해보십시오!


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

2
하-이것은 처음에 시도한 것이었지만 v=F분명히 나 자신에게 생각했기 때문에 지수가 아닌 가치를 원합니다 ... duh!
ngm

정규 표현식 자체를 뒤집는 것이 바이트보다 짧습니다 (이 경우).
ngm

작동하지 않지만 여전히 2 초가지나갑니다. ^[^2]*$짧지 않은 것이 필요합니다 .
J.Doe

4
이제 답을 확인해야합니까?
ngm


10

펄 6 , 22 바이트

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

온라인으로 사용해보십시오!

코드 블록을 수행하는 더 좋은 방법이 있지만 일치를 반전시키는 정규식 부사를 찾을 수 없습니다.


숫자 주위의 괄호를 제거하십시오. 그렇지 않으면 괜찮습니다.
Monolica

@Monolica 고정
Jo King

1
@Monolica 다른 답변이 그렇게 많은 목록으로 인쇄 할 수없는 것처럼 내 답변을 골라내는 것이 조금 이상합니다. 반면에, 그것은 어떤 바이트도 비용이 들지 않습니다.
Jo King

7

PowerShell , 22 16 바이트

1..100-notmatch2

온라인으로 사용해보십시오!

mazzy로 인해 -6 바이트

범위 1를 생성 한 100다음 -notmatch숫자 를 수행 하는 해당 객체를 가져옵니다 2. -notmatch이와 같은 배열에 대해를 실행하면 배열의 필터처럼 작동합니다. 각 항목은 파이프 라인에 남아 있으며 출력은 암시 적입니다.


? 1..100-notmatch2
mazzy

@mazzy 물론 그렇게 생각하지 않은 이유는 무엇입니까? 감사!
AdmBorkBork

6

하스켈 , 48 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]일을합니다.
Jonathan Frech

@JonathanFrech 와우, 그리워. : / 그 공간이 어디로 갔는지 전혀 모른다! 그것은 TIO에 있습니다 ...
Khuldraeseth na'Barya 1

2
하스켈이 notElem를 위해 not.elem, 그러나도 짧다 all(/='2').
xnor



5

자바 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.


. $.>`¶두 번째 단계 에서 작동 합니까 ?
ovs

@ovs 나는 이전에 더 복잡한 것을 가지고 있었고 L$새로운 줄 바꿈을 피하기 위해 전환 했으므로 다시 전환 할 수 있다는 것을 깨닫지 못했습니다. 감사합니다.
Neil


4

Wolfram Language (Mathematica) , 42 바이트

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

온라인으로 사용해보십시오!

산술 시퀀스 1, 19/9, 29/9, 39/9, ...는 천정을 취하면 2로 끝나는 모든 숫자를 건너 뛰는 올바른 속도로 자랍니다. 그런 다음 Drop값 을 핑하여 20에서 29를 제거 합니다. 인덱스 18에서 26까지.


나는 합의 Print가 필요한지 모르겠지만 어쨌든 누가 정말로 관심 이 있는지 .
Misha Lavrov 1

[...] 그러나 어쨌든 누가 정말 관심이 있습니다. -그 정신입니다 ...
Jonathan Frech

수행 \[LeftCeiling]하고 \[RightCeiling]정말 : 단일 바이트로 계산
user6014

@ user6014 유니 코드에서 차지하는 3 바이트로 계산하지만 실제 Ceiling명령 보다 약간 저렴 합니다.
Misha Lavrov

@MishaLavrov는 공정한 소리! 깔끔한 솔루션.
user6014


4

파워 쉘, 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의 답변 과 동일합니다 .
Ruslan

쓰레기, 내가 확인했지만 그 것을 보지 못했습니다. 나중에 내 게시물이 게시 된 이후에 삭제해야합니까?
therealfarfetch 님이

4

Z80Golf , 49 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

파이썬 3 , 53 51 50 49 46 바이트

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

온라인으로 사용해보십시오!

이 작업을위한 가장 강력한 언어는 아니지만 저는 골프를 처음 사용합니다.

그들의 의견에 대해 해설자에게 감사합니다!


PPCG에 오신 것을 환영합니다! 앞에있는 공백을 삭제하여 50을 반올림 할 수 있습니다 if.
ElPedro

[print(n)for n in range(1,101)if"2"not in str(n)]공장.
JosiahRyanW

또는 Python 2 답변 중 하나를 기반으로합니다.n=17;exec("print((n>177)*10+n//9);n+=10;"*81)
JosiahRyanW

@JosiahRyanW 나는 암묵적인 인쇄를 알지 못했습니다.
Gigaflop

1
'2'in str(n)or print(n)이해 가드보다 짧습니다.
Jonathan Frech

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 bytes time {if [string f 2 [incr i]]==-1 {puts $i}} 100아웃 고프 실패!
sergiol

테스트를 다음으로 대체 할 수 있습니다 regexp: ![regexp 2 [incr i]]for -3 bytes
david

@ david 정규식 사용에 대한 제안 솔루션이 어떻게 제공되지 않았습니까? 감사.
sergiol


3

배쉬 , 31 바이트

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

온라인으로 사용해보십시오!

짧은 루프를위한 Digital Trauma 덕분입니다.


1
Welcome to PPCG! How about echo $i instead of the printf? Or even better printf %d\\n {1..100}|grep -v 2?
Digital Trauma

yeah right. i ll update my answer.
ketone

i am learning actually i don't know that much btw thanks.
ketone

그냥 내 친다echo {1..100}|tr ' ' \\n|grep -v 2
Mark Perryman

당신이 사용하는 경우 -1 바이트 sed /2/d대신 grep -v 2.
Ruslan

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의 OOL을. 출력은 공백으로 구분 된 숫자 목록입니다.

이것은 (의사로) 다음 의사 코드로 변환됩니다.

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 함수 (내장 수학자 및 스크라이브 클래스를 통해)를 포함하여 객체를 사용하여 모든 작업을 수행합니다. 전체 기능 만 반복 할 수 있으므로 작업을 수행하는 데 두 가지 기능이있는 객체의 필요성이 설명됩니다.


3

MathGolf, 7 6 bytes

♀╒Ç{2╧

Try it online!

Explanation

♀╒       Push 100 and convert to 1-based range ([1,2,...,100])
  Č{     Inverse filter by block
    2╧   Does the number contain 2?


3

PHP 7.1, 40 bytes

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

prints numbers separated by underscores. Run with -nr or try it online.


Nice use of PHP's wacky behavior to separate the numbers, lol
Roberto Maldonado

1
The preg_filter() based one is interesting. (I never used that function. 🤫) That one would be shorter with preg_grep(): <?=join(_,preg_grep("/2/",range(1,100),1));.
manatwork


2

brainfuck, 176 bytes

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

Try it online!

Shorter is definitely possible. This generates the numbers 1,3,4,5,6,7,8,9 and 0,1,3,4,5,6,7,8,9. First it outputs each number in the first list, then it outputs every combination of the first and second list, then finally prints just 100.

Explanation:

---------   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 bytes

This was a fun challenge! And it is a challenge where my language can do well.

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

Cycles through all values from 1 to 100, outputting the ones that don't have 2, separated by a newline.

You can try it on http://sandbox.onlinephpfunctions.com/code/2c97a2b6954c29844f1079938da771d51e2e0d99

Ungolfed:

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

The {@/} is used to close the {@for ...} and {@if ...}, but is optional.
When compiling to PHP, it adds the needed closing.


If you're curious, the golfed code results in this PHP code:

// {@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
};};

Where $FN['array_flat'] is defined outside of this code.

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.