text stringlengths 1.76k 50k | token_count int64 435 12.1k |
|---|---|
I’m working on a tiny edge‑device that has to decide whether a micro‑camera image contains a defect or not.
All I have is a small collection of **grayscale images** (each image is a 2‑D `numpy.ndarray`).
The images are not all the same size – they can be any square size between **8 × 8** and **28 × 28** pixels, but... | 7,240 |
> I’m trying to write a little program for a robotics class.
> The lab gives us a rectangular “maze” that’s just a grid of 0’s and 1’s – 0 means the cell is free, 1 means there’s a wall.
> We have to place a “rat” on a start cell and let it find its way to a destination cell, moving only up, down, left or right (no... | 3,273 |
I’m working with a huge log file that contains a lot of user‑generated messages.
Each line of the file is one message – it can be empty, or it can contain any printable ASCII characters (letters, digits, punctuation, spaces, etc.).
For some analysis I need to know, **very quickly**, how many vowels appear in any c... | 1,989 |
You are working on a logging system that receives a huge stream of events.
Each event is identified by a *timestamp* – an integer in the range `[0, 10^9]`.
During the lifetime of the system you have to support three kinds of operations:
| operation | description |
|-----------|-------------|
| `ADD t` | a new e... | 3,546 |
You work for a fast‑growing startup that keeps a single huge spreadsheet of its employees.
Each employee is identified by a unique integer `id` (from 1 to `N`).
During the year the HR system writes a **log** of events that looks like this:
```
M X Y # merge the team that contains employee X with the team that ... | 2,839 |
I’m trying to coordinate two devices that emit a short pulse at regular intervals.
Device A emits a pulse every `A` seconds, starting at time 0.
Device B also emits a pulse every `B` seconds, but its first pulse happens `D` seconds **after** the first pulse of A (so at time `D`).
For each triple `(A, B, D)` I ne... | 3,470 |
I’m building a tiny “leader‑board” micro‑service for a game.
Every time a player finishes a match we get his new **rating** (an integer) and we want to keep all seen ratings in a binary‑search‑tree (BST) – nothing fancy, just the classic left‑smaller / right‑greater structure.
Later we have to answer a lot of “what’... | 2,575 |
I have a binary tree stored in a very simple text format.
Every node has an integer value and (maybe) a left and a right child.
In my project a *full* binary tree is a tree where **every node has either 0 or 2 children** – a leaf is fine, but a node with only one child is not.
What I’m after is the *largest* full ... | 2,767 |
I’m building a simple game‑leaderboard.
Every player has a name (a short string) and a score that works like a *penalty*: the lower the score, the better the player.
During the game three things can happen, in any order:
* a new player joins the leaderboard,
* an existing player’s score gets *decreased* (it can o... | 2,606 |
I’m building a tiny lottery‑style app.
The app works with the numbers `1 … n` (inclusive) and a ticket must contain **exactly `k` distinct numbers** – the order on a ticket does not matter.
I need a program that, given several `(n, k)` pairs, prints **every possible ticket**.
I could just call `itertools.combina... | 2,912 |
- Understand the *disjoint‑set* (Union‑Find) data structure.
- Learn why *union‑by‑rank* and *path‑compression* are needed for near‑constant‑time operations.
- Apply the structure to a dynamic connectivity problem where many “merge” and “query” operations are mixed.
---
### Problem statement (in the voice of a ca... | 3,014 |
*Counting Ways on a Broken Staircase*
---
### Background (as a casual request)
> I’m working on a game level where the player has to climb a staircase.
> The staircase can be up to **100 000** steps high.
> At each move the player can go **one step** or **two steps** forward.
> Unfortunately some steps are b... | 2,541 |
I’m trying to put together a tiny command‑line tool that encrypts or decrypts a piece of text using the **Vigenère cipher**.
* The tool should read three lines from *stdin*:
```
1️⃣ a mode character – “E” for encryption or “D” for decryption (case‑insensitive)
2️⃣ a secret key – a non‑empty string that may contain ... | 3,532 |
I have a training set that follows the typical YOLO layout:
* `images/` – a folder that holds the picture files (extensions may be `.jpg`, `.jpeg` or `.png`).
* `labels/` – a folder that holds one text file per image, named with the same stem (e.g., `cat_001.jpg` → `cat_001.txt`).
Each label file contains zero or... | 3,265 |
I’m preparing a tiny demo for a class about “the worst possible sorting algorithm”.
All I have is a small list of numbers (at most 8 elements) and a deterministic random‑number generator that I’m forced to use. I want to keep **randomly shuffling** the list until it finally ends up sorted in non‑decreasing order, pr... | 3,451 |
I have a long list of integer IDs and I need to know how many *different* pairs of IDs share at least one hexadecimal digit when the IDs are written in the usual hex notation.
The “hexadecimal representation” of a number is exactly what Python’s `hex()` would give for the **absolute value** of the number, **without*... | 3,435 |
I’m trying to build a tiny reverse‑mode automatic differentiation (AD) library that works with NumPy arrays. The idea is to wrap numbers/arrays in a `Tensor` (or `Variable`) class, record every elementary operation in a computation graph, and then compute gradients of any “target” tensor with respect to any “source” te... | 6,510 |
I have a singly‑linked list that stores a sequence of items (the items can be integers, strings, or any hashable objects).
The list may contain the same value many times, and I want to keep only the first occurrence of each value, preserving the original order of the remaining nodes.
Right now I’m using a double‑loo... | 2,550 |
*Lucas Queries – fast answers for huge indices*
---
### Learning objectives
* **Mathematical background** – recognise the Lucas sequence, its recurrence `L₀ = 2, L₁ = 1, Lₙ = Lₙ₋₁ + Lₙ₋₂` and its close relation to the Fibonacci numbers.
* **Closed‑form and matrix formulation** – understand how the recurrence can... | 4,739 |
I’m adding a little “status ticker” to my smart‑home hub. Every minute the hub has to emit a token that tells the rest of the system what’s going on:
* If the minute number is a multiple of **3**, emit **“Fizz”**.
* If the minute number is a multiple of **5**, emit **“Buzz”**.
* If it’s a multiple of **both 3 and ... | 3,786 |
I want a small Python command‑line tool that lets me type the name of an anime and an episode number and instantly gives me two URLs:
1. a *watch* URL – the address of the `<iframe>` that streams the video in a browser, and
2. a *download* URL – the direct `.m3u8` playlist that I can feed to a video player or downlo... | 8,384 |
I have a CSV‑like data dump that contains a series of measurements (they could be growth rates, sensor readings, returns on an investment, …).
Each line is a separate *record* and may contain any mixture of the following tokens:
* an integer (e.g. `42`)
* a floating‑point number (e.g. `3.14`, `-0.0012`)
* the placeh... | 5,008 |
I have a small set of cities (maybe 5 – 30) and a text file that tells me the distance between every pair of cities.
The file looks like this (each line appears **once**, distances are symmetric):
```
A B 20
A C 18
A D 22
A E 26
B C 10
B D 11
B E 12
C D 23
C E 24
D E 40
```
*Every city name is a single word without... | 4,008 |
You are working on a moderation tool for a huge chat service.
The service gives you a *log* – one long string that contains all messages that were posted during a day (the string may be several megabytes long).
Before the log arrives you also receive a list of *flagged phrases* – words or short snippets that the mo... | 3,835 |
Hey there!
I’m working on a small physics‑simulation where I constantly need the real solution `x` of
```
x * exp(x) = C
```
for many different constants `C`.
The obvious way is to use Newton‑Raphson, but my current implementation is flaky:
* it uses a **finite‑difference** to approximate the derivative with a ... | 5,776 |
I’m working on a small project where I need to read a binary tree from the input and then output the values of its nodes level‑by‑level, but with a twist: the traversal direction should alternate on each level (left‑to‑right on the first level, right‑to‑left on the next, then left‑to‑right again, and so on). In other w... | 3,331 |
> Hey, I’m building a simple routing tool for our warehouse robots.
> The floor plan comes to me as a rectangular matrix where each cell is an integer:
>
> * `-1` – a solid obstacle (pillars, shelves, walls). Robots can’t step on these.
> * `0` – a loading dock (the “gate”). This is where a robot can start or finish... | 2,535 |
I’m working on a system that manages a fleet of cargo ships crossing the oceans.
The company wants us to replace the quick “haversine–sphere” distance with a more accurate **Lambert’s ellipsoidal distance** (the WGS‑84 ellipsoid) for every distance query we get from the routing service.
Here’s what I need:
* I have... | 4,631 |
I’ve got a toy music‑player that keeps a *playlist* as a simple sequence of song IDs (just integers).
The player receives a long list of commands that modify the playlist:
* `PUSH_FRONT x` – put song `x` at the beginning
* `PUSH_BACK x` – put song `x` at the end
* `INSERT_BEFORE y x` – insert song `x` **immediat... | 3,323 |
I have a small collection of medical chest X‑ray images that I want to use to automatically decide whether a patient has tuberculosis (TB) or not. The images are already sorted into folders by class, like this:
```
dataset/
training_set/
TB/
img001.png
img002.png
...
... | 6,551 |
I’m writing a tiny “text editor” that works only with the classic Caesar shift.
The editor gets an initial string (it may contain uppercase, lowercase letters and any other ASCII symbols – only the letters have to be shifted, everything else stays unchanged).
During a session I have to perform many operations of t... | 3,281 |
I’ve been playing around with strings and I need a little helper.
Given a string `s`, I want to cut it into pieces so that **every piece reads the same forward and backward** (i.e. each piece is a palindrome).
A cut can be placed between any two consecutive characters.
If the whole string is already a palindrome, ... | 2,305 |
I have a list of `N` integers ( `N` can be pretty big – think up to a couple of hundred thousand ).
If I run the classic *in‑place* insertion sort on this list – the version that walks from left to right, takes the current element, and repeatedly shifts the bigger elements one position to the right until the correct ... | 2,613 |
I’m writing a tiny “circular‑shift” helper for a text‑processing script.
The idea is simple: given a string `s` and an integer `k`, I want to rotate the characters **to the left** by `k` positions.
* If `k` is positive, the rotation is left‑wards.
* If `k` is negative, the rotation should be right‑wards (i.e. a ... | 1,810 |
Hey,
I’ve been playing around with a tiny binary‑tree implementation in Python (all nodes store an `int`). The basic `Node` and `BinaryTree` classes work – I can iterate over the tree in‑order, get its length with `len(tree)`, and the existing `depth()` method (recursive) returns the correct depth for the small exampl... | 3,738 |
I’m tinkering with a tiny board that has an *n‑bit* register.
The board never lets the register change arbitrarily – it only flips **one
bit at a time** so that the whole set of 2ⁿ possible states can be visited
in a single closed loop.
In other words the register walks through a **Gray‑code** sequence:
* starts a... | 2,897 |
I’m working with very large remote‑sensing images (multispectral) and I need to compute several vegetation indices for every pixel.
Each band of the image is provided as a separate two‑dimensional NumPy array (shape `H × W`) with `float32` values. The available bands are:
* **red** – Red channel
* **green** – Gr... | 3,265 |
I’m building a scheduler for a production line (or a game quest‑tree, whatever).
There are *N* independent tasks numbered `0 … N‑1`.
Some tasks must be finished before others – each such requirement is a directed
edge `u → v` meaning *task u* has to be completed before *task v* can start.
I need two things:
1. **... | 2,935 |
Hey there – I’m putting together a quick‑analysis tool for a server that logs an event every second. The timestamps are just plain integers (seconds since the epoch). For a strange but fun reason we call a timestamp *prime* if the integer itself is a prime number.
I have a bunch of time windows and, for each window, I... | 3,117 |
I’ve got a bunch of grayscale images (just plain old 8‑bit pictures, pixel values from 0 to 255). For each original picture I also have a version that was compressed (so it may look a bit worse).
What I want is a tiny script that:
* reads a whole lot of these original/compressed pairs from *standard input*,
* compu... | 2,991 |
You have a high‑dimensional dataset and you want to compress it with **Principal Component Analysis (PCA)**.
The data are stored in a matrix where each **row** corresponds to a feature (dimension) and each **column** corresponds to an observation (sample).
You wrote a small program that should:
1. centre the data,
... | 3,835 |
Hey there! 👋
I’ve got a big list of integers and I need to pull out some information about their prime factors.
- For **every** number in the list I want to know the **smallest prime divisor** and the **largest prime divisor** it has.
- If the number is `0` or `1` (they don’t really have prime factors) just ou... | 2,844 |
I have a long list of numbers that arrive one after another.
Whenever a number arrives I must put it on one of a set of stacks.
The rule for each stack is simple: the numbers that end up on the same stack must appear **strictly increasing** in the order they arrived (i.e. if you read the elements of a stack from bo... | 2,679 |
I’ve got a log file from a bunch of sensors. Each sensor spits out a **positive integer reading** every second.
Some of these readings look “perfect” – I mean *perfect* in the mathematical sense (the number equals the sum of its proper divisors, excluding itself).
I need to pull out **all** the perfect readings fro... | 2,029 |
---
### Problem Description
I’m working on a tiny service that stores a *huge* sorted list of integer IDs (think user IDs, product codes, etc.).
The list is **already sorted in non‑decreasing order** and the values are roughly uniformly spread over a large range (0 … 10⁹).
Later on the service receives a lot o... | 2,843 |
I have a binary tree that stores a bunch of integer readings (they could be sensor values, scores, whatever).
For every node I would like to know how far its reading is from the reading of the *mirrored* node – i.e. the node that would sit in exactly the same place if the whole tree were flipped left‑to‑right.
Forma... | 2,919 |
Hey there – I’ve got a huge list of integers that I keep in memory and, from time to time, I need to answer a bunch of look‑ups on it.
For each look‑up I’m given a number `x` and I have to tell **the index of the occurrence of `x` that is closest to either end of the list** (i.e. the smallest distance to the leftmos... | 2,727 |
I’ve been collecting a huge log of energy measurements from a bunch of sensors.
Every line of the log looks like this:
```
<value> <unit>
```
* `<value>` is a number (it can be an integer or a decimal, possibly negative).
* `<unit>` is one of the official energy units – exactly the spellings below:
```
joule, ki... | 3,296 |
I have a huge list of integer timestamps (they can be negative, zero or positive) that I need to sort as fast as possible.
Because the range of values is usually pretty small compared to the size of the list (e.g. a day‑long log: values from 0 to 86 400), I wanted to use **pigeon‑hole sort** (the same idea as countin... | 1,856 |
I’m working on a telemetry pipeline for a satellite.
Every minute the ground station receives a *single line* that contains a bunch of integer readings (temperature, sensor IDs, error codes …).
The line can be huge – up to **10 000 000** numbers – and it is **very repetitive**: in many cases 70 % – 90 % of the valu... | 4,423 |
Hey there,
I’m working on a small utility that has to sort a list of integers. The lists I get can be pretty big (up to 10⁵ numbers), they may contain negative values and a lot of duplicates. I read that *heap sort* is a good fit because it works in‑place and runs in O(N log N) time, so I gave it a try.
Below is th... | 2,782 |
I have a piece of text that may contain letters, digits, punctuation marks and a lot of spaces.
For every *maximal* group of English letters (a‑z, A‑Z) that is **strictly longer** than a given threshold `L`, I need to flip the order of the letters inside that group. All other characters – spaces, tabs, newlines, punc... | 2,912 |
I have a spreadsheet that contains the daily average temperature (in °C) and the total ice‑cream sales (in dollars) for the last **N** days.
I want to use this data to predict the sales for new temperatures, but I don’t want to “guess” – I’d like a proper statistical model.
**Your task**
1. From the given `(temp... | 3,154 |
Finding the “Boldest” Binary Representation
---
### Story & Motivation
I’m processing a huge log file that contains a long list of integer readings from a sensor.
For each reading I have to turn the decimal value into a binary string – exactly the way Python’s `bin()` prints it:
* a non‑negative number → `0... | 2,221 |
I’m working on a backup‑server network for a company that has grown a lot lately.
The network is described by an undirected weighted graph:
* every vertex is a server,
* every edge is a possible cable between two servers,
* the weight of an edge is the cost (which may be negative – a discount – or zero).
The compan... | 4,185 |
I have two independent sources that generate ordered items – for example, a personal to‑do list and a work calendar, or two live feeds of notifications.
I need to produce a single schedule that mixes the items from both sources as evenly as possible, but I also have a rule that I don’t want to see more than *k* items... | 2,466 |
I’ve got a huge list of tags that come from a bunch of external vendors.
Each tag is just a line of text – it can contain anything: ASCII letters,
digits, punctuation, spaces, emojis, even non‑ASCII letters like “é” or “Ω”.
My analytics pipeline wants to compare tags case‑insensitively, but the way it
does that is... | 3,076 |
You have been asked to write a small utility that digests the raw output of a Doppler‑based radar system and converts the raw data into the frequencies that the radar actually “hears”.
The radar works by emitting a continuous wave of known frequency `f₀` (in Hz) that travels through a medium with a known propagation s... | 2,187 |
I’m processing huge numeric logs and I need to know the *best* contiguous block of *K* entries.
Specifically, for each test case I get an array `A` of `N` integers (the values can be positive or negative) and an integer `K`.
I have a quick prototype that works for tiny inputs, but as soon as `N` reaches a few hundr... | 3,705 |
I’m playing around with “ugly numbers” – the positive integers whose only prime factors are 2, 3 and 5 (by convention 1 counts as well).
For a single value I could just keep testing every integer, but now I have to answer a lot of questions at once and the naïve way is way too slow.
---
### Task
You are given sever... | 2,503 |
I’m putting together a very simple “photo‑electron detector” simulation for a lab demo.
The idea is that we shine a monochromatic light (either described by its frequency or by its wavelength) on a metal surface and we want to know the **maximum kinetic energy** \(K_{\max}\) of the electrons that could be emitted.
T... | 4,000 |
I’m trying to pull product information from Amazon for a given search term (e.g., “headphones”, “laptop”, “gaming chair”).
What I need is a Python function that:
1. Takes a search query string (the product name/category).
2. Scrapes Amazon’s search results page(s) and extracts for each listed product:
- Product... | 4,376 |
I started writing a tiny hash table in Python using open addressing (linear probing). It works for a couple of inserts, but as soon as I start deleting keys or inserting many items it either hangs or gives the wrong answers.
Below is the code I have right now:
```python
class HashMap:
_EMPTY = object()
_DELE... | 5,066 |
I’m working on a little tool that keeps track of a bunch of 2‑D points.
At the start I get a list of points, then I receive a long sequence of commands.
The commands are of two kinds:
* `ADD x y` – insert a new point with integer coordinates `(x, y)` into the current set.
* `QUERY` – ask for the **sum of the squ... | 2,814 |
I’m building a small tool that helps the community manager of a blockchain project decide how to split a token airdrop between two groups of users:
* **Early adopters** – each of them should receive exactly `a` tokens.
* **Regular users** – each of them should receive exactly `b` tokens.
The total amount of tokens ... | 5,312 |
You have a digital circuit that is built out of the three usual logic gates
`AND`, `OR` and `NOT`.
Unfortunately your hardware only contains a single primitive: a **NAND gate**.
A NAND gate takes two binary inputs `a` and `b` and returns
```
nand(a,b) = 1 if not (a == 1 and b == 1)
0 otherwise
```
... | 2,556 |
I’m modelling a stack‑like data structure (think of a pile of cards).
Exactly three commands can appear in the input:
* `push x` – push the integer `x` on the **top** of the stack.
* `pop` – remove the current top element (do nothing if the stack is empty).
* `swap` – **swap every successive pair of elemen... | 3,463 |
I’ve got a directed graph and I keep getting asked questions like:
*“If I start at vertex `s`, how many different walks of exactly `K` edges end at vertex `t`?”*
The graph may be pretty dense, `K` can be huge (think 10¹⁸), and there are a lot of these queries.
I’m sure there’s a way to answer them faster than doi... | 3,625 |
I have a collection of points in an *n*-dimensional integer grid (the dimension is small – at most 5).
For every unordered pair of points I need the Manhattan (aka taxicab) distance and I have to add all those distances together.
My current script works fine for a few dozen points, but when the input grows to **hund... | 2,384 |
I have a huge piece of text – think of a long article, a DNA sequence, or a chat log – and a *lot* of short strings that I want to flag whenever they appear.
The catch is that the text can be up to a million characters long and the list of patterns can contain up to one hundred‑thousand strings (the total length of a... | 3,958 |
I have a piece of text that can contain any printable ASCII characters (letters, digits, punctuation, spaces …).
For every *lower‑case* ASCII letter (`a`‑`z`) I may optionally press a special key that turns that single character into its upper‑case counterpart (`A`‑`Z`).
All other characters (already upper‑case let... | 3,570 |
I’m writing a tiny interpreter for a game that keeps a stack of scores.
The engine receives a long list of commands (up to a few × 10⁵) and it has to:
* **push x** – put the integer `x` on the top of the stack.
* **pop** – remove the element that is on the top and *print* its value. If the stack is empty print `EM... | 1,993 |
I’m building a log‑monitoring tool that constantly streams text files that can be *really* big – think millions of characters.
Whenever an error signature shows up in a log line I need to flag it instantly.
The situation is:
* I get **one pattern** (the error signature) and **one log line** (the text) as input. ... | 2,956 |
I run a small online shop and for every day I log three numbers:
| column | meaning |
|--------|----------|
| `date` | an integer (or float) representing the day index (0‑based) |
| `event`| how many promotional events we ran that day (exogenous variable) |
| `user` | the total number of unique visitors that day (targ... | 4,719 |
I’ve got a huge list of strings and I need to figure out how many of them could actually be the same word, just written starting from a different position. In other words, two strings belong to the same “rotation family” if you can take some number of characters off the front of one and stick them on the end to get the... | 2,626 |
I’ve got a tiny monitoring script that prints a tag every second, starting from second 1.
The rules are the classic *Fizz‑Buzz* ones:
* if the second number is a multiple of **3** → print `"Fizz"`
* if the second number is a multiple of **5** → print `"Buzz"`
* if it’s a multiple of **both 3 and 5** → print `"Fi... | 1,584 |
I’m working on a small financial audit tool. Every day the system dumps a list of *transaction deltas* – integers where a positive number means money came into the account and a negative number means money went out.
For debugging I want to spot any three distinct transactions that exactly cancel each other out (thei... | 3,004 |
---
### Problem description (as a quick request)
I have a huge string `S` (think of it as a log of events, each event represented by a single character).
I want to keep the string “alive” – I may change a single event, and many times I need to know **how big the RLE‑compressed version of a substring would be**.
Th... | 4,369 |
I’m keeping a list of temperature forecasts for the next `N` days.
Sometimes I discover that a whole block of days was entered incorrectly, so I have to **overwrite** every forecast in that block with a new constant value.
After each correction I often want to know **the hottest day** inside any interval I ask abou... | 1,797 |
Hey there,
I’m putting together a little “fun‑with‑combinatorics” challenge for my blog readers, but I’m stuck on making the backend fast enough.
**What I need:**
- I get up to **10 000 strings** as input (one per line).
- Each string can be up to **2 000 characters** long and contains only lower‑case letter... | 3,197 |
> I have a big list of strings (think file‑names, DNA fragments, or user‑ids).
> From time to time I need to **replace** one of the strings with a new one, and I also need to ask:
> *“What is the longest common prefix shared by *all* strings between positions **L** and **R** (inclusive)?”*
>
> The list can be ... | 3,613 |
I’m working on a little robotics project and I need a helper routine that can figure out a walkable path through a grid‑based floor plan. Here’s the situation:
* The warehouse floor is given as a **2‑D list of integers** (`maze`).
* `0` = free tile – the robot can step on it.
* `1` = obstacle (rack, wall, etc.... | 2,271 |
I’m working on a small analytics pipeline for a mobile game and I need a reusable Python solution that does two things:
1. **Core library** – expose two functions that compute the *additive persistence* and the *multiplicative persistence* of a non‑negative integer (in base 10).
The functions must accept either a... | 4,378 |
I’m working on a data‑acquisition system that reads 32‑bit status words from a legacy peripheral. Because the connector on the board was wired incorrectly, every transmitted word has its *adjacent* bits swapped:
* bit 0 is sent as bit 1,
* bit 1 is sent as bit 0,
* bit 2 is sent as bit 3,
* bit 3 is sent as bit 2,
* …... | 2,389 |
I’ve got a huge list of integers (up to 100 000 of them) and I need to know, one‑by‑one, whether each number is *square‑free* or not.
> **Square‑free** means: the absolute value of the number is **not** divisible by any perfect square larger than 1.
> Examples: `10 = 2·5` is square‑free, `12 = 2²·3` is *not* (the fa... | 4,065 |
I have a bunch of text files that are being sent over the wire in an *encrypted* form.
The encryption is a **Gronsfeld cipher** (a digit‑based Caesar shift).
The rules are:
* The secret key is a **non‑empty numeric string** – each character of the key is a digit `0…9`.
* Its length is unknown but it never excee... | 4,430 |
Hey there!
I’ve got a long list of audio samples (just a stream of floating‑point numbers) and a digital IIR filter that I want to run on it.
After the filtering I’d like to know how loud the signal ever gets – in other words, the **maximum absolute value** among all filtered samples.
The filter is described by t... | 3,781 |
I’m writing a tiny map‑viewer for a game. The map is stored as a rectangular 2‑D list (a list of rows, each row a list of integers).
For a few UI tricks I need to show the same map in a different orientation, but **the original grid must stay untouched**.
The required orientations are:
* **Clockwise 90°** – rotate... | 2,558 |
I have a huge binary tree (up to 10⁵ nodes) that represents a network of devices.
From time to time I need to know what the tree *looks like* when I stand on one of four sides:
* **L** – look from the **left** side (the left‑most node at each depth)
* **R** – look from the **right** side (the right‑most node at ea... | 5,176 |
I have a bunch of long strings (only lower‑case English letters) and I’m interested in a kind of “repeating‑pattern score”.
For a *prefix* `p` of a string `s` the **border** of `p` is any non‑empty proper prefix of `p` that is also a suffix of `p`.
Among all possible borders of `p` I only care about the *longest* o... | 2,313 |
Hey there,
I’m working on a little script that has to answer a *lot* of queries about the Fibonacci numbers.
For each query I get three integers `L`, `R` and `M` and I need to output
```
( F(L) + F(L+1) + … + F(R) ) mod M
```
where the Fibonacci sequence is defined in the usual way:
* `F(0) = 0`
* `F(1) = 1`
... | 3,162 |
Hey everyone,
I’m working on a little number‑theory challenge and I could really use a hand.
For each test case I get two integers:
* `X` – the target sum ( 1 ≤ X ≤ 10⁵ )
* `N` – the power ( 2 ≤ N ≤ 10 )
I want to know **how many different ways** I can write `X` as a sum of **distinct** positive integers raise... | 2,957 |
I’m working on a small network‑analysis tool that should list every *critical* connection in an undirected graph – a connection (edge) whose removal would increase the number of connected components. In graph theory these edges are called **bridges**.
I wrote a function `compute_bridges` that takes a graph represented... | 4,345 |
I have a CSV‑style dataset that I’ll feed to my program via *stdin*.
The first line contains two integers
```
N M
```
* `N` – number of training samples (1 ≤ N ≤ 10 000)
* `M` – number of input features (1 ≤ M ≤ 20)
Every one of the next `N` lines contains `M+1` real numbers separated by spaces:
```
x₁ x₂ … x... | 3,955 |
I’m working on a telemetry pipeline for a fleet of remote sensors.
Every measurement the sensor produces is a **32‑bit unsigned integer**, but the
wire protocol sends the bits **LSB‑first** – i.e. the integer we receive has its
bits reversed.
The log file I get from the device is just a list of those raw decimal
va... | 2,854 |
I’ve got a directed network that models a bunch of “junctions” (think of them as routers, water tanks, or even magical chambers).
Each junction can only handle a limited amount of flow passing **through it** – that’s a *node capacity*.
Some of the junctions are **generators**: they can inject a certain amount of f... | 4,673 |
I’m working with a lot of Excel‑style worksheets.
Every column in a sheet is identified by the usual Excel titles: `A`, `B`, … `Z`, `AA`, `AB`, … and so on (always upper‑case, never empty).
For each sheet I get a bunch of **column ranges** that are already taken by some reports.
A range can be written in two way... | 4,140 |
I have a large network of `N` cities (or computers, substations, …).
Between some pairs of cities a road (or cable) already exists – these
edges are **already built** and I can’t remove them.
In addition there are `M` possible new roads I could still build, each
with a known construction cost.
The already built r... | 3,870 |
I have a multiset of product codes (just integers) that I can use to create “bundles”.
A bundle is any selection of zero or more items from the multiset – the order of the items inside a bundle does **not** matter.
Because the multiset may contain duplicate codes, the same bundle can often be formed in many differe... | 2,741 |
I’m working on a tiny reporting tool that receives a list of values (e.g. scores, timestamps, prices…) from an external service.
Because the service runs in a very constrained sandbox I’m **not allowed to use** any of Python’s built‑in sorting helpers (`list.sort()`, `sorted()`, `heapq`, etc.).
The only operations ... | 1,687 |