An error occurred
An error occurred while running your tests. This might mean that there was an issue in our infrastructure, or it might mean that you have something in your code that's causing our systems to break.
Please check your code, and if nothing seems to be wrong, try running the tests again.
I feel confused because the behavior of these functions is as I expected. Here is my code:
(defpackage :all-your-base
(:use :cl)
(:export :rebase))
(in-package :all-your-base)
(defun rebase (list-digits in-base out-base)
(let ((decimal (to-decimal list-digits in-base)))
(decimal-to-base decimal out-base nil)))
;; convert a list from in-base to decimal base
(defun to-decimal (list-digits in-base)
(reduce
(lambda (acc x) (+ (* acc in-base) x))
list-digits
:initial-value 0))
;; convert a decimal number to an out-base list
(defun decimal-to-base (decimal out-base acc)
(if (<= decimal (1- out-base))
(cons decimal acc)
(let* ((quotient (floor decimal out-base))
(remainder (mod decimal out-base)))
(decimal-to-base quotient out-base (cons remainder acc)))))
Have you tested your code against the test suite locally? See the documentation at Testing on the Common Lisp track | Exercism's Docs. Do you get any error messages running the tests locally? If so, what do they say?