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