On Wednesday, March 23, 2016 at 12:35:26 PM UTC-4, rom cgb wrote:
> Thanks all for the interesting replies. 
> 
> About using an external package, there also the case like on 
> www.hackerrank.com where you have to run the code in their own environment 
> (eg: http://i.imgur.com/iSSPLGy.png).

I use racket for hackerrank and coding contests all the time, and I find it's 
read syntax really useful. For instance, I would parse this into a list of 
lists by doing 
(for/list ([i (in-range (read))])
  (map (lambda (x) (if (list? x) (cadr x) x)) (read))).

Then, to print out results, I normally do 
(define (main n)
  (unless (= 0 n)
    (begin (printf "~a ... ~a\n", args...)
      (main (sub1 n)))).

Another really useful helper is 
(define (read->list n)
  (if (= 0 n) '()
    (cons (read) (read->list (sub1 n)))). 

You can customize these by doing for/vector, for/fold, etc., and there hasn't 
been a hackerrank contest I've run into that I haven't been able to do with 
some technique like this. 

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to