3 ms·
PS Using chatgpt.com ChatGPT 3.5, input was: Translate this to Common Lisp. def solve(graph): a = 0 while a < len(graph): for b in range(len
by chrisjj 3y ago
PS Using chatgpt.com ChatGPT 3.5, input was:
Translate this to Common Lisp.
def solve(graph):
a = 0
while a < len(graph):
for b in range(len(graph)):
if b > a and graph[a].intersection(graph[b]):
graph[b] = graph[a] | graph[b]
graph.pop(a);a-=1
break
a+=1
return graph
a = [{1, 2}, {4, 5}, {1, 3}, {1, 4}]
print((solve( a )))
Output today is:
(defun solve (graph)
(let ((a 0))
(loop while (< a (length graph))
do (loop for b below (length graph)
do (when (and (> b a)
(intersection (elt graph a) (elt graph b)))
(setf (elt graph b) (union (elt graph a) (elt graph b)))
(setf graph (remove (elt graph a) graph))
(decf a)
(return)))
(incf a))
graph))
(defparameter *a* '((1 2) (4 5) (1 3) (1 4)))
(format t "~a" (solve *a*)))
and though this differs from the original attempt's output, it fails to compile the same way - "unmatched close parenthesis" on graph)).
Using Bing.com GPT-4 the output again differs, but again fails the same.