Dataset Viewer
Auto-converted to Parquet Duplicate
problem_id
int64
174
4.99k
question
stringlengths
170
5.3k
solutions
stringlengths
0
333k
input_output
stringlengths
45
25.4k
difficulty
stringclasses
3 values
url
stringlengths
39
57
starter_code
stringlengths
0
77
174
Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: dir subdir1 subdir2 file.ext The directory dir contains an empty sub-directory subdir1 and a sub-directory subdir2 containing a file file.ext. The string "dir\n\...
["class Solution:\n def lengthLongestPath(self, input):\n \"\"\"\n :type input: str\n :rtype: int\n \"\"\"\n dict={0:0}\n maxlen=0\n line=input.split(\"\\n\")\n for i in line:\n name=i.lstrip('\\t')\n print(name)\n p...
{"fn_name": "lengthLongestPath", "inputs": [["\"dir\\n\\tsubdir1\\n\\tsubdir2\\n\\t\\tfile.ext\""]], "outputs": [41]}
interview
https://leetcode.com/problems/longest-absolute-file-path/
class Solution: def lengthLongestPath(self, input: str) -> int:
752
Many internet protocols these days include the option of associating a media type with the content being sent. The type is usually inferred from the file extension. You are to write a program that facilitates the lookup of media types for a number of files. You will be given a table of media type associations that asso...
["# cook your dish here\nn,m=list(map(int,input().split()))\na={}\nfor i in range(n):\n x,y=input().split()\n a[x]=y\nfor i in range(m):\n c=input().strip()\n if '.' not in c:\n print(\"unknown\")\n else:\n h=c.split('.')[-1]\n if h in a:\n print(a[h])\n else:\n print('unknown')\n \n \n", "# cook your dish her...
{"inputs": [["5 6", "html text/html", "htm text/html", "png image/png", "svg image/svg+xml", "txt text/plain", "index.html", "this.file.has.lots.of.dots.txt", "nodotsatall", "virus.exe", "dont.let.the.png.fool.you", "case.matters.TXT"]], "outputs": [["text/html", "text/plain", "unknown", "unknown", "unknown", "unknown"...
interview
https://www.codechef.com/problems/MIME2
1,649
Automatons, or Finite State Machines (FSM), are extremely useful to programmers when it comes to software design. You will be given a simplistic version of an FSM to code for a basic TCP session. The outcome of this exercise will be to return the correct state of the TCP FSM based on the array of events given. ------...
["STATE_TO_COMMANDS = {\n 'CLOSED': {\n 'APP_PASSIVE_OPEN': 'LISTEN',\n 'APP_ACTIVE_OPEN': 'SYN_SENT'\n },\n 'LISTEN': {\n 'RCV_SYN': 'SYN_RCVD',\n 'APP_SEND': 'SYN_SENT',\n 'APP_CLOSE': 'CLOSED'\n },\n 'SYN_RCVD': {\n 'APP_CLOSE': 'FIN_WAIT_1',\n 'RCV_ACK': 'ESTABLISHED'\n },\n 'SYN_SENT': ...
{"fn_name": "traverse_TCP_states", "inputs": [[["APP_PASSIVE_OPEN", "RCV_SYN", "RCV_ACK", "APP_CLOSE"]], [["APP_PASSIVE_OPEN", "RCV_SYN", "RCV_ACK"]], [["APP_PASSIVE_OPEN", "RCV_SYN"]], [["APP_PASSIVE_OPEN"]], [["APP_ACTIVE_OPEN", "APP_CLOSE"]], [["APP_ACTIVE_OPEN", "RCV_SYN", "APP_CLOSE", "RCV_FIN", "RCV_ACK"]], [["AP...
interview
https://www.codewars.com/kata/54acc128329e634e9a000362
def traverse_TCP_states(events):
1,655
```if:java ___Note for Java users:___ Due to type checking in Java, inputs and outputs are formated quite differently in this language. See the footnotes of the description. ``` You have the following lattice points with their corresponding coordinates and each one with an specific colour. ``` Point [x , y] ...
["from itertools import combinations\n\ndef count_col_triang(a):\n p, r = {}, {}\n for xy, col in a:\n p[col] = p.get(col, []) + [xy]\n for k in p:\n r[k] = sum(1 for c in combinations(p[k], 3) if triangle(*c))\n mx = max(r.values())\n return [len(a), len(p), sum(r.values()), sorted(k for k...
{"fn_name": "count_col_triang", "inputs": [[[[[3, -4], "blue"], [[-7, -1], "red"], [[7, -6], "yellow"], [[2, 5], "yellow"], [[1, -5], "red"], [[-1, 4], "red"], [[1, 7], "red"], [[-3, 5], "red"], [[-3, -5], "blue"], [[4, 1], "blue"]]], [[[[3, -4], "blue"], [[-7, -1], "red"], [[7, -6], "yellow"], [[2, 5], "yellow"], [[1,...
interview
https://www.codewars.com/kata/57cebf1472f98327760003cd
def count_col_triang(a):
1,664
# Task An `amazon` (also known as a queen+knight compound) is an imaginary chess piece that can move like a `queen` or a `knight` (or, equivalently, like a `rook`, `bishop`, or `knight`). The diagram below shows all squares which the amazon attacks from e4 (circles represent knight-like moves while crosses correspond ...
["from itertools import count\n\nALL_MOVES = [(1,1), (0,1), ( 1,0), (-1,0), (0,-1), (-1,1), ( 1,-1), (-1,-1)] # Natural directions of moves for king or queen (one step)\nAMA_MOVES = [(1,2), (2,1), (-1,2), (2,-1), (1,-2), (-2,1), (-1,-2), (-2,-1)] # Knight moves for amazon queen\n\n\ndef amazon_check_mate(...
{"fn_name": "amazon_check_mate", "inputs": [["a1", "g5"], ["a3", "e4"], ["f3", "f2"], ["b7", "a8"], ["f7", "d3"], ["g2", "c3"], ["f3", "c1"], ["d4", "h8"], ["h6", "a7"], ["a6", "g3"], ["e1", "b4"], ["f4", "c4"], ["c3", "e8"], ["b5", "e5"], ["c8", "g8"], ["a6", "b5"], ["b3", "e2"], ["b7", "c3"], ["b5", "b3"], ["a4", "a6...
interview
https://www.codewars.com/kata/5897f30d948beb78580000b2
def amazon_check_mate(king, amazon):
1,710
![alt text](https://2.bp.blogspot.com/-DNNiOXduuvQ/Vh-FR-qbKXI/AAAAAAAAEOA/HT0IzJ36zW4/s1600/voz.jpg) Create a class called `Warrior` which calculates and keeps track of their level and skills, and ranks them as the warrior they've proven to be. Business Rules: - A warrior starts at level 1 and can progress all the ...
["class Warrior():\n \n def __init__(self):\n self._experience = 100\n self.rs = [\"Pushover\", \"Novice\", \"Fighter\", \"Warrior\", \"Veteran\", \"Sage\", \"Elite\", \"Conqueror\", \"Champion\", \"Master\", \"Greatest\"]\n self.achievements = []\n def training(self, train):\n if(t...
{"fn_name": "__init__", "inputs": [], "outputs": []}
interview
https://www.codewars.com/kata/5941c545f5c394fef900000c
def __init__(self):
1,714
### The Problem Consider a flat board with pegs sticking out of one side. If you stretched a rubber band across the outermost pegs what is the set of pegs such that all other pegs are contained within the shape formed by the rubber band? ![alt text](https://upload.wikimedia.org/wikipedia/commons/b/bc/ConvexHull.png) ...
["def hull_method(points):\n sorted_points = sorted(points)\n return half_hull(sorted_points) + half_hull(reversed(sorted_points))\n\ndef half_hull(sorted_points):\n hull = []\n for p in sorted_points:\n while len(hull) > 1 and not is_ccw_turn(hull[-2], hull[-1], p):\n hull.pop()\n ...
{"fn_name": "hull_method", "inputs": [], "outputs": []}
interview
https://www.codewars.com/kata/5657d8bdafec0a27c800000f
def hull_method(pointlist):
1,767
### **[Mahjong Series](/collections/mahjong)** **Mahjong** is based on draw-and-discard card games that were popular in 18th and 19th century China and some are still popular today. In each deck, there are three different suits numbered `1` to `9`, which are called **Simple tiles**. To simplify the problem, we talk a...
["from collections import Counter\n\ndef solution(tiles):\n return \"\".join(\n tile for tile in \"123456789\"\n if tiles.count(tile) < 4\n and list(meld(meld(meld(meld(pair(Counter(map(int, tiles+tile))))))))\n )\n\ndef pair(c):\n yield from (c - Counter([t,t]) for t in c if c[t] ...
{"fn_name": "solution", "inputs": [], "outputs": []}
interview
https://www.codewars.com/kata/56ad7a4978b5162445000056
def solution(tiles):
1,777
"# Task\n IONU Satellite Imaging, Inc. records and stores very large images using run length encodin(...TRUNCATED)
"[\"'''\\nChallenge Fun #20: Edge Detection\\nhttps://www.codewars.com/kata/58bfa40c43fadb4edb0000b5(...TRUNCATED)
{"fn_name": "edge_detection", "inputs": [], "outputs": []}
interview
https://www.codewars.com/kata/58bfa40c43fadb4edb0000b5
def edge_detection(image):
2,858
"# Task\n Miss X has only two combs in her possession, both of which are old and miss a tooth or two(...TRUNCATED)
"[\"def combs(a, b):\\n return min(mesh(a, b), mesh(b, a))\\n\\ndef mesh(a, b):\\n for i in ra(...TRUNCATED)
"{\"fn_name\": \"combs\", \"inputs\": [[\"*..*\", \"*.*\"], [\"*...*\", \"*.*\"], [\"*..*.*\", \"*.*(...TRUNCATED)
introductory
https://www.codewars.com/kata/58898b50b832f8046a0000ec
def combs(comb1, comb2):
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
4