Skip to content

Instantly share code, notes, and snippets.

@boxp
Created October 9, 2013 16:17
Show Gist options
  • Save boxp/6903876 to your computer and use it in GitHub Desktop.
Save boxp/6903876 to your computer and use it in GitHub Desktop.
(ns atcoder.core
(:use [clojure.string :only (join split split-lines)])
(:require [goog.events :as events]
[goog.dom :as dom]))
; don't fix me
(defn gen-args
[input]
(split-lines input))
(defn gen-temps
[args]
(map #(split % " ") args))
; start code section
(defn main [args]
(let [cnt (js/parseInt (first args))
as (gen-temps (rest args))]
(.log js/console
(apply str
(join " "
(loop [result [0 0 0 0 0 0] temps as i 0]
(if (= cnt i)
result
(let [temp (first temps)
M (temp 0)
m (temp 1)]
(recur [(if (>= M 35.0) (inc (result 0)) (result 0))
(if (and (>= M 30.0) (< M 35.0)) (inc (result 1)) (result 1))
(if (and (>= M 25.0) (< M 30.0)) (inc (result 2)) (result 2))
(if (>= m 25.0) (inc (result 3)) (result 3))
(if (and (>= M 0) (< m 0)) (inc (result 4)) (result 4))
(if (< M 0) (inc (result 5)) (result 5))]
(rest temps)
(inc i))))))))))
; don't fix me
(defn ^:export debug
[]
(main
(gen-args
(.. js/document
(getElementById "input")
-value))))
; don't fix me
(set! *main-cli-fn*
(main
(gen-args
(.. (js/require "fs")
(readFileSync "/dev/stdin" "utf8")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment