From 80407491504ab6349654dc5aa3906bd95ff9104c Mon Sep 17 00:00:00 2001 From: Vaclav Synacek Date: Tue, 15 Apr 2025 21:02:08 +0200 Subject: [PATCH] fix 5 problems' ids from $numberLong to plain integer --- public/data/problems.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/data/problems.json b/public/data/problems.json index a0420b5..174fb5d 100644 --- a/public/data/problems.json +++ b/public/data/problems.json @@ -148,9 +148,9 @@ { "_id" : 164, "description" : "A deterministic finite automaton (DFA) is an abstract machine that recognizes a regular language. Usually a DFA is defined by a 5-tuple, but instead we'll use a map with 5 keys:\r\n\r\n\r\n\r\nWrite a function that takes as input a DFA definition (as described above) and returns a sequence enumerating all strings in the language recognized by the DFA.\r\n\r\nNote: Although the DFA itself is finite and only recognizes finite-length strings it can still recognize an infinite set of finite-length strings. And because stack space is finite, make sure you don't get stuck in an infinite loop that's not producing results every so often!", "difficulty" : "Hard", "restricted" : null, "tags" : [ "automata", "seqs" ], "tests" : [ "(= #{\"a\" \"ab\" \"abc\"}\r\n (set (__ '{:states #{q0 q1 q2 q3}\r\n :alphabet #{a b c}\r\n :start q0\r\n :accepts #{q1 q2 q3}\r\n :transitions {q0 {a q1}\r\n q1 {b q2}\r\n q2 {c q3}}})))", "\r\n(= #{\"hi\" \"hey\" \"hello\"}\r\n (set (__ '{:states #{q0 q1 q2 q3 q4 q5 q6 q7}\r\n :alphabet #{e h i l o y}\r\n :start q0\r\n :accepts #{q2 q4 q7}\r\n :transitions {q0 {h q1}\r\n q1 {i q2, e q3}\r\n q3 {l q5, y q4}\r\n q5 {l q6}\r\n q6 {o q7}}})))", "(= (set (let [ss \"vwxyz\"] (for [i ss, j ss, k ss, l ss] (str i j k l))))\r\n (set (__ '{:states #{q0 q1 q2 q3 q4}\r\n :alphabet #{v w x y z}\r\n :start q0\r\n :accepts #{q4}\r\n :transitions {q0 {v q1, w q1, x q1, y q1, z q1}\r\n q1 {v q2, w q2, x q2, y q2, z q2}\r\n q2 {v q3, w q3, x q3, y q3, z q3}\r\n q3 {v q4, w q4, x q4, y q4, z q4}}})))", "(let [res (take 2000 (__ '{:states #{q0 q1}\r\n :alphabet #{0 1}\r\n :start q0\r\n :accepts #{q0}\r\n :transitions {q0 {0 q0, 1 q1}\r\n q1 {0 q1, 1 q0}}}))]\r\n (and (every? (partial re-matches #\"0*(?:10*10*)*\") res)\r\n (= res (distinct res))))", "(let [res (take 2000 (__ '{:states #{q0 q1}\r\n :alphabet #{n m}\r\n :start q0\r\n :accepts #{q1}\r\n :transitions {q0 {n q0, m q1}}}))]\r\n (and (every? (partial re-matches #\"n*m\") res)\r\n (= res (distinct res))))", "(let [res (take 2000 (__ '{:states #{q0 q1 q2 q3 q4 q5 q6 q7 q8 q9}\r\n :alphabet #{i l o m p t}\r\n :start q0\r\n :accepts #{q5 q8}\r\n :transitions {q0 {l q1}\r\n q1 {i q2, o q6}\r\n q2 {m q3}\r\n q3 {i q4}\r\n q4 {t q5}\r\n q6 {o q7}\r\n q7 {p q8}\r\n q8 {l q9}\r\n q9 {o q6}}}))]\r\n (and (every? (partial re-matches #\"limit|(?:loop)+\") res)\r\n (= res (distinct res))))\r\n" ], "title" : "Language of a DFA", "user" : "daowen" }, { "_id" : 166, "description" : "For any orderable data type it's possible to derive all of the basic comparison operations (<, ≤, =, ≠, ≥, and >) from a single operation (any operator but = or ≠ will work). Write a function that takes three arguments, a less than operator for the data and two items to compare. The function should return a keyword describing the relationship between the two items. The keywords for the relationship between x and y are as follows:\r\n\r\n", "difficulty" : "Easy", "restricted" : null, "tags" : null, "tests" : [ "(= :gt (__ < 5 1))", "(= :eq (__ (fn [x y] (< (count x) (count y))) \"pear\" \"plum\"))", "(= :lt (__ (fn [x y] (< (mod x 5) (mod y 5))) 21 3))", "(= :gt (__ > 0 2))\r\n" ], "title" : "Comparisons", "user" : "daowen" }, { "_id" : 168, "description" : "

\r\nIn what follows, m, n, s, t \r\ndenote nonnegative integers, f denotes a function that accepts two \r\narguments and is defined for all nonnegative integers in both arguments.\r\n

\r\n\r\n

\r\nIn mathematics, the function f can be interpreted as an infinite \r\nmatrix\r\nwith infinitely many rows and columns that, when written, looks like an ordinary \r\nmatrix but its rows and columns cannot be written down completely, so are terminated \r\nwith ellipses. In Clojure, such infinite matrix can be represented \r\nas an infinite lazy sequence of infinite lazy sequences, \r\nwhere the inner sequences represent rows.\r\n

\r\n\r\n

\r\nWrite a function that accepts 1, 3 and 5 arguments\r\n

\r\n

", "difficulty" : "Medium", "restricted" : [ "for", "range", "iterate", "repeat", "cycle", "drop" ], "tags" : [ "seqs", "recursion", "math" ], "tests" : [ "(= (take 5 (map #(take 6 %) (__ str)))\r\n [[\"00\" \"01\" \"02\" \"03\" \"04\" \"05\"]\r\n [\"10\" \"11\" \"12\" \"13\" \"14\" \"15\"]\r\n [\"20\" \"21\" \"22\" \"23\" \"24\" \"25\"]\r\n [\"30\" \"31\" \"32\" \"33\" \"34\" \"35\"]\r\n [\"40\" \"41\" \"42\" \"43\" \"44\" \"45\"]])", "(= (take 6 (map #(take 5 %) (__ str 3 2)))\r\n [[\"32\" \"33\" \"34\" \"35\" \"36\"]\r\n [\"42\" \"43\" \"44\" \"45\" \"46\"]\r\n [\"52\" \"53\" \"54\" \"55\" \"56\"]\r\n [\"62\" \"63\" \"64\" \"65\" \"66\"]\r\n [\"72\" \"73\" \"74\" \"75\" \"76\"]\r\n [\"82\" \"83\" \"84\" \"85\" \"86\"]])", "(= (__ * 3 5 5 7)\r\n [[15 18 21 24 27 30 33]\r\n [20 24 28 32 36 40 44]\r\n [25 30 35 40 45 50 55]\r\n [30 36 42 48 54 60 66]\r\n [35 42 49 56 63 70 77]])", "(= (__ #(/ % (inc %2)) 1 0 6 4)\r\n [[1/1 1/2 1/3 1/4]\r\n [2/1 2/2 2/3 1/2]\r\n [3/1 3/2 3/3 3/4]\r\n [4/1 4/2 4/3 4/4]\r\n [5/1 5/2 5/3 5/4]\r\n [6/1 6/2 6/3 6/4]])", "(= (class (__ (juxt bit-or bit-xor)))\r\n (class (__ (juxt quot mod) 13 21))\r\n (class (lazy-seq)))", "(= (class (nth (__ (constantly 10946)) 34))\r\n (class (nth (__ (constantly 0) 5 8) 55))\r\n (class (lazy-seq)))", "(= (let [m 377 n 610 w 987\r\n check (fn [f s] (every? true? (map-indexed f s)))\r\n row (take w (nth (__ vector) m))\r\n column (take w (map first (__ vector m n)))\r\n diagonal (map-indexed #(nth %2 %) (__ vector m n w w))]\r\n (and (check #(= %2 [m %]) row)\r\n (check #(= %2 [(+ m %) n]) column)\r\n (check #(= %2 [(+ m %) (+ n %)]) diagonal)))\r\n true)" ], "title" : "Infinite Matrix", "user" : "maximental" }, -{ "_id" : { "$numberLong" : "171" }, "description" : "Write a function that takes a sequence of integers and returns a sequence of \"intervals\". Each interval is a a vector of two integers, start and end, such that all integers between start and end (inclusive) are contained in the input sequence.", "difficulty" : "Medium", "restricted" : null, "tags" : null, "tests" : [ "(= (__ [1 2 3]) [[1 3]])", "(= (__ [10 9 8 1 2 3]) [[1 3] [8 10]])", "(= (__ [1 1 1 1 1 1 1]) [[1 1]])", "(= (__ []) [])", "(= (__ [19 4 17 1 3 10 2 13 13 2 16 4 2 15 13 9 6 14 2 11])\r\n [[1 4] [6 6] [9 11] [13 17] [19 19]])\r\n" ], "title" : "Intervals", "user" : "aiba" }, -{ "_id" : { "$numberLong" : "173" }, "description" : "Sequential destructuring allows you to bind symbols to parts of sequential things (vectors, lists, seqs, etc.): (let [bindings* ] exprs*)\r\n\r\nComplete the bindings so all let-parts evaluate to 3.", "difficulty" : "Easy", "restricted" : null, "tags" : [ "Destructuring" ], "tests" : [ "(= 3\r\n (let [[__] [+ (range 3)]] (apply __))\r\n (let [[[__] b] [[+ 1] 2]] (__ b))\r\n (let [[__] [inc 2]] (__)))" ], "title" : "Intro to Destructuring 2", "user" : "hangkous" }, -{ "_id" : { "$numberLong" : "177" }, "description" : "When parsing a snippet of code it's often a good idea to do a sanity check to see if all the brackets match up. Write a function that takes in a string and returns truthy if all square [ ] round ( ) and curly { } brackets are properly paired and legally nested, or returns falsey otherwise.", "difficulty" : "Medium", "restricted" : null, "tags" : [ "parsing" ], "tests" : [ "(__ \"This string has no brackets.\")", "(__ \"class Test {\r\n public static void main(String[] args) {\r\n System.out.println(\\\"Hello world.\\\");\r\n }\r\n }\")", "(not (__ \"(start, end]\"))", "(not (__ \"())\"))", "(not (__ \"[ { ] } \"))", "(__ \"([]([(()){()}(()(()))(([[]]({}()))())]((((()()))))))\")", "(not (__ \"([]([(()){()}(()(()))(([[]]({}([)))())]((((()()))))))\"))", "(not (__ \"[\"))" ], "title" : "Balancing Brackets", "user" : "daowen" }, -{ "_id" : { "$numberLong" : "178" }, "description" : "

Following on from Recognize Playing Cards, determine the best poker hand that can be made with five cards. The hand rankings are listed below for your convenience.

\r\n\r\n
    \r\n
  1. Straight flush: All cards in the same suit, and in sequence
  2. \r\n
  3. Four of a kind: Four of the cards have the same rank
  4. \r\n
  5. Full House: Three cards of one rank, the other two of another rank
  6. \r\n
  7. Flush: All cards in the same suit
  8. \r\n
  9. Straight: All cards in sequence (aces can be high or low, but not both at once)
  10. \r\n
  11. Three of a kind: Three of the cards have the same rank
  12. \r\n
  13. Two pair: Two pairs of cards have the same rank
  14. \r\n
  15. Pair: Two cards have the same rank
  16. \r\n
  17. High card: None of the above conditions are met
  18. \r\n
", "difficulty" : "Hard", "restricted" : null, "tags" : [ "strings", "game" ], "tests" : [ "(= :high-card (__ [\"HA\" \"D2\" \"H3\" \"C9\" \"DJ\"]))", "(= :pair (__ [\"HA\" \"HQ\" \"SJ\" \"DA\" \"HT\"]))", "(= :two-pair (__ [\"HA\" \"DA\" \"HQ\" \"SQ\" \"HT\"]))", "(= :three-of-a-kind (__ [\"HA\" \"DA\" \"CA\" \"HJ\" \"HT\"]))", "(= :straight (__ [\"HA\" \"DK\" \"HQ\" \"HJ\" \"HT\"]))", "(= :straight (__ [\"HA\" \"H2\" \"S3\" \"D4\" \"C5\"]))", "(= :flush (__ [\"HA\" \"HK\" \"H2\" \"H4\" \"HT\"]))", "(= :full-house (__ [\"HA\" \"DA\" \"CA\" \"HJ\" \"DJ\"]))", "(= :four-of-a-kind (__ [\"HA\" \"DA\" \"CA\" \"SA\" \"DJ\"]))", "(= :straight-flush (__ [\"HA\" \"HK\" \"HQ\" \"HJ\" \"HT\"]))\r\n" ], "title" : "Best Hand", "user" : "toolkit" }, -{ "_id" : { "$numberLong" : "195" }, "title" : "Parentheses... Again", "difficulty" : "Medium", "description" : "

In a family of languages like Lisp, having balanced parentheses is a defining feature of the language. Luckily, Lisp has almost no syntax, except for these \"delimiters\" -- and that hardly qualifies as \"syntax\", at least in any useful computer programming sense.

\r\n\r\n

It is not a difficult exercise to find all the combinations of well-formed parentheses if we only have N pairs to work with. For instance, if we only have 2 pairs, we only have two possible combinations: \"()()\" and \"(())\". Any other combination of length 4 is ill-formed. Can you see why?

\r\n\r\n

Generate all possible combinations of well-formed parentheses of length 2n (n pairs of parentheses).\r\nFor this problem, we only consider '(' and ')', but the answer is similar if you work with only {} or only [].

\r\n\r\n

There is an interesting pattern in the numbers!

", "tags" : [ "math", "combinatorics" ], "restricted" : null, "tests" : [ "(= [#{\"\"} #{\"()\"} #{\"()()\" \"(())\"}] (map (fn [n] (__ n)) [0 1 2]))", "(= #{\"((()))\" \"()()()\" \"()(())\" \"(())()\" \"(()())\"} (__ 3))", "(= 16796 (count (__ 10)))", "(= (nth (sort (filter #(.contains ^String % \"(()()()())\") (__ 9))) 6) \"(((()()()())(())))\")", "(= (nth (sort (__ 12)) 5000) \"(((((()()()()()))))(()))\")" ], "user" : "djtrack16" }, +{ "_id" : 171, "description" : "Write a function that takes a sequence of integers and returns a sequence of \"intervals\". Each interval is a a vector of two integers, start and end, such that all integers between start and end (inclusive) are contained in the input sequence.", "difficulty" : "Medium", "restricted" : null, "tags" : null, "tests" : [ "(= (__ [1 2 3]) [[1 3]])", "(= (__ [10 9 8 1 2 3]) [[1 3] [8 10]])", "(= (__ [1 1 1 1 1 1 1]) [[1 1]])", "(= (__ []) [])", "(= (__ [19 4 17 1 3 10 2 13 13 2 16 4 2 15 13 9 6 14 2 11])\r\n [[1 4] [6 6] [9 11] [13 17] [19 19]])\r\n" ], "title" : "Intervals", "user" : "aiba" }, +{ "_id" : 173, "description" : "Sequential destructuring allows you to bind symbols to parts of sequential things (vectors, lists, seqs, etc.): (let [bindings* ] exprs*)\r\n\r\nComplete the bindings so all let-parts evaluate to 3.", "difficulty" : "Easy", "restricted" : null, "tags" : [ "Destructuring" ], "tests" : [ "(= 3\r\n (let [[__] [+ (range 3)]] (apply __))\r\n (let [[[__] b] [[+ 1] 2]] (__ b))\r\n (let [[__] [inc 2]] (__)))" ], "title" : "Intro to Destructuring 2", "user" : "hangkous" }, +{ "_id" : 177, "description" : "When parsing a snippet of code it's often a good idea to do a sanity check to see if all the brackets match up. Write a function that takes in a string and returns truthy if all square [ ] round ( ) and curly { } brackets are properly paired and legally nested, or returns falsey otherwise.", "difficulty" : "Medium", "restricted" : null, "tags" : [ "parsing" ], "tests" : [ "(__ \"This string has no brackets.\")", "(__ \"class Test {\r\n public static void main(String[] args) {\r\n System.out.println(\\\"Hello world.\\\");\r\n }\r\n }\")", "(not (__ \"(start, end]\"))", "(not (__ \"())\"))", "(not (__ \"[ { ] } \"))", "(__ \"([]([(()){()}(()(()))(([[]]({}()))())]((((()()))))))\")", "(not (__ \"([]([(()){()}(()(()))(([[]]({}([)))())]((((()()))))))\"))", "(not (__ \"[\"))" ], "title" : "Balancing Brackets", "user" : "daowen" }, +{ "_id" : 178, "description" : "

Following on from Recognize Playing Cards, determine the best poker hand that can be made with five cards. The hand rankings are listed below for your convenience.

\r\n\r\n
    \r\n
  1. Straight flush: All cards in the same suit, and in sequence
  2. \r\n
  3. Four of a kind: Four of the cards have the same rank
  4. \r\n
  5. Full House: Three cards of one rank, the other two of another rank
  6. \r\n
  7. Flush: All cards in the same suit
  8. \r\n
  9. Straight: All cards in sequence (aces can be high or low, but not both at once)
  10. \r\n
  11. Three of a kind: Three of the cards have the same rank
  12. \r\n
  13. Two pair: Two pairs of cards have the same rank
  14. \r\n
  15. Pair: Two cards have the same rank
  16. \r\n
  17. High card: None of the above conditions are met
  18. \r\n
", "difficulty" : "Hard", "restricted" : null, "tags" : [ "strings", "game" ], "tests" : [ "(= :high-card (__ [\"HA\" \"D2\" \"H3\" \"C9\" \"DJ\"]))", "(= :pair (__ [\"HA\" \"HQ\" \"SJ\" \"DA\" \"HT\"]))", "(= :two-pair (__ [\"HA\" \"DA\" \"HQ\" \"SQ\" \"HT\"]))", "(= :three-of-a-kind (__ [\"HA\" \"DA\" \"CA\" \"HJ\" \"HT\"]))", "(= :straight (__ [\"HA\" \"DK\" \"HQ\" \"HJ\" \"HT\"]))", "(= :straight (__ [\"HA\" \"H2\" \"S3\" \"D4\" \"C5\"]))", "(= :flush (__ [\"HA\" \"HK\" \"H2\" \"H4\" \"HT\"]))", "(= :full-house (__ [\"HA\" \"DA\" \"CA\" \"HJ\" \"DJ\"]))", "(= :four-of-a-kind (__ [\"HA\" \"DA\" \"CA\" \"SA\" \"DJ\"]))", "(= :straight-flush (__ [\"HA\" \"HK\" \"HQ\" \"HJ\" \"HT\"]))\r\n" ], "title" : "Best Hand", "user" : "toolkit" }, +{ "_id" : 195, "title" : "Parentheses... Again", "difficulty" : "Medium", "description" : "

In a family of languages like Lisp, having balanced parentheses is a defining feature of the language. Luckily, Lisp has almost no syntax, except for these \"delimiters\" -- and that hardly qualifies as \"syntax\", at least in any useful computer programming sense.

\r\n\r\n

It is not a difficult exercise to find all the combinations of well-formed parentheses if we only have N pairs to work with. For instance, if we only have 2 pairs, we only have two possible combinations: \"()()\" and \"(())\". Any other combination of length 4 is ill-formed. Can you see why?

\r\n\r\n

Generate all possible combinations of well-formed parentheses of length 2n (n pairs of parentheses).\r\nFor this problem, we only consider '(' and ')', but the answer is similar if you work with only {} or only [].

\r\n\r\n

There is an interesting pattern in the numbers!

", "tags" : [ "math", "combinatorics" ], "restricted" : null, "tests" : [ "(= [#{\"\"} #{\"()\"} #{\"()()\" \"(())\"}] (map (fn [n] (__ n)) [0 1 2]))", "(= #{\"((()))\" \"()()()\" \"()(())\" \"(())()\" \"(()())\"} (__ 3))", "(= 16796 (count (__ 10)))", "(= (nth (sort (filter #(.contains ^String % \"(()()()())\") (__ 9))) 6) \"(((()()()())(())))\")", "(= (nth (sort (__ 12)) 5000) \"(((((()()()()()))))(()))\")" ], "user" : "djtrack16" }, { "_id" : 5, "description" : "

When operating on a list, the conj function will return a new list with one or more items \"added\" to the front.

\r\n

Note that there are two test cases, but you are expected to supply only one answer, which will cause all the tests to pass.

", "difficulty" : "Elementary", "tags" : null, "tests" : [ "(= __ (conj '(2 3 4) 1))", "(= __ (conj '(3 4) 2 1))" ], "times-solved" : 1260, "title" : "Lists: conj", "user" : "dbyrne", "restricted" : null }]