Welcome! Please see the About page for a little more info on how this works.

0 votes
in Portal by

I have submitted a solution to the bird watcher problem, and the test suit complains that it doesn't find the function day-without-birds. Visual Studio Code is able to import it and run it from another file.

The full implementation of the solution is as follows:

Solution

(ns bird-watcher)

 (def last-week [0 2 5 3 7 8 4])

 (defn last_position [v]
   (- (clojure.core/count v) 1))

 (defn today [birds]
   (get birds (last_position birds)))

(defn inc-bird [birds]
  (assoc birds (last_position birds)  (+ (today birds) 1)))

(defn day-without-birds
  [birds]
  (loop [y birds]
    (let [[x & rest] y]
      (if (= x 0)
        true
        (if (empty? rest)
          false
          (recur rest))))))
 
 

(defn n-days-count [birds n]
  (reduce + (take n birds)))

(defn busy [day]
  (if (> day 5)
    1
    0))

(defn busy-days [birds]
  (reduce + (map busy birds)))

(defn odd-week-internal
  [birds x]
  (loop [y birds
         target x]
    (let [[x & rest] y
          target (- 1 target)]
      (if (= x target)
        (if (empty? rest)
          true
          (recur rest target))
        false))))

(defn odd-week [birds]
  (odd-week-internal birds 0))

Thank you in advance!

by
This question relies on some info that's not stated. "Submitted" - where exactly? Also note that you have asked this in the `Portal` section, but I don't see how Portal is relevant to the question.

Please log in or register to answer this question.

...