tangled
alpha
login
or
join now
eldridge.cam
/
advent-of-code
2
fork
atom
Advent of Code solutions
2
fork
atom
overview
issues
pulls
pipelines
continuing all.rb with more language support
eldridge.cam
2 months ago
b6f2a3fc
dfd5d9a9
+104
-9
3 changed files
expand all
collapse all
unified
split
2024
16
solution.cabal
18
solution.cabal
all.rb
+1
-1
2024/16/day16.cabal
2024/16/solution.cabal
···
1
1
cabal-version: 3.0
2
2
-
name: day16
2
2
+
name: solution
3
3
version: 1.0.0
4
4
-- synopsis:
5
5
-- description:
+1
-1
2024/18/day18.cabal
2024/18/solution.cabal
···
1
1
cabal-version: 3.0
2
2
-
name: day18
2
2
+
name: solution
3
3
version: 1.0.0
4
4
-- synopsis:
5
5
-- description:
+102
-7
all.rb
···
58
58
end
59
59
60
60
def self.implemented? part
61
61
-
File.exist? "p#{part}.hs"
61
61
+
File.exist? "p#{part}.hs" or File.exist? "solution.cabal"
62
62
end
63
63
64
64
def self.run part
65
65
-
`ghc p#{part}.hs 2> /dev/null`
66
66
-
return :ghc_error unless $?.success?
67
67
-
report "p#{part}.hs" do
68
68
-
`timeout 1m ./p#{part} < input`
65
65
+
if File.exist? "solution.cabal"
66
66
+
`cabal build p#{part}`
67
67
+
return :cabal_error unless $?.success?
68
68
+
report "solution.cabal (p#{part})" do
69
69
+
`timeout 1m cabal run p#{part} < input`
70
70
+
end
71
71
+
else
72
72
+
`ghc p#{part}.hs 2> /dev/null`
73
73
+
return :ghc_error unless $?.success?
74
74
+
report "p#{part}.hs" do
75
75
+
`timeout 1m ./p#{part} < input`
76
76
+
end
69
77
end
70
78
end
71
79
end
···
161
169
return "python" if which "python"
162
170
return nil
163
171
end
164
164
-
172
172
+
165
173
def self.available?
166
174
self.python != nil
167
175
end
···
209
217
end
210
218
end
211
219
212
212
-
languages = [Haskell, Rust, Trilogy, C, Cpp, Swift, Python, Ruby, TypeScript]
220
220
+
module Erlang
221
221
+
def self.available?
222
222
+
which "erl" != nil
223
223
+
end
224
224
+
225
225
+
def self.implemented? part
226
226
+
File.exist? "p#{part}.erl"
227
227
+
end
228
228
+
229
229
+
def self.run part
230
230
+
`erl -compile p#{part}.erl`
231
231
+
return :erl_error unless $?.success?
232
232
+
report "p#{part}.erl" do
233
233
+
`timeout 1m erl -noshell -s p#{part} main -s init stop < input`
234
234
+
end
235
235
+
end
236
236
+
end
237
237
+
238
238
+
module Elixir
239
239
+
def self.available?
240
240
+
which "elixir" != nil
241
241
+
end
242
242
+
243
243
+
def self.implemented? part
244
244
+
File.exist? "p#{part}.ex"
245
245
+
end
246
246
+
247
247
+
def self.run part
248
248
+
report "p#{part}.ex" do
249
249
+
`timeout 1m elixir p#{part}.ex < input`
250
250
+
end
251
251
+
end
252
252
+
end
253
253
+
254
254
+
module Gleam
255
255
+
def self.available?
256
256
+
which "gleam" != nil
257
257
+
end
258
258
+
259
259
+
def self.implemented? part
260
260
+
File.exist? "p#{part}/gleam.toml"
261
261
+
end
262
262
+
263
263
+
def self.run part
264
264
+
pwd = Dir.pwd
265
265
+
Dir.chdir "p#{part}"
266
266
+
`gleam build --no-print-progress`
267
267
+
return :gleam_error unless $?.success?
268
268
+
report "p#{part}.gleam" do
269
269
+
`timeout 1m gleam run --no-print-progress < ../input`
270
270
+
end
271
271
+
Dir.chdir pwd
272
272
+
end
273
273
+
end
274
274
+
275
275
+
module Prolog
276
276
+
def self.available?
277
277
+
which "swipl" != nil
278
278
+
end
279
279
+
280
280
+
def self.implemented? part
281
281
+
File.exist? "p#{part}.pl"
282
282
+
end
283
283
+
284
284
+
def self.run part
285
285
+
report "p#{part}.pl" do
286
286
+
`timeout 1m swipl -s p#{part}.pl -g main,halt < input`
287
287
+
end
288
288
+
end
289
289
+
end
290
290
+
291
291
+
module Php
292
292
+
def self.available?
293
293
+
which "php" != nil
294
294
+
end
295
295
+
296
296
+
def self.implemented? part
297
297
+
File.exist? "p#{part}.php"
298
298
+
end
299
299
+
300
300
+
def self.run part
301
301
+
report "p#{part}.php" do
302
302
+
`timeout 1m php p#{part}.php < input`
303
303
+
end
304
304
+
end
305
305
+
end
306
306
+
307
307
+
languages = [Haskell, Rust, Trilogy, C, Cpp, Swift, Python, Ruby, TypeScript, Erlang, Elixir, Gleam, Prolog, Php]
213
308
.filter { |lang| lang.available? }
214
309
215
310
root = Dir.pwd