-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproblem42.j
executable file
·161 lines (114 loc) · 2.26 KB
/
problem42.j
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
.class public problem42
.super java/lang/Object
.method public <init>()V
aload_0
invokespecial java/lang/Object/<init>()V
return
.end method
.method public static isTriangular(I)Z
.limit stack 4
.limit locals 1
ldc 1
loop:
dup
dup
ldc 1
iadd
imul
ldc 2
idiv
dup
iload 0
if_icmpne next1
pop2
ldc 1
ireturn
next1:
iload 0
if_icmple next2
pop
ldc 0
ireturn
next2:
ldc 1
iadd
goto loop
.end method
.method public static main([Ljava/lang/String;)V
.limit stack 4
.limit locals 6 ; args, arr, counter, i, curr, currx
new java/io/File
dup
ldc "./files/p042_words.txt"
invokespecial java/io/File/<init>(Ljava/lang/String;)V
new java/io/FileReader
swap
dup2
invokespecial java/io/FileReader/<init>(Ljava/io/File;)V
pop
new java/io/BufferedReader
swap
dup2
invokespecial java/io/BufferedReader/<init>(Ljava/io/Reader;)V
pop
dup
invokevirtual java/io/BufferedReader/readLine()Ljava/lang/String;
ldc "\""
ldc ""
invokevirtual java/lang/String/replaceAll(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
ldc ","
invokevirtual java/lang/String/split(Ljava/lang/String;)[Ljava/lang/String;
astore 1
invokevirtual java/io/BufferedReader/close()V
ldc 0
dup
istore 2
istore 3
xouter:
aload_1
iload 3
aaload
astore 4
ldc 0
istore 5
ldc 0
xinner:
dup
aload 4
swap
invokevirtual java/lang/String/charAt(I)C
ldc 65
isub
ldc 1
iadd
iload 5
iadd
istore 5
ldc 1
iadd
dup
aload 4
invokevirtual java/lang/String/length()I
if_icmplt xinner
pop
iload 5
invokestatic problem42/isTriangular(I)Z
ifeq skip
iload 2
ldc 1
iadd
istore 2
skip:
iload 3
ldc 1
iadd
dup
istore 3
aload_1
arraylength
if_icmplt xouter
getstatic java/lang/System/out Ljava/io/PrintStream;
iload 2
invokevirtual java/io/PrintStream/println(I)V
return
.end method