Skip to content

fix 5 problems' ids from $numberLong to plain integer #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions public/data/problems.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@
{ "_id" : 164, "description" : "A <a href=\"http://en.wikipedia.org/wiki/Deterministic_finite_automaton\">deterministic finite automaton (DFA)</a> is an abstract machine that recognizes a <a href=\" http://en.wikipedia.org/wiki/Regular_language\">regular language</a>. Usually a DFA is defined by a 5-tuple, but instead we'll use a map with 5 keys:\r\n\r\n<ul>\r\n<li><var>:states</var> is the set of states for the DFA.</li>\r\n<li><var>:alphabet</var> is the set of symbols included in the language recognized by the DFA. </li>\r\n<li><var>:start</var> is the start state of the DFA. </li>\r\n<li><var>:accepts</var> is the set of accept states in the DFA. </li>\r\n<li><var>:transitions</var> is the transition function for the DFA, mapping <var>:states</var> &#x2a2f <var>:alphabet</var> onto <var>:states</var>.</li>\r\n</ul>\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 (&lt;, &le;, =, &ne;, &ge;, and &gt;) from a single operation (any operator but = or &ne; will work). Write a function that takes three arguments, a <var>less than</var> 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 <var>x</var> and <var>y</var> are as follows:\r\n\r\n<ul>\r\n<li><var>x</var> = <var>y</var> &rarr; :eq</li>\r\n<li><var>x</var> &gt; <var>y</var> &rarr; :gt</li>\r\n<li><var>x</var> &lt; <var>y</var> &rarr; :lt</li>\r\n</ul>", "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" : "<p>\r\nIn what follows, <code>m</code>, <code>n</code>, <code>s</code>, <code>t</code> \r\ndenote nonnegative integers, <code>f</code> denotes a function that accepts two \r\narguments and is defined for all nonnegative integers in both arguments.\r\n</p>\r\n\r\n<p>\r\nIn mathematics, the function <code>f</code> can be interpreted as an infinite \r\n<a href=\"http://en.wikipedia.org/wiki/Matrix_%28mathematics%29\">matrix</a>\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</p> \r\n\r\n<p>\r\nWrite a function that accepts 1, 3 and 5 arguments\r\n<ul>\r\n<li>\r\nwith the argument <code>f</code>, it returns the infinite matrix <b>A</b> \r\nthat has the entry in the <code>i</code>-th row and the <code>j</code>-th column \r\nequal to <code>f(i,j)</code> for <code>i,j = 0,1,2,...</code>;</li>\r\n<li>\r\nwith the arguments <code>f</code>, <code>m</code>, <code>n</code>, it returns \r\nthe infinite matrix <b>B</b> that equals the remainder of the matrix <b>A</b> \r\nafter the removal of the first <code>m</code> rows and the first <code>n</code> columns;</li>\r\n<li>\r\nwith the arguments <code>f</code>, <code>m</code>, <code>n</code>, <code>s</code>, <code>t</code>,\r\nit returns the finite s-by-t matrix that consists of the first t entries of each of the first \r\n<code>s</code> rows of the matrix <b>B</b> or, equivalently, that consists of the first s entries \r\nof each of the first <code>t</code> columns of the matrix <b>B</b>.</li>\r\n</ul>\r\n</p>", "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.): <a href=\"http://clojure.org/special_forms#Special Forms--(let [bindings* ] exprs*)\">(let [bindings* ] exprs*)</a>\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" : "<p>Following on from <a href=\"http://www.4clojure.com/problem/128\">Recognize Playing Cards</a>, determine the best poker hand that can be made with five cards. The hand rankings are listed below for your convenience.</p>\r\n\r\n<ol>\r\n <li>Straight flush: All cards in the same suit, and in sequence</li>\r\n <li>Four of a kind: Four of the cards have the same rank</li>\r\n <li>Full House: Three cards of one rank, the other two of another rank</li>\r\n <li>Flush: All cards in the same suit</li>\r\n <li>Straight: All cards in sequence (aces can be high or low, but not both at once)</li>\r\n <li>Three of a kind: Three of the cards have the same rank</li>\r\n <li>Two pair: Two pairs of cards have the same rank</li>\r\n <li>Pair: Two cards have the same rank</li>\r\n <li>High card: None of the above conditions are met</li>\r\n</ol>", "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" : "<p>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.</p>\r\n\r\n<p>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? </p>\r\n\r\n<p>Generate all possible combinations of well-formed parentheses of length <code>2n</code> (n pairs of parentheses).\r\nFor this problem, we only consider '(' and ')', but the answer is similar if you work with only {} or only [].</p>\r\n\r\n<p>There is an interesting pattern in the numbers!</p>", "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.): <a href=\"http://clojure.org/special_forms#Special Forms--(let [bindings* ] exprs*)\">(let [bindings* ] exprs*)</a>\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" : "<p>Following on from <a href=\"http://www.4clojure.com/problem/128\">Recognize Playing Cards</a>, determine the best poker hand that can be made with five cards. The hand rankings are listed below for your convenience.</p>\r\n\r\n<ol>\r\n <li>Straight flush: All cards in the same suit, and in sequence</li>\r\n <li>Four of a kind: Four of the cards have the same rank</li>\r\n <li>Full House: Three cards of one rank, the other two of another rank</li>\r\n <li>Flush: All cards in the same suit</li>\r\n <li>Straight: All cards in sequence (aces can be high or low, but not both at once)</li>\r\n <li>Three of a kind: Three of the cards have the same rank</li>\r\n <li>Two pair: Two pairs of cards have the same rank</li>\r\n <li>Pair: Two cards have the same rank</li>\r\n <li>High card: None of the above conditions are met</li>\r\n</ol>", "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" : "<p>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.</p>\r\n\r\n<p>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? </p>\r\n\r\n<p>Generate all possible combinations of well-formed parentheses of length <code>2n</code> (n pairs of parentheses).\r\nFor this problem, we only consider '(' and ')', but the answer is similar if you work with only {} or only [].</p>\r\n\r\n<p>There is an interesting pattern in the numbers!</p>", "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" : "<p>When operating on a list, the conj function will return a new list with one or more items \"added\" to the front.</p>\r\n<p>Note that there are two test cases, but you are expected to supply only one answer, which will cause all the tests to pass.</p>", "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 }]