This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(map inc [1 2 3 4]) | |
;; [2 3 4 5] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(reduce | |
#(+ %1 %2) | |
[1 2 3 4]) | |
;; 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(reduce | |
#(conj %1 (inc %2)) | |
[] | |
[1 2 3 4]) | |
;; [2 3 4 5] | |
(map | |
inc | |
[1 2 3 4]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(filter odd? [1 2 3 4]) | |
;; [1 3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(reduce | |
#(if (odd? %2) | |
(conj %1 %2) | |
%1) | |
[] | |
[1 2 3 4]) | |
;; [1 3] | |
(filter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Func<int, string> toRoman = (number) => | |
new Dictionary<int, string> | |
{ | |
{1000, "M"}, | |
{ 900, "CM"}, | |
{ 500, "D"}, | |
{ 400, "CD"}, | |
{ 100, "C"}, | |
{ 90, "XC"}, | |
{ 50, "L"}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns Player | |
(:gen-class)) | |
(defn -main [& args] | |
(while true | |
(let [enemies (doall (repeatedly 2 #(array-map :name (read) :distance (read))))] | |
(println (->> enemies | |
(sort-by :distance <) | |
first |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns Player | |
(:gen-class)) | |
(defn -main [& args] | |
; strongly based on https://github.com/vhennebert/CodinGame/blob/master/2014-02-22_Ragnarok/1_power-of-thor.clj | |
(let [[lx ly tx ty] (repeatedly 4 read) | |
x-difference (- lx tx) | |
x-length (Math/abs x-difference) | |
x (cond |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns Player | |
(:gen-class)) | |
(defn -main [& args] | |
(while true | |
(let [x (read) | |
h (read) | |
mountains (repeatedly 8 read) | |
tallest (apply max mountains) | |
tallest-index (.indexOf mountains tallest) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns Player | |
(:gen-class)) | |
(defn -main [& args] | |
(let [road-length (read) | |
gap-length (read) | |
landing-length (read) | |
gap-jump-length (inc gap-length)] | |
(while true |