DEV Community

Discussion on: A coding interview question asked at Google

erickhagstrom profile image
Erick Hagstrom • Edited on

I'm learning clojure, which isn't supported by Coderbyte :-(

Here's my clojure solution:

(ns challenge20191202.core
  (:require [clojure.string :as str]))

(defn check-equivalent-keypresses [v]
  (defn parse-string [s]
    (vec (str/split s #",")))

  (defn apply-keypresses [v s]
    (if (= s "-B")
      (vec (drop-last v))
      (conj v s)))

  (let [[s1 s2] v
        v1 (str/split s1 #",")
        v2 (str/split s2 #",")]
    (= (reduce apply-keypresses '[] v1)
       (reduce apply-keypresses '[] v2))))
elisabethgross profile image
elisabethgross Author • Edited on

One of the benefits of having a close relationship with our community is hearing what you all want and building it! Like this comment if you'd be interested in Coderbyte supporting clojure!