> On Jun 16, 2019, at 3:38 AM, Neil Van Dyke <n...@neilvandyke.org> wrote:
> 
> Anyone have thoughts on whether there's anything Racket can/should do 
> involving Leetcode?
> 
> If you're not familiar, Leetcode is a site with bunch of coding interview 
> problems that huge numbers of CS students and professionals work through.  
> For doing the problems on the site, there's several popular programming 
> languages to choose from (Racket and Scheme not among them).  
> https://leetcode.com/problemset/all/
> 
> I just did three of the most popular problems tonight, in Racket/Scheme, 
> offline.  (Incidentally, in the official solutions writeups of all three, I 
> ended up finding what appears to be one outright incorrect algorithm, and had 
> nits to pick in each, over the discussion and sometimes needlessly 
> inefficient coding.  And they strangely provide little-to-no test cases in 
> the official solution writeups I've seen so far, when I'd say that figuring 
> out good test cases should be a fundamental part of every solution process.)


Undergraduates from NEU routinely report that when they follow the 
design-recipe teaching (purpose, examples, tests, templating), the interviewers 
soon move them to the next stage of the process. Or shorter, I can’t count the 
students anymore who see me and say something like “the design recipe saved my 
a.. during the interview.” (And then there are those students who know better 
:) 

Of course, good companies know by now that these “puzzle” questions are bad at 
identifying good (as in above-average) sw devs. Only the average companies 
still use this method because they are way behind. You want people who think 
systematically and leav code behind that others comprehend down the line. 

And fwiw, we have anecdotes where places such as Amazon accepted students who 
coded their solutions in BSL or ISL+. 


> One thing I found with my code[1] is that it's probably not good for 
> *selling* people on Racket. f you don't know a Lisp, and you look at this 
> Racket/Scheme code as well as the Java or C++ official solution, I suspect 
> this code looks bulkier and less familiar. 


I looked at the solutions for the first problem (’sum’). I think idiomatic 
full-fledged Racket will look fine. I use d-s-r because I hate repeated 
patterns. 

;; determine indicies i, j for Vec such that (Vec i) + (Vec j) = T 
(define (find Vec T)
  (define-syntax-rule (N) (in-range (length Vec)))
  (define-syntax-rule (in k) (in-value (list-ref Vec k)))
  (for*/first ((i (N)) (j (N)) (n (in i)) (m (in j)) #:when (= (+ n m) T)) 
(list i j)))

(equal? (find '[2 7 11 15] 9) (list 0 1))

It includes a “test”. But yes, I can see how plan R5 would look very bulky 
here, except if you can figure out ‘do’. (This has been a iong running argument 
with a local colleague here who loves R5.) 


;; - - - 

You forgot [2]. 

— Matthias




> IThough, for example, one of their solutions, if you tried to really 
> understand an optimization they were doing, their coding style actually 
> obscured that, and the Scheme code could've done that same approach in a way 
> that was easier to step through exactly what's going on.[2]
> 
> Also, I suspect that going to a lot of trouble to publish better solutions, 
> and crits of the official ones, won't impress many. Although I saw one of the 
> official solutions go into excessively detailed big-O analysis, and I suspect 
> most everyone doing Leecode has Intro Algorithms as an accomplishment they 
> can rightly be proud of, I suspect that the majority of people just want to 
> survive the all-important whiteboard hazings, and the self-image/aspiration 
> after that is more "I get it done".  I suspect that Racket will already be 
> assumed to be for academics, so academic-ing Leetcode problems harder won't 
> change that, and these contrived whiteboard problems I've seen so far don't 
> really lend themselves to Racket's relative practical strengths.
> 
> I suppose one possibility might be to get Racket or Scheme considered an 
> official language for Leetcode.  Simply having it appear on the menu on 
> leetcode.com is a boost of credibility.  I doubt many employers will want to 
> see Racket/Scheme in any case right now (and schools I've seen seem to be 
> targeting a popular language, for internships and whiteboard interviews), but 
> students and professionals will see it.  Maybe: not being on that list says 
> we're definitely not relevant; being on the list says we might be. Plus a few 
> "what's this new Racket/Scheme thing?" leads.
> 
> Other ideas for involving Racket and Leetcode?
> 
> 
> [1] Style-wise, for this exercise, I did pure-functional (which was easy and 
> efficient for all of the 3 problems thus far), and in only R5RS plus Racket 
> hashes and my unit testing library, and favoring named-`let`.  FWIW, for the 
> constant factor details, I also assumed a modestly good compiler, I 
> micro-optimized a bit more than I had to (e.g., avoiding redundant branching 
> in imagined target code), and I didn't assume allocations/GC were free.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/7c80122b-6157-f75e-3994-d5e5d0503f90%40neilvandyke.org.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/9093F4CE-B5A7-4EF3-8235-C1FD44211EA5%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to