id
stringlengths
25
25
kind
stringclasses
1 value
title
stringlengths
17
17
provisional
bool
1 class
output_code
stringlengths
60
4.12k
input_data_sample
stringlengths
3
637
output_data_sample
unknown
transformation_instruction
stringlengths
54
1.91k
cmsx3d5d5003bx3p2kgzimabd
contributor_item
Submission ZIMABD
false
import re import json def parse_logfmt(line): pairs = re.findall(r'(\w+)=("[^"]*"|\S+)', line) result = {} for k, v in pairs: if v.startswith('"') and v.endswith('"'): v = v[1:-1] result[k] = v return result def transform(text): lines = [l for l in text.strip('\n').spl...
time=2026-08-10T10:00:00 level=info msg="request handled" duration=120 time=2026-08-10T10:00:05 level=error msg="db timeout" duration=5000 time=2026-08-10T10:00:07 level=info msg="request handled" duration=95 time=2026-08-10T10:00:09 level=warn msg="slow response" duration=800 time=2026-08-10T10:00:12 level=error msg="...
{ "info": { "count": 3, "avg_duration": 108.33 }, "error": { "count": 2, "avg_duration": 4950 }, "warn": { "count": 1, "avg_duration": 800 } }
Each line is logfmt-style text with space-separated key=value pairs, where values may be double-quoted strings containing spaces. Parse the 'level' and 'duration' fields from each line, group lines by level, and compute count and average duration (rounded to 2 decimals) per level. Return a JSON object mapping level to ...
cmsx3d5d5002kx3p2txsvsmt0
contributor_item
Submission SVSMT0
false
import json def transform(text): lines = text.strip('\n').split('\n') request_line = lines[0].strip() parts = request_line.split(' ') method, path = parts[0], parts[1] protocol = parts[2] if len(parts) > 2 else '' headers = {} for line in lines[1:]: line = line.rstrip('\r') ...
GET /api/users?active=true HTTP/1.1 Host: api.example.com Accept: application/json, text/html X-Forwarded-For: 10.0.0.1, 10.0.0.2, 10.0.0.3 User-Agent: curl/7.68.0 Cache-Control: no-cache Accept: */*
{ "method": "GET", "path": "/api/users?active=true", "protocol": "HTTP/1.1", "headers": { "host": "api.example.com", "accept": [ "application/json", "text/html", "*/*" ], "x-forwarded-for": [ "10.0.0.1", "10.0.0.2", "10.0.0.3" ], "user-agent": "curl/7....
Parse this raw HTTP request text. The first line is the request line 'METHOD PATH PROTOCOL'. The remaining lines are 'Header-Name: value' pairs. Lower-case every header name. Split each header's value on commas into a list of trimmed values; if a header name repeats, merge and deduplicate its value lists in order of fi...
cmsx3d5d5002lx3p2866nlc1c
contributor_item
Submission 6NLC1C
false
import json import math def transform(text): parts = text.split('---') frontmatter_raw = parts[1].strip('\n') body = '---'.join(parts[2:]).strip('\n') metadata = {} for line in frontmatter_raw.splitlines(): if ':' not in line: continue key, val = line.split(':', 1) ...
--- title: Getting Started author: Jane Doe tags: python, tutorial, beginner published: true --- # Getting Started This is a short guide to get you started with the tool. It covers installation and basic usage in a few short paragraphs. ## Installation Run pip install tool to install.
{ "metadata": { "title": "Getting Started", "author": "Jane Doe", "tags": [ "python", "tutorial", "beginner" ], "published": true }, "word_count": 34, "reading_time_minutes": 1 }
This is a markdown document with a YAML-like frontmatter block delimited by '---' lines, followed by a body. Parse the frontmatter into a metadata dict: split the 'tags' value on commas into a list of trimmed strings; convert 'true'/'false' values (case-insensitive) to booleans; leave other values as strings. Count the...
cmsx3d5d5002ix3p2lcovbdkq
contributor_item
Submission OVBDKQ
false
import re import json def transform(text): blocks = text.strip().split('BEGIN:VCARD') contacts = [] for block in blocks: block = block.strip() if not block: continue block = block.replace('END:VCARD', '').strip() fields = {} for line in block.splitlines(...
BEGIN:VCARD FN:John Smith TEL:(555) 123-4567 EMAIL:John.Smith@EXAMPLE.com ORG:Acme Corp END:VCARD BEGIN:VCARD FN:Maria Garcia TEL:+34 91 123 4567 EMAIL:maria@example.org END:VCARD BEGIN:VCARD FN:Bob Lee TEL:1-800-555-0199 EMAIL:BOB@TEST.COM ORG:Widgets Inc END:VCARD
[ { "name": "John Smith", "phone": "+15551234567", "email": "john.smith@example.com", "org": "Acme Corp" }, { "name": "Maria Garcia", "phone": "+34911234567", "email": "maria@example.org", "org": null }, { "name": "Bob Lee", "phone": "+18005550199", "email": "bob@te...
Parse this text containing multiple BEGIN:VCARD/END:VCARD blocks into a JSON array of contact objects with keys name, phone, email, org. Normalize each phone number to E.164 format: strip all non-digit characters; if the original number already starts with '+', keep it as '+' followed by the digits; if the digits are e...
cmsx3d5d5002px3p2bu6fkqrt
contributor_item
Submission 6FKQRT
false
def transform(text): lines = [l for l in text.strip('\n').split('\n') if l.strip()] out = ['os\tbrowser\tversion'] for ua in lines: if 'Windows' in ua: os_name = 'Windows' elif 'iPhone' in ua: os_name = 'iOS' elif 'Macintosh' in ua or 'Mac OS X' in ua: ...
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Mozilla/5.0 (Macintosh; Intel Mac OS X 13_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Safari/605.1.15 Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0 Safari/53...
"os\tbrowser\tversion\nWindows\tChrome\t115.0.0.0\nmacOS\tSafari\t16.5\nLinux\tChrome\t114.0\niOS\tSafari\t16.5\nUnknown\tcurl\t7.68.0"
Parse each User-Agent line into an operating system and browser with version, using these rules in order: OS is 'Windows' if the string contains 'Windows'; else 'iOS' if it contains 'iPhone'; else 'macOS' if it contains 'Macintosh' or 'Mac OS X'; else 'Linux' if it contains 'Linux'; else 'Unknown'. Browser: 'Chrome' wi...
cmsx3d5d5002ox3p2jwxp7s2o
contributor_item
Submission XP7S2O
false
import json def transform(text): lines = text.strip('\n').split('\n') rows = [] warnings = 0 for line in lines[1:]: cols = line.split('\t') sku, location, stock = cols[0], cols[1], int(cols[2]) if stock < 0: stock = 0 warnings += 1 rows.append({'...
sku location stock A1 WH1 50 A2 WH1 -5 A3 WH2 12 A2 WH2 -20 A4 WH1 0
{ "corrected_rows": [ { "sku": "A1", "location": "WH1", "stock": 50 }, { "sku": "A2", "location": "WH1", "stock": 0 }, { "sku": "A3", "location": "WH2", "stock": 12 }, { "sku": "A2", "location": "WH2", "stock": 0 }...
This is tab-separated inventory data with header 'sku\tlocation\tstock'. Some stock values are negative due to a data error; clamp any negative stock to 0 and count how many rows were clamped as 'warnings'. Return JSON {corrected_rows: [{sku, location, stock}, ...], warnings: <int>} serialized with indent=2, preserving...
cmsx3d5d5002nx3p2so0d5liw
contributor_item
Submission 0D5LIW
false
import json def transform(text): out = ['order_id,customer,sku,qty,price,line_total'] for line in text.strip('\n').split('\n'): if not line.strip(): continue order = json.loads(line) items = order.get('items', []) if not items: out.append(f"{order['order...
{"order_id": "A100", "customer": "Lee", "items": [{"sku": "X1", "qty": 2, "price": 9.5}, {"sku": "X2", "qty": 1, "price": 20.0}]} {"order_id": "A101", "customer": "Kim", "items": [{"sku": "X3", "qty": 5, "price": 3.25}]} {"order_id": "A102", "customer": "Park", "items": []}
"order_id,customer,sku,qty,price,line_total\nA100,Lee,X1,2,9.50,19.00\nA100,Lee,X2,1,20.00,20.00\nA101,Kim,X3,5,3.25,16.25\nA102,Park,,0,0.00,0.00"
Each line is a JSON order object with an 'items' array of {sku, qty, price}. Flatten this into a CSV with header 'order_id,customer,sku,qty,price,line_total' with one row per item, where line_total = qty * price formatted to 2 decimal places (price also formatted to 2 decimals). If an order's items list is empty, emit ...
cmsx3d5d5002mx3p2isnht6af
contributor_item
Submission NHT6AF
false
def transform(text): lines = [l for l in text.strip('\n').split('\n') if l.strip()] header = [h.strip() for h in lines[0].split(',')] seen = {} order = [] for line in lines[1:]: cols = [c.strip() for c in line.split(',')] name, email, city = cols[0], cols[1], cols[2] key = (...
Name , Email ,City Alice Wong ,alice@example.com , Seattle Bob Chen,BOB@EXAMPLE.COM,Portland alice wong , ALICE@EXAMPLE.COM ,seattle Carol Diaz,carol@example.com,Denver BOB CHEN, bob@example.com ,Portland
"Name,Email,City\nAlice Wong,alice@example.com,Seattle\nBob Chen,bob@example.com,Portland\nCarol Diaz,carol@example.com,Denver"
This CSV has inconsistent whitespace and duplicate rows that only differ by case. Trim whitespace from every field. Treat two rows as duplicates if their name and email match case-insensitively after trimming; keep only the first occurrence of each unique (name, email) pair, in original order. In the kept rows, lower-c...
cmsx3d5d5002rx3p22d5eykl6
contributor_item
Submission 5EYKL6
false
import json import re def transform(text): lines = [l for l in text.strip('\n').split('\n') if l.strip()] totals = {} for line in lines[1:]: desc, amount = line.split(',', 1) m = re.match(r'^([^\d.]+)([\d.]+)$', amount.strip()) symbol, value = m.group(1), float(m.group(2)) ...
description,amount Coffee,$4.50 Book,€12.99 Lunch,$8.25 Museum,€7.00 Taxi,£15.00 Snack,$2.10 Gift,£3.50
{ "$": 14.85, "€": 19.99, "£": 18.5 }
This CSV has a description column and an amount column where amounts are prefixed with a currency symbol ($, €, or £) and no thousands separators. Sum the numeric amounts grouped by currency symbol, rounding each running total to 2 decimals. Return a JSON object mapping each currency symbol to its total, serialized wit...
cmsx3d5d5002qx3p2qdq99cci
contributor_item
Submission Q99CCI
false
import json def parse_semver(v): core = v build = None if '+' in core: core, build = core.split('+', 1) prerelease = None if '-' in core: core, prerelease = core.split('-', 1) major, minor, patch = (int(x) for x in core.split('.')) return major, minor, patch, prerelease, bu...
1.2.3 1.10.0 1.2.3-alpha 1.2.3 2.0.0-beta.1 1.2.10 1.2.3-alpha+build.5 2.0.0 1.2.9
[ "1.2.3-alpha", "1.2.3-alpha+build.5", "1.2.3", "1.2.9", "1.2.10", "1.10.0", "2.0.0-beta.1", "2.0.0" ]
This is a list of semantic version strings (major.minor.patch[-prerelease][+build]), one per line, with exact duplicates and mixed pre-release/build metadata. Remove exact duplicate lines (keeping first occurrence order irrelevant since we re-sort), then sort all unique versions by semver precedence rules: compare majo...
cmsx3d5d5002vx3p25o9f5yq5
contributor_item
Submission 9F5YQ5
false
import json FLAGS = [(1, 'READ'), (2, 'WRITE'), (4, 'DELETE'), (8, 'ADMIN')] def transform(text): lines = [l for l in text.strip('\n').split('\n') if l.strip()] result = [] for line in lines[1:]: user, mask = line.split(',') mask = int(mask) flags = [name for bit, name in FLAGS if...
user,permissions_mask alice,7 bob,1 carol,15 dave,0 erin,10
[ { "user": "alice", "mask": 7, "flags": [ "READ", "WRITE", "DELETE" ] }, { "user": "bob", "mask": 1, "flags": [ "READ" ] }, { "user": "carol", "mask": 15, "flags": [ "READ", "WRITE", "DELETE", "ADMIN" ] }, { ...
This CSV has a user and a permissions_mask (integer bitmask) column. Bit 1 = READ, bit 2 = WRITE, bit 4 = DELETE, bit 8 = ADMIN. Decode each mask into the list of flag names whose bits are set (empty list if mask is 0). Return a JSON array of objects {user, mask, flags} in original order, serialized with indent=2.
cmsx3d5d5002xx3p290vgw1gx
contributor_item
Submission VGW1GX
false
MORSE = { '.-': 'A', '-...': 'B', '-.-.': 'C', '-..': 'D', '.': 'E', '..-.': 'F', '--.': 'G', '....': 'H', '..': 'I', '.---': 'J', '-.-': 'K', '.-..': 'L', '--': 'M', '-.': 'N', '---': 'O', '.--.': 'P', '--.-': 'Q', '.-.': 'R', '...': 'S', '-': 'T', '..-': 'U', '...-': 'V', '.--': 'W', '-..-': 'X', '-....
.... . .-.. .-.. --- / .-- --- .-. .-.. -.. --. --- --- -.. / -- --- .-. -. .. -. --. .--. -.-- - .... --- -.
"HELLO WORLD\nGOOD MORNING\nPYTHON"
Each line is Morse code where letters within a word are separated by single spaces and words are separated by ' / '. Decode each line to uppercase plain text (words separated by a single space) and return all decoded lines newline-joined, in original order.
cmsx3d5d5002ux3p23wyxlyl9
contributor_item
Submission YXLYL9
false
import unicodedata import re import json def slugify(s): s = unicodedata.normalize('NFKD', s).encode('ascii', 'ignore').decode('ascii') s = s.lower() s = re.sub(r'[^a-z0-9\s-]', '', s) s = re.sub(r'[\s-]+', '-', s).strip('-') return s def transform(text): titles = [l for l in text.strip('\n')...
Café Del Mar: A Sunset Story! 10 Tips & Tricks for Beginners Résumé Writing 101 C++ Programming — The Basics Hello, World?? (2024 Edition)
[ { "title": "Café Del Mar: A Sunset Story!", "slug": "cafe-del-mar-a-sunset-story" }, { "title": "10 Tips & Tricks for Beginners", "slug": "10-tips-tricks-for-beginners" }, { "title": "Résumé Writing 101", "slug": "resume-writing-101" }, { "title": "C++ Programming — The Basic...
For each title line, generate a URL slug: transliterate accented/unicode characters to their closest ASCII equivalent (using NFKD normalization and dropping non-encodable characters), lower-case the result, remove any character that isn't a lowercase letter, digit, whitespace, or hyphen, then collapse any run of whites...
cmsx3d5d5002wx3p27re7vmrv
contributor_item
Submission E7VMRV
false
import json def transform(text): lines = [l for l in text.strip('\n').split('\n') if l.strip()] result = {} for line in lines: group, pairs_str = line.split(':', 1) pairs = pairs_str.split(',') total_weighted = 0.0 total_weight = 0.0 for pair in pairs: s...
MathTest:88;0.3,92;0.5,79;0.2 ScienceTest:95;0.4,85;0.6 HistoryTest:70;1.0
{ "MathTest": 88.2, "ScienceTest": 89, "HistoryTest": 70 }
Each line has a group name, a colon, then comma-separated 'score;weight' pairs. Compute the weighted average score per group as sum(score*weight)/sum(weight), rounded to 2 decimals. Return a JSON object mapping group name to its weighted average, serialized with indent=2, preserving input order.
cmsx3d5d50031x3p2ppr2yvlj
contributor_item
Submission R2YVLJ
false
def transform(text): lines = [l for l in text.strip('\n').split('\n') if l.strip()] header = lines[0] out = [header] last_region = None for line in lines[1:]: cols = line.split(',') region = cols[0] if region.strip() == '"': region = last_region else: ...
Region,Product,Sales West,Widget,100 ",Gadget,150 ",Gizmo,90 East,Widget,80 ",Gadget,60 North,Widget,40
"Region,Product,Sales\nWest,Widget,100\nWest,Gadget,150\nWest,Gizmo,90\nEast,Widget,80\nEast,Gadget,60\nNorth,Widget,40"
This CSV uses a ditto mark (a lone double-quote character) in the Region column to mean 'same as the row above'. Fill down the Region column: whenever a row's first field is exactly a single double-quote character, replace it with the most recent actual region value seen above it. Leave other columns untouched. Return ...
cmsx3d5d50030x3p2xw95k6yp
contributor_item
Submission 95K6YP
false
import json def hex_to_rgb(hex_code): hex_code = hex_code.lstrip('#') return [int(hex_code[i:i + 2], 16) for i in (0, 2, 4)] def transform(text): lines = [l for l in text.strip('\n').split('\n') if l.strip()] groups = {} for line in lines: name, hex_code = line.split(':') name = n...
brand-primary: #1A73E8 brand-secondary: #34A853 brand-accent: #FBBC05 alert-error: #EA4335 alert-warning: #FF6D01 neutral-100: #F5F5F5 neutral-900: #212121
{ "brand": [ { "name": "brand-primary", "rgb": [ 26, 115, 232 ] }, { "name": "brand-secondary", "rgb": [ 52, 168, 83 ] }, { "name": "brand-accent", "rgb": [ 251, 188, 5 ] ...
Each line is 'name: #HEXCODE'. Group entries by the prefix before the first hyphen in the name. Convert each hex code to an [R, G, B] integer list. Return a JSON object mapping each prefix to a list of {name, rgb} objects in original order, serialized with indent=2.
cmsx3d5d5002zx3p2mhzq6n21
contributor_item
Submission ZQ6N21
false
import re import json def dms_to_decimal(dms_str): m = re.match(r"(\d+)°(\d+)'([\d.]+)\"([NSEW])", dms_str) deg, minutes, seconds, direction = m.groups() value = float(deg) + float(minutes) / 60 + float(seconds) / 3600 if direction in ('S', 'W'): value = -value return round(value, 6) def ...
41°24'12.2"N 2°10'26.5"E 40°26'46.0"N 79°58'56.0"W 33°51'54.0"S 151°12'36.0"E 90°0'0.0"N 0°0'0.0"E
[ { "lat": 41.403389, "lon": 2.174028 }, { "lat": 40.446111, "lon": -79.982222 }, { "lat": -33.865, "lon": 151.21 }, { "lat": 90, "lon": 0 } ]
Each line has a latitude and longitude in degrees-minutes-seconds format like 41°24'12.2"N, separated by a space. Convert each to decimal degrees using degrees + minutes/60 + seconds/3600, negating the value if the direction is S or W, rounded to 6 decimal places. Return a JSON array of {lat, lon} objects in order, ser...
cmsx3d5d5002yx3p2e4ur2k78
contributor_item
Submission UR2K78
false
import re import json def transform(text): messages = re.split(r'\n(?=From )', text.strip('\n')) result = [] for msg in messages: lines = msg.split('\n') headers = {} for line in lines[1:]: if not line.strip(): break if ':' in line: ...
From alice@example.com Mon Aug 10 10:00:00 2026 From: Alice <alice@example.com> To: bob@example.com Subject: Meeting Tomorrow Date: Mon, 10 Aug 2026 10:00:00 +0000 Let's meet at 10am. From bob@example.com Mon Aug 10 11:00:00 2026 From: Bob <bob@example.com> To: alice@example.com, carol@example.com Subject: Re: Meetin...
[ { "from": "Alice <alice@example.com>", "to": [ "bob@example.com" ], "subject": "Meeting Tomorrow", "date": "Mon, 10 Aug 2026 10:00:00 +0000" }, { "from": "Bob <bob@example.com>", "to": [ "alice@example.com", "carol@example.com" ], "subject": "Re: Meeting Tom...
This is mbox-style text: each message begins with an envelope line starting with 'From ' followed by header lines (From, To, Subject, Date) then a blank line then the body. Split on message boundaries (lines starting with 'From ' that are not preceded by other content on the same message), parse the From, To, Subject, ...
cmsx3d5d50035x3p2p52z5c9z
contributor_item
Submission 2Z5C9Z
false
def transform(text): lines = [l for l in text.strip('\n').split('\n') if l.strip()] header = lines[0] out = [header] for line in lines[1:]: id_, value, checksum = line.split(',') expected = sum(ord(c) for c in id_ + value) % 97 if expected == int(checksum): out.appen...
id,value,checksum A1,apple,62 A2,banana,45 A3,cherry,91 A4,date,46
"id,value,checksum\nA1,apple,62\nA2,banana,45\nA4,date,46"
This CSV has columns id,value,checksum. The correct checksum for a row is defined as sum(ord(c) for c in id + value) % 97. Recompute the checksum for every row and keep only the rows where the stored checksum matches the recomputed value; discard rows whose stored checksum is wrong. Return the filtered CSV text (comma-...
cmsx3d5d50033x3p2iwgobmi5
contributor_item
Submission GOBMI5
false
import re import json def transform(text): lines = [l for l in text.strip('\n').split('\n') if l.strip()] result = [] for line in lines: main = re.split(r'ext', line, flags=re.IGNORECASE)[0] digits = re.sub(r'\D', '', main) if len(digits) == 10: normalized = '+1' + digi...
(415) 555-2671 415.555.9823 +1-415-555-3344 415 555 7788 ext 12 1(415)5551234
[ { "original": "(415) 555-2671", "e164": "+14155552671" }, { "original": "415.555.9823", "e164": "+14155559823" }, { "original": "+1-415-555-3344", "e164": "+14155553344" }, { "original": "415 555 7788 ext 12", "e164": "+14155557788" }, { "original": "1(415)5551234...
Each line is a US phone number in a different format, possibly with a trailing extension like 'ext 12'. Strip any extension first (everything from 'ext', case insensitive, onward), then extract the digits. If there are exactly 10 digits, normalize to '+1' followed by the digits. If there are 11 digits starting with '1'...
cmsx3d5d50032x3p2gxv8rf03
contributor_item
Submission V8RF03
false
import re import json def parse_duration(s): pattern = re.findall(r'(\d+)([hms])', s) total = 0 for value, unit in pattern: value = int(value) if unit == 'h': total += value * 3600 elif unit == 'm': total += value * 60 elif unit == 's': t...
build:1h30m build:45m test:90s test:2m30s deploy:5m build:20m
{ "build": 9300, "test": 240, "deploy": 300 }
Each line is 'task:duration' where duration is composed of optional h/m/s components like '1h30m', '45m', '90s', '2m30s'. Parse each duration to total seconds and sum by task. Return a JSON object mapping task name to total seconds (integer), serialized with indent=2, preserving first-appearance order of tasks.
cmsx3d5d50039x3p2e6vnyc4u
contributor_item
Submission VNYC4U
false
import json SCALE = { 'Strongly Disagree': 1, 'Disagree': 2, 'Neutral': 3, 'Agree': 4, 'Strongly Agree': 5 } def transform(text): lines = [l for l in text.strip('\n').split('\n') if l.strip()] header = lines[0].split(',') questions = header[1:] sums = {q: 0 for q in questions} ...
respondent,q1,q2,q3 R1,Strongly Agree,Agree,Neutral R2,Disagree,Strongly Agree,Agree R3,Neutral,Disagree,Strongly Disagree R4,Strongly Disagree,Neutral,Strongly Agree
{ "responses": [ { "respondent": "R1", "scores": { "q1": 5, "q2": 4, "q3": 3 } }, { "respondent": "R2", "scores": { "q1": 2, "q2": 5, "q3": 4 } }, { "respondent": "R3", "scores": { "q1": 3, ...
This CSV has a respondent column followed by question columns with Likert-scale text answers. Map answers to numbers: 'Strongly Disagree'=1, 'Disagree'=2, 'Neutral'=3, 'Agree'=4, 'Strongly Agree'=5. Build a JSON object with 'responses': a list of {respondent, scores: {question: number, ...}} in row order, and 'averages...
cmsx3d5d50036x3p2bih4l1tg
contributor_item
Submission H4L1TG
false
import re import json def transform(text): lines = [l for l in text.strip('\n').split('\n') if l.strip()] header = lines[0] m = re.match(r'rows=(\d+)\s+cols=(\d+)', header) rows, cols = int(m.group(1)), int(m.group(2)) grid = [[0] * cols for _ in range(rows)] for line in lines[1:]: r, ...
rows=3 cols=4 0,0,5 0,3,2 1,1,7 2,0,1 2,3,9
[ [ 5, 0, 0, 2 ], [ 0, 7, 0, 0 ], [ 1, 0, 0, 9 ] ]
The first line declares grid dimensions as 'rows=R cols=C'. Each following line is 'row,col,value' for a non-zero cell in sparse coordinate format. Build the dense R x C grid (all other cells 0) and return it as a JSON 2D array (list of row lists) serialized with indent=2.
cmsx3d5d50037x3p2lfi6hudf
contributor_item
Submission I6HUDF
false
import re import json from collections import Counter STOPWORDS = {'the', 'a', 'an', 'at', 'but', 'over', 'is', 'in', 'on', 'and', 'to', 'of'} def transform(text): words = re.findall(r"[a-zA-Z']+", text.lower()) words = [w for w in words if w not in STOPWORDS] counts = Counter(words) result = sorted(...
The quick brown fox jumps over the lazy dog. The dog barks at the fox, but the fox runs away quickly. A quick fox is a smart fox.
[ [ "fox", 5 ], [ "dog", 2 ], [ "quick", 2 ], [ "away", 1 ], [ "barks", 1 ], [ "brown", 1 ], [ "jumps", 1 ], [ "lazy", 1 ], [ "quickly", 1 ], [ "runs", 1 ], [ "smart", 1 ] ]
Lower-case the text and extract alphabetic word tokens (letters and apostrophes only). Remove any token in this stopword set: {the, a, an, at, but, over, is, in, on, and, to, of}. Count the frequency of remaining words and return a JSON array of [word, count] pairs sorted by count descending, then alphabetically ascend...
cmsx3d5d5003ax3p21bb56osj
contributor_item
Submission B56OSJ
false
import json def transform(text): lines = [l for l in text.strip('\n').split('\n') if l.strip()] result = {} current_id = None seq = '' def flush(): if current_id: gc = seq.count('G') + seq.count('C') pct = round(gc / len(seq) * 100, 2) if seq else 0 res...
>seq1 ATGCGCTAGCTAGCTAGCGCGATCG >seq2 ATATATATATCGCGCG >seq3 GGGGCCCCAATT
{ "seq1": 60, "seq2": 37.5, "seq3": 66.67 }
This is FASTA-format text: lines starting with '>' introduce a sequence id, followed by one or more lines of nucleotide letters belonging to that sequence (concatenate them). For each sequence compute the GC content percentage: (count of 'G' + count of 'C') / total length * 100, rounded to 2 decimals. Return a JSON obj...
cmsx5vet500fpx3p2xtpvm84j
contributor_item
Submission PVM84J
false
from datetime import datetime def transform(input): d={} for l in input.splitlines(): t,v=l.split(',');h=datetime.fromisoformat(t.replace('Z','+00:00')).strftime('%Y-%m-%dT%H');d[h]=d.get(h,0)+int(v) return '\n'.join(f'{k},{d[k]}' for k in sorted(d))
2026-01-01T00:00:00Z,5 2026-01-01T00:30:00Z,7 2026-01-01T01:00:00Z,4
"2026-01-01T00,12\n2026-01-01T01,4"
Parse timestamp,value rows and aggregate values by UTC hour, returning sorted hour,total lines.
cmsx5vet600fsx3p25hivhepm
contributor_item
Submission IVHEPM
false
def transform(input): lines=[l.split() for l in input.splitlines() if l.strip()];v=sorted({x for l in lines for x in l});m={x:i for i,x in enumerate(v)};return 'vocab='+','.join(v)+'\n'+'\n'.join(' '.join(str(m[x]) for x in l) for l in lines)
red red blue green blue blue
"vocab=blue,green,red\n2 2 0\n1 0 0"
Create an alphabetical vocabulary and encode each input line as space-separated vocabulary indices, returning vocabulary then encoded lines.
cmsx5vet600ftx3p2cnmzwwk4
contributor_item
Submission MZWWK4
false
import json def transform(input): a=json.loads(input);p=None for x in a: x['previous_v']=p;x['delta']=None if p is None else x['v']-p;p=x['v'] return json.dumps(a,separators=(',',':'))
[{"id":1,"v":10},{"id":2,"v":20},{"id":3,"v":15}]
[ { "id": 1, "v": 10, "previous_v": null, "delta": null }, { "id": 2, "v": 20, "previous_v": 10, "delta": 10 }, { "id": 3, "v": 15, "previous_v": 20, "delta": -5 } ]
Parse JSON records, add previous_v and delta fields relative to the preceding record; first record uses nulls; return compact JSON.
cmsx5vet600fwx3p2pvnsh9b1
contributor_item
Submission NSH9B1
false
import json def transform(input): d={} for l in input.splitlines(): x=json.loads(l) for k,v in x.items():d[k]=d.get(k,0)+v return json.dumps(dict(sorted(d.items())),separators=(',',':'))
{"a":1,"b":2,"c":3} {"a":4,"b":5} {"a":6,"c":7}
{ "a": 11, "b": 7, "c": 10 }
Parse JSON Lines and return compact JSON mapping each key to the sum of numeric values across all records.
cmsx5vet600fyx3p2d4wkfoq8
contributor_item
Submission WKFOQ8
false
import json def transform(input): s=[sum(map(int,l.split())) for l in input.splitlines() if l.strip()];return json.dumps({'row_sums':s,'total':sum(s)},separators=(',',':'))
1 2 3 4 5 6
{ "row_sums": [ 6, 9, 6 ], "total": 21 }
Parse whitespace-delimited integer rows of varying length and return compact JSON with each row sum plus a grand total.
cmsx5vet600fvx3p22ch5wnsf
contributor_item
Submission H5WNSF
false
import csv,io def transform(input): d={} for r in csv.DictReader(io.StringIO(input)):d.setdefault(r['dept'],[]).append(int(r['salary'])) a=[(k,sum(v)/len(v)) for k,v in d.items()];a.sort(key=lambda x:(-x[1],x[0]));return '\n'.join(f'{k}={v:.1f}' for k,v in a)
id,dept,salary 1,x,10 2,y,20 3,x,30 4,y,10
"x=20.0\ny=15.0"
Parse CSV, compute average salary by department, and return departments ordered by descending average then name as dept=avg.
cmsx5vet500fox3p28v955446
contributor_item
Submission 955446
false
import csv,io,json def transform(input): r=csv.DictReader(io.StringIO(input));d={k:0 for k in r.fieldnames} for x in r: for k,v in x.items():d[k]+=bool(v) return json.dumps(d,separators=(',',':'))
a,b,c 1,2,3 4,,6 7,8,
{ "a": 3, "b": 2, "c": 2 }
Parse CSV and return compact JSON with per-column count of non-empty data cells, excluding the header.
cmsx5vet500ewx3p2onls2xwc
contributor_item
Submission LS2XWC
false
import json def transform(input): x=json.loads(input);bad=set(x['disabled']);u=[v for v in x['users'] if v['id'] not in bad];u.sort(key=lambda z:z['id']);return json.dumps(u,separators=(',',':'))
{"users":[{"id":2,"name":"Bob"},{"id":1,"name":"Ada"}],"disabled":[2]}
[ { "id": 1, "name": "Ada" } ]
Parse JSON, remove users whose id appears in disabled, sort remaining users by id, and return compact JSON array.
cmsx5vet500evx3p2m5i3x99b
contributor_item
Submission I3X99B
false
import csv,io,json def transform(input): r=csv.DictReader(io.StringIO(input));d={} for x in r: if x['active']!='yes': continue a=d.setdefault(x['team'],{'count':0,'total':0});a['count']+=1;a['total']+=int(x['score']) return json.dumps(dict(sorted(d.items())),separators=(',',':'))
id,team,score,active 1,red,8,yes 2,blue,5,no 3,red,12,yes 4,blue,9,yes
{ "blue": { "count": 1, "total": 9 }, "red": { "count": 2, "total": 20 } }
Parse CSV, keep active rows, group by team, and return compact JSON with count and total score per team sorted by team.
cmsx5vet500eyx3p22i5fpev7
contributor_item
Submission 5FPEV7
false
import urllib.parse,json def transform(input): q=urllib.parse.parse_qs(input,keep_blank_values=True);r={k:(v[0] if len(v)==1 else v) for k,v in q.items()};return json.dumps(dict(sorted(r.items())),separators=(',',':'))
name=Alice&tag=python&tag=data&empty=&city=New+York
{ "city": "New York", "empty": "", "name": "Alice", "tag": [ "python", "data" ] }
Parse a query string preserving repeated values and blank values; flatten single values only; return compact JSON with keys sorted.
cmsx5vet500ezx3p278gkxm70
contributor_item
Submission GKXM70
false
import csv,io,json def transform(input): d={} for r in csv.DictReader(io.StringIO(input),delimiter='|'): a=d.setdefault(r['sku'],[0,0.0]);q=int(r['qty']);a[0]+=q;a[1]+=q*float(r['price']) o={k:{'qty':v[0],'revenue':round(v[1],2)} for k,v in sorted(d.items())};return json.dumps(o,separators=(',',':'))
sku|qty|price A|2|3.50 B|1|10.00 A|3|3.50
{ "A": { "qty": 5, "revenue": 17.5 }, "B": { "qty": 1, "revenue": 10 } }
Parse pipe-delimited rows, aggregate quantity and extended revenue by SKU, and return sorted compact JSON rounding revenue to 2 decimals.
cmsx5vet500f4x3p2ct2u522a
contributor_item
Submission 2U522A
false
def transform(input): vals=[] for l in input.splitlines(): d,v=l.split(',',1) try:vals.append((d,float(v))) except:pass out=['date,delta'] for i in range(1,len(vals)):out.append(f'{vals[i][0]},{vals[i][1]-vals[i-1][1]:g}') return '\n'.join(out)
2026-01-01,10 2026-01-02,bad 2026-01-03,15 2026-01-04,20
"date,delta\n2026-01-03,5\n2026-01-04,5"
Parse date,value lines, skip non-numeric values, compute deltas between consecutive valid readings, and return CSV.
cmsx5vet500f3x3p29yllgfr6
contributor_item
Submission LLGFR6
false
import json,csv,io def transform(input): rows=[] for x in json.loads(input): for t in x['tags']:rows.append((x['id'],t)) rows.sort();o=io.StringIO();w=csv.writer(o,lineterminator='\n');w.writerow(['id','tag']);w.writerows(rows);return o.getvalue().strip()
[{"id":1,"tags":["a","b"]},{"id":2,"tags":[]},{"id":3,"tags":["b"]}]
"id,tag\n1,a\n1,b\n3,b"
Expand each JSON object into one row per tag, skip objects with no tags, and return CSV sorted by id then tag.
cmsx5vet500f7x3p2l20h61g5
contributor_item
Submission 0H61G5
false
import json def transform(input): d={} for l in input.splitlines(): level,svc,_=l.split('|');d.setdefault(svc,{})[level]=d.setdefault(svc,{}).get(level,0)+1 return json.dumps({k:dict(sorted(v.items())) for k,v in sorted(d.items())},separators=(',',':'))
INFO|api|10 WARN|web|20 ERROR|api|30 ERROR|web|40 WARN|api|50
{ "api": { "ERROR": 1, "INFO": 1, "WARN": 1 }, "web": { "ERROR": 1, "WARN": 1 } }
Parse pipe records and return compact JSON per service with counts by level, omitting zero-count levels.
cmsx5vet500fkx3p2j7oqzs3b
contributor_item
Submission OQZS3B
false
import json def transform(input): a=json.loads(input)['items'];g=0 for x in a:x['line_total']=x['price']*x['qty'];g+=x['line_total'] a.append({'grand_total':g});return json.dumps(a,separators=(',',':'))
{"items":[{"name":"a","price":10,"qty":2},{"name":"b","price":5,"qty":3}]}
[ { "name": "a", "price": 10, "qty": 2, "line_total": 20 }, { "name": "b", "price": 5, "qty": 3, "line_total": 15 }, { "grand_total": 35 } ]
Parse JSON items, add line_total=price*qty to each item and append a final summary object with grand_total, returning compact JSON.
cmsx5vet500fjx3p2xw2f47zt
contributor_item
Submission 2F47ZT
false
import csv,io,json def transform(input): a=sorted((int(r['start']),int(r['end'])) for r in csv.DictReader(io.StringIO(input)));m=[] for s,e in a: if not m or s>m[-1][1]:m.append([s,e]) else:m[-1][1]=max(m[-1][1],e) return json.dumps(m,separators=(',',':'))
id,start,end 1,1,4 2,3,6 3,8,10
[ [ 1, 6 ], [ 8, 10 ] ]
Parse intervals from CSV, merge overlapping intervals, and return compact JSON array of merged [start,end] pairs.
cmsx5vet500fqx3p2khfvtwnz
contributor_item
Submission FVTWNZ
false
import json def transform(input): a=json.loads(input)['matrix'];t=[list(x) for x in zip(*a)] if a else [];return json.dumps({'matrix':t},separators=(',',':'))
{"matrix":[[1,2,3],[4,5,6]]}
{ "matrix": [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] }
Transpose the rectangular matrix in JSON and return compact JSON under key matrix.
cmsx5vet600frx3p2uec0bdra
contributor_item
Submission C0BDRA
false
import csv,io,json def transform(input): d={} for r in csv.DictReader(io.StringIO(input)): a=d.setdefault(r['host'],{'total':0,'errors':0});a['total']+=1;a['errors']+=int(r['status'])>=500 return json.dumps(dict(sorted(d.items())),separators=(',',':'))
host,status api,200 web,500 api,503 web,200 api,200
{ "api": { "total": 3, "errors": 1 }, "web": { "total": 2, "errors": 1 } }
Parse CSV and return compact JSON per host with total requests and error count where status >= 500.
cmsx5vet600fux3p2nodnfir9
contributor_item
Submission DNFIR9
false
import json def transform(input): d={} for p in input.split(';'): if '=' in p: k,v=p.split('=',1);d[k]=v return json.dumps(dict(sorted(d.items())),separators=(',',':'))
A=1;B=2;C=hello=world;D=
{ "A": "1", "B": "2", "C": "hello=world", "D": "" }
Parse semicolon-delimited key=value pairs splitting only on the first '=', preserve empty values, and return sorted compact JSON.
cmsx5vet600fxx3p2u67530vz
contributor_item
Submission 7530VZ
false
import csv,io,json def transform(input): a=[{'path':r['path'],'size':int(r['size'])} for r in csv.DictReader(io.StringIO(input))];a.sort(key=lambda x:(-x['size'],x['path']));return json.dumps(a[:2],separators=(',',':'))
path,size /a,10 /b,25 /c,5 /d,25
[ { "path": "/b", "size": 25 }, { "path": "/d", "size": 25 } ]
Parse CSV and return the two largest files as compact JSON sorted by size descending then path ascending.
cmsx5vet500ffx3p2s9cjit0s
contributor_item
Submission CJIT0S
false
import csv,io,json def transform(input): a=list(csv.DictReader(io.StringIO(input)));ids={r['id'] for r in a};d={} for r in a: p=r['parent'] if p and p in ids:d.setdefault(p,[]).append(int(r['id'])) return json.dumps({k:sorted(v) for k,v in sorted(d.items(),key=lambda x:int(x[0]))},separators=(',',':'))
id,parent 1, 2,1 3,1 4,2 5,9
{ "1": [ 2, 3 ], "2": [ 4 ] }
Parse CSV parent relations; return compact JSON mapping each existing parent id to sorted child ids, ignoring references to missing parents.
cmsx5vet500fix3p2w471gfpt
contributor_item
Submission 71GFPT
false
import json def transform(input): r={} for l in input.splitlines(): k,v=[x.strip() for x in l.split(':',1)] if v=='true':z=True elif v=='false':z=False elif v=='null':z=None else: try:z=int(v) except:z=v r[k]=z return json.dumps(r,separators=(',',':'))
alpha: 1 beta: true gamma: null delta: text
{ "alpha": 1, "beta": true, "gamma": null, "delta": "text" }
Parse simple key: value lines and coerce integers, true/false, and null to native JSON types while leaving other values as strings.
cmsx5vet500fhx3p2cnnf4o8p
contributor_item
Submission NF4O8P
false
import json def transform(input): x=json.loads(input);r={str(v):k for k,vs in x.items() for v in vs};return json.dumps(dict(sorted(r.items(),key=lambda z:int(z[0]))),separators=(',',':'))
{"a":[1,2],"b":[3],"c":[]}
{ "1": "a", "2": "a", "3": "b" }
Invert a JSON mapping of group -> values into value-string -> group, skipping empty lists, and return compact JSON sorted numerically by value.
cmsx5vet500fgx3p2kba0l4ky
contributor_item
Submission A0L4KY
false
def transform(input): d={} for l in input.splitlines(): k,v,s=l.split(',') if s=='ok':d.setdefault(k,[]).append(float(v)) return '\n'.join(f'{k}={sum(v)/len(v):.1f}' for k,v in sorted(d.items()))
A,10,ok B,20,fail A,30,ok B,40,ok
"A=20.0\nB=40.0"
Parse comma rows without header, keep status ok, compute average numeric value per key, and return sorted key=average lines with one decimal.
cmsx5vet500fmx3p2v3m1xgse
contributor_item
Submission M1XGSE
false
import csv,io def transform(input): d={r['id']:r['value'] for r in csv.DictReader(io.StringIO(input))};return 'id,value\n'+'\n'.join(f'{k},{d[k]}' for k in sorted(d,key=int))
id,value 3,c 1,a 2,b 2,B
"id,value\n1,a\n2,B\n3,c"
Parse CSV, keep the last row for each id, then emit CSV sorted numerically by id.
cmsx5vet500flx3p2kohzqzs9
contributor_item
Submission HZQZS9
false
import json def transform(input): d={} for l in input.splitlines(): g,vs=l.split('|',1) for v in filter(None,vs.split(',')):d.setdefault(v,[]).append(g) return json.dumps({k:sorted(v) for k,v in sorted(d.items())},separators=(',',':'))
A|x,y,z B|y C|x,z
{ "x": [ "A", "C" ], "y": [ "A", "B" ], "z": [ "A", "C" ] }
Parse group|comma-values rows and return compact JSON mapping each value to sorted groups containing it.
cmsx5vet500fnx3p2zp1kdued
contributor_item
Submission 1KDUED
false
import json,statistics def transform(input): a=json.loads(input);a.remove(min(a));a.remove(max(a));a.sort();return json.dumps({'values':a,'median':statistics.median(a)},separators=(',',':'))
[5,1,9,3,7,2]
{ "values": [ 2, 3, 5, 7 ], "median": 4 }
Parse numeric JSON array, remove min and max values once each, then return compact JSON with remaining sorted values and their median.
cmsx5vet500exx3p2drcjt8yo
contributor_item
Submission CJT8YO
false
from collections import Counter def transform(input): c=Counter() for l in input.splitlines(): p=l.split() if len(p)>=4 and p[1]=='ERROR': c[p[2]]+=1 return '\n'.join(f'{k}={v}' for k,v in sorted(c.items(),key=lambda x:(-x[1],x[0])))
2026-01-01T08:00:00Z INFO api start 2026-01-01T08:01:00Z ERROR api fail 2026-01-01T08:02:00Z ERROR web bad 2026-01-01T08:03:00Z ERROR api retry
"api=2\nweb=1"
Parse space-separated logs, count ERROR events per service, sort by descending count then service, and return lines 'service=count'.
cmsx5vet500f0x3p2p59mbfba
contributor_item
Submission 9MBFBA
false
import json def transform(input): a=json.loads(input);seen=set();u=[] for x in a: if x not in seen:seen.add(x);u.append(x) s=0;c=[] for x in u:s+=x;c.append(s) return json.dumps({'values':u,'cumulative':c},separators=(',',':'))
[1,2,2,3,4,4,4,5]
{ "values": [ 1, 2, 3, 4, 5 ], "cumulative": [ 1, 3, 6, 10, 15 ] }
Parse a JSON integer array, remove duplicates while preserving first occurrence, then return compact JSON containing values and their cumulative sums.
cmsx5vet500f2x3p20nb6c06v
contributor_item
Submission B6C06V
false
def transform(input): d={} for l in input.splitlines(): l=l.strip() if not l or l.startswith('#') or ':' not in l:continue k,v=l.split(':',1);d[k]=int(v) return '\n'.join(f'{k}={d[k]}' for k in sorted(d))
a:1 b:2 a:3 #ignore c:4
"a=3\nb=2\nc=4"
Parse key:value lines ignoring comments; for duplicate keys keep the last integer value and return sorted key=value lines.
cmsx5vet500f1x3p21yn62b6z
contributor_item
Submission N62B6Z
false
import csv,io,json def transform(input): d={} for r in csv.DictReader(io.StringIO(input)):d.setdefault(r['user'],[]).append(r['event']) return json.dumps(dict(sorted(d.items())),separators=(',',':'))
user,event u1,login u2,login u1,click u1,logout u2,click
{ "u1": [ "login", "click", "logout" ], "u2": [ "login", "click" ] }
Parse CSV and build per-user ordered event histories, returning compact JSON sorted by user id.
cmsx5vet500f6x3p2w0b0lfit
contributor_item
Submission B0LFIT
false
import csv,io def transform(input): a=list(csv.DictReader(io.StringIO(input)));scores=sorted({int(x['score']) for x in a},reverse=True);rank={s:1+sum(1 for x in a if int(x['score'])>s) for s in scores};a.sort(key=lambda x:(rank[int(x['score'])],x['name']));return 'name,score,rank\n'+'\n'.join(f"{x['name']},{x['score']...
name,score Alice,90 Bob,75 Cara,90 Dan,60
"name,score,rank\nAlice,90,1\nCara,90,1\nBob,75,3\nDan,60,4"
Parse CSV, assign rank by descending score with equal scores sharing a rank and gaps after ties, then return CSV sorted by rank then name.
cmsx5vet500f5x3p287qhszvi
contributor_item
Submission QHSZVI
false
import json def transform(input): x=json.loads(input);r={} for k,v in x.items(): if isinstance(v,dict): for q,z in v.items():r[f'{k}.{q}']=z else:r[k]=v return json.dumps(dict(sorted(r.items())),separators=(',',':'))
{"a":{"x":1,"y":2},"b":{"x":3},"c":4}
{ "a.x": 1, "a.y": 2, "b.x": 3, "c": 4 }
Flatten a nested JSON object one level using dot-separated keys, preserving scalar top-level values, and return compact JSON with sorted keys.
cmsx5vet500fax3p24vnuksmw
contributor_item
Submission NUKSMW
false
import csv,io def transform(input): d={} for r in csv.DictReader(io.StringIO(input)):d[r['category']]=d.get(r['category'],0)+float(r['amount']) return '\n'.join(f'{k}={v:.2f}' for k,v in sorted(d.items(),key=lambda x:(-x[1],x[0])))
category,amount food,10.5 travel,20 food,-2.5 travel,5
"travel=25.00\nfood=8.00"
Parse CSV, sum amounts by category including negatives, sort categories by descending total then name, and return lines category=total with 2 decimals.
cmsx5vet500f8x3p23qtdh8gq
contributor_item
Submission TDH8GQ
false
import json def transform(input): d={} for x in json.loads(input):d.setdefault(x['k'],[]).append(x['v']) return json.dumps(dict(sorted(d.items())),separators=(',',':'))
[{"k":"a","v":1},{"k":"b","v":2},{"k":"a","v":4}]
{ "a": [ 1, 4 ], "b": [ 2 ] }
Parse records and pivot them into key -> list of values preserving input order, returning compact sorted-key JSON.
cmsx5vet500fex3p2ba86mrbt
contributor_item
Submission 86MRBT
false
import json def transform(input): a=json.loads(input);a.sort(key=lambda x:(x['ts'],x['id']));return json.dumps(a,separators=(',',':'))
[{"ts":3,"id":"a"},{"ts":1,"id":"b"},{"ts":3,"id":"c"},{"ts":2,"id":"d"}]
[ { "ts": 1, "id": "b" }, { "ts": 2, "id": "d" }, { "ts": 3, "id": "a" }, { "ts": 3, "id": "c" } ]
Sort JSON records by timestamp ascending and then id ascending, returning compact JSON.
cmsx5vet500fdx3p2z07nb5sa
contributor_item
Submission 7NB5SA
false
import json def transform(input): d={} for l in input.splitlines(): if '=' not in l:continue k,v=l.split('=',1) try:d[k]=d.get(k,0)+int(v) except:pass return json.dumps(dict(sorted(d.items())),separators=(',',':'))
x=1 y=2 x=4 badline z=3
{ "x": 5, "y": 2, "z": 3 }
Parse key=value integer records, ignore malformed lines, sum repeated keys rather than overwrite, and return sorted compact JSON.
cmsx5vet500fcx3p24q1irq7r
contributor_item
Submission 1IRQ7R
false
import json from collections import Counter def transform(input): c=Counter(input.split());a=sorted(c.items(),key=lambda x:(-x[1],x[0]))[:2];return json.dumps([{'word':k,'count':v} for k,v in a],separators=(',',':'))
apple apple banana banana carrot apple carrot carrot
[ { "word": "apple", "count": 3 }, { "word": "carrot", "count": 3 } ]
Tokenize whitespace-separated words, count frequencies, and return the top 2 as compact JSON objects sorted by count desc then word asc.
cmsx5vet500fbx3p2lij7wacp
contributor_item
Submission J7WACP
false
import json def transform(input): x=json.loads(input)['rows'];r=[a for a in x if 'v' in a and a['v'] is not None];r.sort(key=lambda z:z['id']);return json.dumps(r,separators=(',',':'))
{"rows":[{"id":1,"v":null},{"id":2,"v":3},{"id":3},{"id":4,"v":0}]}
[ { "id": 2, "v": 3 }, { "id": 4, "v": 0 } ]
Parse JSON, keep rows where v exists and is not null, retain zero, and return compact JSON sorted by id.
cmsx7xmlq0031kup2q2gfm86b
contributor_item
Submission GFM86B
false
from collections import Counter def transform(input): c=Counter() for l in input.splitlines(): level,svc,_=l.split('|',2) if level=='ERROR': c[svc]+=1 return '\n'.join(f'{k}={v}' for k,v in sorted(c.items(),key=lambda x:(-x[1],x[0])))
INFO|api|start ERROR|api|fail WARN|web|slow ERROR|web|bad ERROR|api|retry
"api=2\nweb=1"
Parse pipe-delimited logs, count ERROR events by service, and return lines service=count sorted by descending count then service.
cmsx7xmlq003kkup2ijppb38g
contributor_item
Submission PPB38G
false
def transform(input): lines=[l.split() for l in input.splitlines() if l.strip()]; vocab=sorted({x for line in lines for x in line}); idx={x:i for i,x in enumerate(vocab)} return 'vocab='+','.join(vocab)+'\n'+'\n'.join(' '.join(str(idx[x]) for x in line) for line in lines)
red red blue green blue blue
"vocab=blue,green,red\n2 2 0\n1 0 0"
Build an alphabetical vocabulary from all tokens and encode each input line as space-separated vocabulary indices, returning vocabulary then encoded lines.
cmsx7xmlq002xkup23yyjgejo
contributor_item
Submission YJGEJO
false
import csv,io,json def transform(input): rows=list(csv.DictReader(io.StringIO(input))); ids={r['id'] for r in rows}; d={} for r in rows: p=r['parent'] if p and p in ids: d.setdefault(p,[]).append(int(r['id'])) return json.dumps({k:sorted(v) for k,v in sorted(d.items(),key=lambda x:int(x[0]))},separators=(',',':'...
id,parent 1, 2,1 3,1 4,2 5,9
{ "1": [ 2, 3 ], "2": [ 4 ] }
Parse parent-child CSV, ignore children whose parent id does not exist, and return compact JSON mapping each existing parent to sorted child ids.
cmsx7xmlq002zkup2s71jqtsh
contributor_item
Submission 1JQTSH
false
import csv,io,json def transform(input): d={} for r in csv.DictReader(io.StringIO(input)): q=int(r['qty']); p=float(r['price']); a=d.setdefault(r['sku'],{'qty':0,'revenue':0.0}); a['qty']+=q; a['revenue']+=q*p for a in d.values(): a['revenue']=round(a['revenue'],2) return json.dumps(dict(sorted(d.items())),separa...
sku,qty,price A,2,3.5 B,1,10 A,3,3.5
{ "A": { "qty": 5, "revenue": 17.5 }, "B": { "qty": 1, "revenue": 10 } }
Parse CSV, aggregate quantity and revenue by SKU, round revenue to 2 decimals, and return compact JSON sorted by SKU.
cmsx7xmlq0030kup2twqqrxgt
contributor_item
Submission QQRXGT
false
import json def transform(input): x=json.loads(input); bad=set(x['blocked']); d={} for u in x['users']: if u['id'] in bad: continue d.setdefault(u['role'],[]).append(u['id']) return json.dumps({k:sorted(v) for k,v in sorted(d.items())},separators=(',',':'))
{"users":[{"id":1,"role":"admin"},{"id":2,"role":"user"},{"id":3,"role":"admin"}],"blocked":[3]}
{ "admin": [ 1 ], "user": [ 2 ] }
Parse JSON, exclude blocked user ids, group remaining ids by role, sort ids within each role, and return compact JSON sorted by role.
cmsx7xmlq0035kup2d8xo0vo0
contributor_item
Submission XO0VO0
false
import json def transform(input): a=json.loads(input); a.sort(key=lambda x:(-x['size'],x['path'])); return json.dumps(a[:2],separators=(',',':'))
[{"path":"/a","size":10},{"path":"/b","size":25},{"path":"/c","size":25},{"path":"/d","size":5}]
[ { "path": "/b", "size": 25 }, { "path": "/c", "size": 25 } ]
Parse JSON file records, keep the two largest files sorted by size descending then path ascending, and return compact JSON.
cmsx7xmlq0037kup2hmj79ksu
contributor_item
Submission J79KSU
false
import json def transform(input): a=json.loads(input)['rows']; r=[x for x in a if 'v' in x and x['v'] is not None]; r.sort(key=lambda x:x['id']); return json.dumps(r,separators=(',',':'))
{"rows":[{"id":1,"v":null},{"id":2,"v":3},{"id":3},{"id":4,"v":0}]}
[ { "id": 2, "v": 3 }, { "id": 4, "v": 0 } ]
Parse JSON rows, keep those where v exists and is not null while preserving zero, sort by id, and return compact JSON.
cmsx7xmlq0034kup2f17zw82i
contributor_item
Submission 7ZW82I
false
import csv,io def transform(input): a=list(csv.DictReader(io.StringIO(input))); scores=sorted({int(r['score']) for r in a},reverse=True); rank={s:1+sum(1 for r in a if int(r['score'])>s) for s in scores}; a.sort(key=lambda r:(rank[int(r['score'])],r['name'])) return 'name,score,rank\n'+'\n'.join(f"{r['name']},{r['sco...
name,score Ada,90 Bob,75 Cara,90 Dan,60
"name,score,rank\nAda,90,1\nCara,90,1\nBob,75,3\nDan,60,4"
Parse CSV, assign competition ranks by score descending with gaps after ties, then return CSV sorted by rank then name.
cmsx7xmlq0038kup23d8gvfau
contributor_item
Submission 8GVFAU
false
import csv,io def transform(input): vals=[] for r in csv.DictReader(io.StringIO(input)): try: vals.append((r['date'],float(r['value']))) except: pass out=['date,delta'] for i in range(1,len(vals)): out.append(f'{vals[i][0]},{vals[i][1]-vals[i-1][1]:g}') return '\n'.join(out)
date,value 2026-01-01,10 2026-01-02,bad 2026-01-03,15 2026-01-04,20
"date,delta\n2026-01-03,5\n2026-01-04,5"
Parse CSV, skip rows whose value is not numeric, compute deltas between consecutive valid readings, and return CSV with date,delta.
cmsx7xmlq003dkup21e4bdi5w
contributor_item
Submission 4BDI5W
false
import json,statistics def transform(input): a=json.loads(input)['values']; a.remove(min(a)); a.remove(max(a)); a.sort(); return json.dumps({'values':a,'median':statistics.median(a)},separators=(',',':'))
{"values":[5,1,9,3,7,2]}
{ "values": [ 2, 3, 5, 7 ], "median": 4 }
Parse numeric JSON array, remove one occurrence each of the minimum and maximum, sort remaining values, and return compact JSON with values plus median.
cmsx7xmlq003ckup2c2l3jckf
contributor_item
Submission L3JCKF
false
import csv,io def transform(input): d={r['id']:r['value'] for r in csv.DictReader(io.StringIO(input))} return 'id,value\n'+'\n'.join(f'{k},{d[k]}' for k in sorted(d,key=int))
id,value 3,c 1,a 2,b 2,B
"id,value\n1,a\n2,B\n3,c"
Parse CSV, keep the last row for each id, then emit CSV sorted numerically by id.
cmsx7xmlq003ikup2rwc7im5c
contributor_item
Submission C7IM5C
false
import json def transform(input): d={} for e in json.loads(input)['events']: a=d.setdefault(e['type'],{'count':0,'total':0}); a['count']+=1; a['total']+=e['value'] return json.dumps(dict(sorted(d.items())),separators=(',',':'))
{"events":[{"type":"x","value":3},{"type":"y","value":2},{"type":"x","value":5}]}
{ "x": { "count": 2, "total": 8 }, "y": { "count": 1, "total": 2 } }
Group JSON events by type and return compact JSON with count and total value per type, sorted by type.
cmsx7xmlq003jkup2cy3ch8ch
contributor_item
Submission 3CH8CH
false
import csv,io,json def transform(input): d={} for r in csv.DictReader(io.StringIO(input)): a=d.setdefault(r['host'],{'total':0,'errors':0}); a['total']+=1; a['errors']+=int(r['status'])>=500 return json.dumps(dict(sorted(d.items())),separators=(',',':'))
host,status api,200 web,500 api,503 web,200 api,200
{ "api": { "total": 3, "errors": 1 }, "web": { "total": 2, "errors": 1 } }
Parse CSV and return compact JSON per host with total request count and error count where status >= 500, sorted by host.
cmsx7xmlq003lkup29pmfsxy4
contributor_item
Submission MFSXY4
false
import json def transform(input): a=[x for x in json.loads(input)['records'] if x['score']>=7]; a.sort(key=lambda x:(-x['score'],x['id'])); return json.dumps([x['id'] for x in a],separators=(',',':'))
{"records":[{"id":1,"score":9},{"id":2,"score":4},{"id":3,"score":9},{"id":4,"score":7}]}
[ 1, 3, 4 ]
Parse JSON records, keep those with score at least 7, sort by score descending then id ascending, and return compact JSON array of ids.
cmsx7xmlp002skup2eelgf62w
contributor_item
Submission LGF62W
false
import csv,io,json def transform(input): d={} for r in csv.DictReader(io.StringIO(input)): if r['status']!='ok': continue d[r['region']]=d.get(r['region'],0)+int(r['amount']) return json.dumps(dict(sorted(d.items())),separators=(',',':'))
user,region,amount,status u1,us,10,ok u2,eu,20,fail u3,us,15,ok u4,eu,5,ok
{ "eu": 5, "us": 25 }
Parse CSV, keep only status=ok rows, aggregate amount by region, and return compact JSON sorted by region.
cmsx7xmlp002vkup2ggwi1n0g
contributor_item
Submission WI1N0G
false
import json,csv,io def transform(input): rows=[] for o in json.loads(input): for t in o['tags']: rows.append((t,o['name'])) rows.sort() s=io.StringIO(); w=csv.writer(s,lineterminator='\n'); w.writerow(['tag','name']); w.writerows(rows) return s.getvalue().strip()
[{"name":"A","tags":["x","y"]},{"name":"B","tags":["y"]},{"name":"C","tags":[]}]
"tag,name\nx,A\ny,A\ny,B"
Expand each object into one row per tag, omit empty tag lists, and return CSV sorted by tag then name.
cmsx7xmlq003akup2olap7acy
contributor_item
Submission AP7ACY
false
import json def transform(input): a=json.loads(input)['items']; total=0 for x in a: x['line_total']=x['price']*x['qty']; total+=x['line_total'] a.append({'grand_total':total}); return json.dumps(a,separators=(',',':'))
{"items":[{"name":"a","price":10,"qty":2},{"name":"b","price":5,"qty":3}]}
[ { "name": "a", "price": 10, "qty": 2, "line_total": 20 }, { "name": "b", "price": 5, "qty": 3, "line_total": 15 }, { "grand_total": 35 } ]
Parse JSON items, add line_total=price*qty to each item, append a final grand_total object, and return compact JSON.
cmsx7xmlq002ykup21bwtdpcg
contributor_item
Submission WTDPCG
false
import json def transform(input): a=json.loads(input)['matrix']; r=[list(x) for x in zip(*a[::-1])] if a else [] return json.dumps({'matrix':r},separators=(',',':'))
{"matrix":[[1,2,3],[4,5,6],[7,8,9]]}
{ "matrix": [ [ 7, 4, 1 ], [ 8, 5, 2 ], [ 9, 6, 3 ] ] }
Parse JSON matrix, rotate it 90 degrees clockwise, and return compact JSON under key matrix.
cmsx7xmlp002tkup23pqxgsac
contributor_item
Submission QXGSAC
false
import json def transform(input): x=json.loads(input)['orders'] a=[o for o in x if o['paid']] a.sort(key=lambda o:(-o['total'],o['id'])) return json.dumps([o['id'] for o in a],separators=(',',':'))
{"orders":[{"id":1,"total":25,"paid":true},{"id":2,"total":40,"paid":false},{"id":3,"total":15,"paid":true}]}
[ 1, 3 ]
Parse JSON orders, keep paid orders, sort by total descending then id ascending, and return compact JSON array of ids only.
cmsx7xmlp002ukup28yvpjv6e
contributor_item
Submission VPJV6E
false
def transform(input): d={} for l in input.splitlines(): l=l.strip() if not l or l.startswith('#') or '=' not in l: continue k,v=l.split('=',1); d[k]=d.get(k,0)+int(v) return '\n'.join(f'{k}={d[k]}' for k in sorted(d))
alpha=1 beta=2 alpha=4 # ignored gamma=3
"alpha=5\nbeta=2\ngamma=3"
Parse key=value lines ignoring comments and blanks, sum repeated integer keys, and return sorted key=value lines.
cmsx7xmlq002wkup2rvgwm2oi
contributor_item
Submission GWM2OI
false
import json from datetime import datetime def transform(input): d={} for l in input.splitlines(): t,s,v=l.split(','); h=datetime.fromisoformat(t.replace('Z','+00:00')).strftime('%Y-%m-%dT%H'); k=h+'|'+s; d[k]=d.get(k,0)+int(v) return json.dumps(dict(sorted(d.items())),separators=(',',':'))
2026-01-01T10:15:00Z,api,5 2026-01-01T10:45:00Z,api,7 2026-01-01T11:10:00Z,web,3
{ "2026-01-01T10|api": 12, "2026-01-01T11|web": 3 }
Parse timestamp,service,value rows, aggregate values by UTC hour and service, and return compact JSON with keys hour|service sorted lexicographically.
cmsx7xmlq0033kup2tms4zwjm
contributor_item
Submission S4ZWJM
false
import json def transform(input): d={} for l in input.splitlines(): g,vals=l.split('|',1) for v in filter(None,vals.split(',')): d.setdefault(v,[]).append(g) return json.dumps({k:sorted(v) for k,v in sorted(d.items())},separators=(',',':'))
a|x,y,z b|y c|x,z
{ "x": [ "a", "c" ], "y": [ "a", "b" ], "z": [ "a", "c" ] }
Parse group|comma-values rows and invert them into value -> sorted groups, returning compact JSON sorted by value.
cmsx7xmlq0032kup22pgegcw1
contributor_item
Submission GEGCW1
false
import json def transform(input): a=json.loads(input); prev=None for x in a: x['previous_v']=prev; x['delta']=None if prev is None else x['v']-prev; prev=x['v'] return json.dumps(a,separators=(',',':'))
[{"id":1,"v":10},{"id":2,"v":15},{"id":3,"v":12}]
[ { "id": 1, "v": 10, "previous_v": null, "delta": null }, { "id": 2, "v": 15, "previous_v": 10, "delta": 5 }, { "id": 3, "v": 12, "previous_v": 15, "delta": -3 } ]
Parse JSON records and add previous_v plus delta relative to the preceding record; first record uses nulls. Return compact JSON.
cmsx7xmlq0036kup26xe0bqpu
contributor_item
Submission E0BQPU
false
def transform(input): d={} for l in input.splitlines(): k,v,s=l.split(',') if s=='ok': d.setdefault(k,[]).append(float(v)) return '\n'.join(f'{k}={sum(v)/len(v):.1f}' for k,v in sorted(d.items()))
a,1,ok b,2,fail a,3,ok b,5,ok
"a=2.0\nb=5.0"
Parse key,value,status rows without header, keep status ok, compute average value per key, and return sorted key=average lines with one decimal.
cmsx7xmlq003bkup2xqj9497y
contributor_item
Submission J9497Y
false
import json def transform(input): x=json.loads(input)['groups']; r={str(v):k for k,vals in x.items() for v in vals}; return json.dumps(dict(sorted(r.items(),key=lambda p:int(p[0]))),separators=(',',':'))
{"groups":{"a":[1,2],"b":[3],"c":[]}}
{ "1": "a", "2": "a", "3": "b" }
Invert JSON mapping group -> integer list into integer-string -> group, skip empty lists, and return compact JSON sorted numerically by key.
cmsx7xmlq003fkup2t7m6k1l9
contributor_item
Submission M6K1L9
false
import json def transform(input): d={} for x in json.loads(input)['rows']: d.setdefault(x['k'],[]).append(x['v']) return json.dumps(dict(sorted(d.items())),separators=(',',':'))
{"rows":[{"k":"a","v":1},{"k":"b","v":2},{"k":"a","v":4}]}
{ "a": [ 1, 4 ], "b": [ 2 ] }
Pivot JSON records into key -> list of values preserving original order, and return compact JSON sorted by key.
cmsx7xmlq003ekup2tjz7m4ck
contributor_item
Submission Z7M4CK
false
import csv,io,json def transform(input): r=csv.DictReader(io.StringIO(input)); d={k:0 for k in r.fieldnames} for row in r: for k,v in row.items(): d[k]+=bool(v) return json.dumps(d,separators=(',',':'))
a,b,c 1,2,3 4,,6 7,8,
{ "a": 3, "b": 2, "c": 2 }
Parse CSV and return compact JSON containing the count of non-empty data cells per column.
cmsx7xmlq003hkup2o857f2ne
contributor_item
Submission 57F2NE
false
import csv,io,json def transform(input): a=sorted((int(r['start']),int(r['end'])) for r in csv.DictReader(io.StringIO(input))); m=[] for s,e in a: if not m or s>m[-1][1]: m.append([s,e]) else: m[-1][1]=max(m[-1][1],e) return json.dumps(m,separators=(',',':'))
id,start,end 1,1,4 2,3,6 3,8,10
[ [ 1, 6 ], [ 8, 10 ] ]
Parse intervals from CSV, merge overlaps, and return compact JSON array of merged [start,end] pairs.
cmsx7xmlq003gkup20j2cuwcz
contributor_item
Submission 2CUWCZ
false
import json def transform(input): r={} for l in input.splitlines(): k,v=[x.strip() for x in l.split(':',1)] if v=='true': z=True elif v=='false': z=False elif v=='null': z=None else: try: z=int(v) except: z=v r[k]=z return json.dumps(r,separators=(',',':'))
alpha: 1 beta: true gamma: null delta: text
{ "alpha": 1, "beta": true, "gamma": null, "delta": "text" }
Parse simple key: value lines and coerce integers, true/false, and null to native JSON types; leave other values as strings.
cmsx7xmlq0039kup2rn0o76ob
contributor_item
Submission 0O76OB
false
import json def transform(input): x=json.loads(input); r={} for k,v in x.items(): if isinstance(v,dict): for q,z in v.items(): r[f'{k}.{q}']=z else: r[k]=v return json.dumps(dict(sorted(r.items())),separators=(',',':'))
{"a":{"x":1,"y":2},"b":{"z":3},"c":4}
{ "a.x": 1, "a.y": 2, "b.z": 3, "c": 4 }
Flatten a JSON object one level using dot-separated keys, preserve scalar top-level values, and return compact JSON with sorted keys.
cmsx8ire80047kup25nneoaqq
contributor_item
Submission NEOAQQ
false
import json def transform(text): result = {} section = None for line in text.strip().split('\n'): line = line.strip() if not line or line.startswith('#'): continue if line.startswith('[') and line.endswith(']'): section = line[1:-1] result[section...
[server] host=localhost port=8080 [db] name=voicemart user=admin
{ "server": { "host": "localhost", "port": "8080" }, "db": { "name": "voicemart", "user": "admin" } }
Convert an INI-style config text (sections in [brackets], key=value lines) into a nested JSON object.
cmsx8ire80049kup254u2x8av
contributor_item
Submission U2X8AV
false
import csv, io, json def transform(text): reader = csv.DictReader(io.StringIO(text.strip())) result = {row['key']: row['value'] for row in reader} return json.dumps(result)
key,value hostname,voicemart-01 region,us-east tier,production
{ "hostname": "voicemart-01", "region": "us-east", "tier": "production" }
Merge two equal-length CSV columns (keys, values) given as a single CSV with headers 'key,value' into a single-line JSON object.
cmsx8ire8004ckup2fyo5m06s
contributor_item
Submission O5M06S
false
import csv, io, json def transform(text): reader = csv.DictReader(io.StringIO(text.strip())) credits = debits = 0.0 for row in reader: amt = float(row['amount']) if amt >= 0: credits += amt else: debits += amt return json.dumps({ "total_credits": ...
date,amount 2026-01-01,150.00 2026-01-02,-42.50 2026-01-03,-10.00 2026-01-04,300.25
{ "total_credits": 450.25, "total_debits": -52.5, "net_balance": 397.75 }
Given a CSV of transactions (date,amount) where amount can be negative, output a JSON object with total_credits, total_debits, and net_balance (all rounded to 2 decimals).
cmsx8ire8004akup23b5qerye
contributor_item
Submission 5QERYE
false
import json def transform(text): data = json.loads(text) for d in data: d['tags'] = [t.strip() for t in d['tags'].split(',') if t.strip()] return json.dumps(data)
[{"id": 1, "tags": "urgent, backend, bug"}, {"id": 2, "tags": "frontend"}]
[ { "id": 1, "tags": [ "urgent", "backend", "bug" ] }, { "id": 2, "tags": [ "frontend" ] } ]
Given a JSON array of objects with a 'tags' field (comma-separated string), split tags into a list and return the transformed JSON array.
cmsx8ire8004hkup2kopoufhq
contributor_item
Submission POUFHQ
false
import json from collections import defaultdict def transform(text): lines = [l for l in text.strip().split('\n') if l] result = defaultdict(list) for l in lines: k, v = l.split('=', 1) result[k.strip()].append(v.strip()) return json.dumps(dict(result))
tag=urgent tag=backend owner=alice tag=bug owner=bob
{ "tag": [ "urgent", "backend", "bug" ], "owner": [ "alice", "bob" ] }
Given lines of 'key=value' pairs where some keys repeat, collect all values for each key into a JSON object mapping key to a list of values.
cmsx8ire8004ikup255gworub
contributor_item
Submission GWORUB
false
import csv, io, json def transform(text): reader = csv.DictReader(io.StringIO(text.strip())) result = [] for row in reader: scores = [float(row['math']), float(row['science']), float(row['english'])] avg = round(sum(scores) / len(scores), 1) result.append({"name": row['name'], "aver...
name,math,science,english Alice,88,92,79 Ben,65,70,80
[ { "name": "Alice", "average": 86.3 }, { "name": "Ben", "average": 71.7 } ]
Given a CSV of student scores across subjects (name,math,science,english), compute each student's average score rounded to 1 decimal and output as JSON array of {name, average}.