Fork me on GitHub
#code-reviews
<
2021-05-10
>
raspasov07:05:24

(defn cloud
 [input]
 (let [jump-small 1 jump-big 2]
  (trampoline
   (fn jump [idx cnt]
    (let [idx' (+ idx jump-big)]
     (if-let [?zero-or-one (get input idx')]
      #(if (zero? ?zero-or-one)                             ;big or small jump?
        (jump idx' (inc cnt))                               ;big!
        (let [idx'' (+ idx jump-small)]                     ;else, small
         (jump idx'' (inc cnt))))
      cnt)))                                                ;else, we are done, return jump count
   0 0)))

raspasov07:05:25

@ps there’s too much collection op stuff going on in your solution for what’s ultimately an index increment problem.

raspasov07:05:39

Rant: doing this kind of stuff reminds me how goofy those kind of problems are; They rarely look like what you deal with on a daily basis. P.S. I feel like there’s a higher level solution that’s shorter for the ‘cloud’ problem but I can’t think of it atm.

zendevil.eth07:05:19

Raspasov, I scorned at Hackerrank until I failed two job interviews that did their technical interview through Hackerrank.

raspasov08:05:54

Understood.

seancorfield16:05:49

I wouldn’t work for a company that used one of these “code golf” puzzle challenge sites as a gate for hiring — they’re a terrible way to figure out whether a candidate is good to hire! 🤯

💯 3
raspasov00:05:05

I went through one of these hackerrank puzzles last night and even submitted one solution in Clojure for fun that’s pretty idiomatic. It gave me a score of 10/60 because most tests with huge numbers (in the hundreds of millions of n!) would time out. Then I looked at other people’s solutions that have 60/60 scores and they all consist of low level perf optimizations around loop/recur, unchecked math, type hints, etc. It seems like the site turns into “most clever perf optimization competition”. Since there are so many ways to write a solution to a problem, the only easy way for them to automatically “give a grade” to a solution is based on performance. I totally have done the perf tricks showed there when needed but they are not required in 98% of the code that I usually write.

seancorfield01:05:23

@U050KSS8M Yeah, that sort of thing is why I consider these sites completely inappropriate for hiring purposes.

👍 3
zendevil.eth16:05:16

@U050KSS8M would you please share the optimized code, the non-optimized code and the challenge?

zendevil.eth16:05:05

@U050KSS8M what kind of work do you do? Freelancer or for a company? @U04V70XH6 is your company hiring?

zendevil.eth16:05:36

@U04V70XH6 can you help me get a job in your company or another company?

seancorfield16:05:02

We are not hiring, sorry. The best thing to do is keep an eye on #jobs and #remote-jobs here and see if folks are hiring into positions where they are open to taking on “non-Clojure” developers and training them. But bear in mind the competition is likely to be stiff because a lot of people want to program in Clojure for a living — far more than there are open positions.

seancorfield16:05:12

(one of the benefits of Clojure for companies is also somewhat of a downside for candidates: you can get a lot done with very few engineers — and Clojure developers tend to be happier than non-Clojure developers so they tend to stay in roles, which means there’s less hiring going on)

raspasov17:05:40

@U04V70XH6 I’ve heard conflicting evidence about that actually. I’ve heard all three: “companies: hard to find Clojure developers” “companies: easy to find Clojure developers” “developers: hard to find Clojure jobs”

raspasov17:05:25

@ps sorry, I don’t have any leads at the moment. I am building a React Native app at the moment in Clojure(Script).

zendevil.eth17:05:46

@U050KSS8M I launched one on App Store: https://apps.apple.com/us/app/humboi/id1561534546 in a 1.001 person start-up.

seancorfield17:05:56

@U050KSS8M I’d modify those first two a bit: “companies: hard to find intermediate/senior Clojure developers” (because Clojure devs tend to stay in jobs) and “companies: easy to find folks who want to be Clojure developers” — we should probably take this part of the discussion to #jobs-discuss if we want to drill down further.

👍 4
raspasov08:05:27

For #4, I would expect something like:

(defn repeated-string [s n]
 (transduce
  (comp
   (mapcat identity)
   (take n)
   (filter #(= % \a))
   (map (constantly 1)))
  +
  0
  (repeat s)))