DEV Community

loading...

Discussion on: A coding interview question asked at Google

Collapse
erickhagstrom profile image
Erick Hagstrom

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

Here's my clojure solution:

(ns challenge20191202.core
  (:gen-class)
  (: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))))
Collapse
elisabethgross profile image
elisabethgross Author

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!