Skip to content

Commit

Permalink
Add unfinished solution
Browse files Browse the repository at this point in the history
  • Loading branch information
deniscostadsc committed Sep 28, 2024
1 parent d5dd59a commit b71b7d1
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions solutions/beecrowd/1022/1022.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
(ns main
(:require [clojure.string :as str]))

(defn debug [x]
(println x)
x)
(defn gimme-type [x]
(println (type x))
x)

(defn gcd [a b]
(println (type a) " - " (type b))
(loop [a' a
b' b]
(println (type a') " - " (type b'))
(if (= 0 b')
a'
(recur 'b (mod a' b')))))

(defn process-input [line]
(let [[a' _ b' o c' _ d'] (str/split line #" ")
[a b c d] (map #(Integer/parseInt %) [a' b' c' d'])]
(cond
(= o "+")
(-> (* b d)
(* a)
(/ b)
(+ (* b d))
(* c)
(/ d)
(gcd (* b d)))
(= o "-")
(-> (* b d)
(* a)
(/ b)
(- (* b d))
(* c)
(/ d)
(gcd (* b d)))
(= o "*")
(-> a
(* c)
(gcd (* b d)))
:else
(-> a
(debug)
(gimme-type)
(* d)
(debug)
(gimme-type)
(gcd (* b c))))))

(defn main []
(let [c (-> (read-line)
(Integer/parseInt))]
(loop [c' c]
(process-input (read-line))
(when c'
(recur (- c' 1))))))

(main)
Empty file added solutions/beecrowd/1022/WRONG
Empty file.

0 comments on commit b71b7d1

Please sign in to comment.