Skip to main content
The 2025 Developer Survey results are in. Explore insights into technology and tools, careers, community and more. View results.

Questions tagged [programming-challenge]

Use this tag when the code is a solution to a programming challenge. Always include a sufficient description of the problem to be solved - while a link to the challenge is welcome, the review request needs to be complete when the challenge site is unavailable.

Filter by
Sorted by
Tagged with
3 votes
2 answers
177 views

Third way to place queens and rooks with the higher score (extension of the queen problem)

Here is a third implementation, the second is in my question Place queens and rooks with the higher score (extension of the queen problem) and an initial one is in my answer for the question N queen ...
bruno's user avatar
  • 212
4 votes
1 answer
143 views

Place queens and rooks with the higher score (extension of the queen problem)

This is a continuation of the question N queen problem-like (+rooks and a different goal) written by someone else, where I answered. EDIT I continued to work on the subject and a third implementation ...
bruno's user avatar
  • 212
5 votes
3 answers
1k views

Project Euler Problem #1: Multiples of 3 or 5

Project Euler Problem #1 Multiples of 3 or 5 states: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of ...
toolic's user avatar
  • 13.6k
6 votes
2 answers
433 views

(Codewars) Goldbach's Conjecture (by @rsalgado) in Ruby

Link to kata: linkRank: 6 kyuKata author: @rsalgado I have been recently learning Ruby-lang and have been attempting to solve the following kata from Codewars involving Goldbach's Conjecture: ...
CrSb0001's user avatar
  • 619
6 votes
2 answers
695 views

Weather Observation Station 8 query

Here's my (correct) solution to a HackerRank question: Weather Observation Station 8 Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last ...
JTB's user avatar
  • 277
6 votes
1 answer
565 views

Substring = Permutation of a given pattern

I am working on a problem on LeetCode. Considering only lowercase characters from 'a' to 'z', I have written some Java code to check if a permutation of a given pattern is a substring of a given ...
EngineerP's user avatar
1 vote
1 answer
160 views

FreeCodeCamp todo list

I'm writing JS for the FreeCodeCamp todo list; the corresponding HTML and CSS for this can be found on their page. I have made one edit to the HTML - the button with type "submit" has been ...
ApexPolenta's user avatar
4 votes
1 answer
107 views

Efficient way to win points in chocolate bowl game

I'm working on an optimization problem involving a turn-based chocolate-sharing game, and I need help optimizing my current brute-force solution. Problem Description: You and your friend take turns ...
CodeCrusader's user avatar
7 votes
1 answer
99 views

.net core web API simple app with one endpoint

I am trying to complete a challenge - a simple .net core API with one simple endpoint. This endpoint should validate the user's information and return a unique ID. He should provide: 1) Name, 2) ...
Tania Marinova's user avatar
5 votes
2 answers
200 views

LeetCode Number 416: Partition Equal Subset Sum

Problem: MLE I am confused as to why the LeetCode judge reports Memory Limit Exceeded when my solution looks close to the editorial solution. I not too familiar with ...
user430243's user avatar
7 votes
4 answers
962 views

Project Euler #54: class for poker hands

I'm working right now on Project Euler problem 54, and I figured that this was the perfect opportunity to try to work with classes. This is my first time, so I'm sure that there are a lot of style, ...
Brais Romero's user avatar
7 votes
5 answers
2k views

Solving an easy LeetCode "Merge Strings Alternately"

I am a C++ dev trying to solve problems in C to practice it, specifically the LeetCode Merge Strings Alternately problem: You are given two strings word1 and word2. Merge the strings by adding ...
ijklr's user avatar
  • 397
6 votes
2 answers
255 views

(HackerRank) Project Euler+ #250: 250250

Link to problem: linkNumber of solvers: 27 out of 844Solve rate (per person): 3.199%Success rate (over all submissions): 1.78% Project Euler+ on HackerRank is basically supposed to be a generalization ...
CrSb0001's user avatar
  • 619
5 votes
3 answers
999 views

LeetCode 678: Valid Parenthesis String, Recursion memoization to DP

How can the following recursion + memoization code be converted into a tabulation format dynamic programming solution? The code is working, but I want to improve it. The challenge I am facing is ...
Elias El hachem's user avatar
8 votes
5 answers
1k views

LeetCode 977: Squares of a sorted array, maintaining non-decreasing order

I tried solving the LeetCode question like many others, trying to incorporate the O(n) time complexity requirement. Squares of a Sorted Array Given an integer array ...
Littlejacob2603's user avatar
8 votes
2 answers
217 views

Leetcode 93: Restore IP Addresses (C version)

This is posted in response to this request made in a discussion of my "C-ish" answer to a recent Code Review question regarding a Python solution to a Leetcode challenge. It was reported ...
Fe2O3's user avatar
  • 1
11 votes
4 answers
2k views

Leetcode 93: Restore IP Addresses

(Source: Leetcode 93: Restore IP Addresses [Medium])(Topics: [String] [Backtracking]) The problem is as follows: Definition: A valid IP address is defined to consist of exactly four integers ...
CrSb0001's user avatar
  • 619
5 votes
2 answers
402 views

Rust implementation of Euler problems

I'm starting to learn rust and figured my first simple project would be to solve some of the Euler problems. I'd appreciate if anyone could tell me where I might be ...
zephyr's user avatar
  • 223
3 votes
2 answers
161 views

Pattern Finding In Lists of Strings (2d Char Array), Advent of Code Day 04 Solution

This is part 2 of Day 4 of 2024's AoC: The problem is as follows: It's an X-MAS puzzle in which you're supposed to find two MAS in the shape of an X. One way to achieve that is like this: ...
Lozminda's user avatar
  • 143
6 votes
5 answers
858 views

Bracket matching - Advent of Code 2021 Day 10

The following code solves Advent Of Code 2021 Day 10. The goal for this time around is evaluating whether a line of brackets is complete, has a syntax error or is missing some closing brackets. ...
138 Aspen's user avatar
  • 453
5 votes
2 answers
969 views

LeetCode 3366: Minimum Array Sum - w/o DP/memoisation

This program tried to solve LeetCode problem 3366: Minimum Array Sum. It fails for k odd, op1+op2 high enough such there are more odd value to optionally subtract k from than subtractions to allot. A ...
greybeard's user avatar
  • 7,291
3 votes
1 answer
90 views

Advent of Code 2024 - Day 1 (Common Lisp)

I have recently started learning lisp by reading ANSI Common Lisp, and I thought advent of code would be good for practice. Any feedback on my code for Day 1 would be appreciated. ...
advent-of-code-asker's user avatar
4 votes
1 answer
106 views

LeetCode Rust solution for the Sliding Puzzle problem #773

Here is the solution to the LeetCode Sliding Puzzle Problem #773. The problem is to find the shortest solution for a 3 x 2 sliding puzzle. I would appreciate any ideas to improve this code. But it's ...
Eugene Krokhalev's user avatar
6 votes
1 answer
95 views

LeetCode Rust solution for the Flip Columns problem #1072

Here is the solution to LeetCode Problem #1072. The problem is to find the maximum number of rows in a matrix where all the values can be made equal after some columns are flipped. It's assumed that ...
Eugene Krokhalev's user avatar
8 votes
2 answers
863 views

Basic C++ implementation of linux wc command

I am working on the Build Your Own wc Tool coding challenge in C++. I have a working implementation that seems to match the output of the wc command for different ...
Ganesh Tata's user avatar
4 votes
1 answer
173 views

Poker Lite (AOC 2023 Day 7) using structs wrapped in an enum

I've been trying to learn Rust by working through Advent of Code 2023, specifically for day 7, part 1, here. It's Poker Lite: You're given a list of hands. The input is formatted as ...
roganjosh's user avatar
  • 143
4 votes
4 answers
455 views

Convert the number formats (Decimal - Hexadecimal - Octal) to Decimal

Problem statement: Write a program called multi_input.cpp that prompts the user to enter several integers in any combination of octal, decimal, or hexadecimal, ...
Tuhami's user avatar
  • 41
3 votes
1 answer
258 views

Roman Numerals Look and Say in rust (BIO 2020 Q1)

I was practicing question 1a of the British Informatics Olympiad 2020 past paper. The Roman look-and-say description of a string (of Is, Vs, Xs, Ls, Cs, Ds and Ms) is made by taking each block of ...
sbottingota's user avatar
  • 1,153
1 vote
1 answer
208 views

golang - Kth largest element in an array using quick select - time limit exceeded issue

I am trying to solve the following problem in leetcode. https://leetcode.com/problems/kth-largest-element-in-an-array/description Given an integer array \$nums\$ and an integer \$k\$, return the \$k^\...
Debanjan's user avatar
6 votes
1 answer
439 views

FORTRAN90 test suite for Project Euler

The intent of this test file is to go through each of my Project Euler solutions and see if they: return the correct answer, and do so in under 60 seconds (unless expected otherwise). I am using ...
Olivia A's user avatar
5 votes
1 answer
87 views

Parsing Lists: BIO 2024 Q2

I was practising question 2a of the British Informatics Olympiad 2024 past paper. In this task you will manipulate lists of integers to create new lists. There are three fundamental lists that you ...
sbottingota's user avatar
  • 1,153
4 votes
1 answer
142 views

Efficient polynomial multiplication in Python

I'm practicing problems for the ICPC competition, and one of the problems requires solving it by using an FFT to compute the product of two polynomials efficiently. Since this is for the ICPC ...
João Areias's user avatar
4 votes
2 answers
379 views

BIO 2021 Q3a: Window Dressing (BFS in C++)

I was practicing question 3a of the British Informatics Olympiad 2021 past paper. A shop is looking to display some boxes (conveniently labelled A, B, …) in their window. There is a desired order for ...
sbottingota's user avatar
  • 1,153
4 votes
1 answer
140 views

BIO 2021 Q1a: Down Pat

I was practicing question 1a of the British Informatics Olympiad 2021 past paper. A pat is a single letter or a string of letters which can be split into a left and right string (of at least 1 letter)...
sbottingota's user avatar
  • 1,153
1 vote
1 answer
110 views

Finding the number of distinct decompositions a number has using only repdigits

This is a problem from a previous semester that I am trying to upsolve. I am trying to solve a problem involving the total number of ways of decomposing a number using only repdigits. A repdigit is a ...
Lesserrafim's user avatar
7 votes
3 answers
791 views

Finding the Zeckendorf Representation of a Positive Integer (BIO 2023 Q1)

I was practicing question 1a of the British Informatics Olympiad 2023 past paper. In the Fibonacci sequence each number is generated by adding the previous two numbers in the sequence. We will start ...
sbottingota's user avatar
  • 1,153
6 votes
1 answer
384 views

String Decryption in C (BIO 2022 Q1)

I was practicing question 1a of the 2022 British Informatics Olympiad past paper. Each letter in the alphabet can be given a value based on its position in the alphabet, A being 1 through to Z being ...
sbottingota's user avatar
  • 1,153
6 votes
3 answers
898 views

Project Euler 127 - abc-hits

Problem (Rephrased from here): The radical of \$n\$, \$rad(n)\$, is the product of distinct prime factors of \$n\$. For example, \$504 = 2^3 × 3^2 × 7\$, so \$rad(504) = 2 × 3 × 7 = 42\$. We shall ...
Nadav Nevo's user avatar
6 votes
2 answers
481 views

Family, felon & fuzz River Crossing challenge

I first saw this challenge when a user posted it to SO about two years ago without a shred of code. The post's plea, "How do I get started?" meant the user's post didn't survive long on that ...
Fe2O3's user avatar
  • 1
2 votes
1 answer
58 views

Optimal Extraction of Longest Sorted Sequence from Individually Sorted Bucket Arrays Without Repetitions

Consider a bucket array containing sorted and/or empty buckets, and the goal is to extract the longest possible sequence in sorted order, under the following conditions: Only one element in each ...
M.A.'s user avatar
  • 121
3 votes
1 answer
240 views

Leetcode: Number of Islands - BFS (Queue vs Recursion)

I was playing around with leetcode's Number of Islands. As per the challenge's description: Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the ...
ccot's user avatar
  • 361
3 votes
2 answers
96 views

Optimizing a Function to Check Pronic Numbers in JavaScript

I've written a function in JavaScript to check whether a given number is a Pronic number. A Pronic number, also known as an oblong number, rectangular number, or ...
TAHER El Mehdi's user avatar
4 votes
2 answers
70 views

Optimizing a Function to Generate a Row of Consecutive Odd Numbers in a Triangle

I've written a JavaScript function that generates a row of consecutive odd numbers in a triangle. The triangle looks like this: ...
TAHER El Mehdi's user avatar
6 votes
1 answer
287 views

Performance Tuning to enable answer for Project Euler #566 "Cake Icing Puzzle"

Related to this question I am still looking for a solution to Project Euler Problem 566 (see link for a nice simulation also): Adam plays the following game with his birthday cake. He cuts a piece ...
DuesserBaest's user avatar
9 votes
2 answers
628 views

Advent of code 2023 day 5 in Java: mapping integer ranges to new integer ranges

Context I'll be passing an interview coding test in java soon. I am experienced with other programming languages but am very unfamiliar with Java. I am looking for critiques of the coding style much ...
Stef's user avatar
  • 322
5 votes
2 answers
364 views

Coding challenge for mixing a string

Challenge at https://www.codewars.com/kata/5629db57620258aa9d000014/train/python Given two strings s1 and s2, we want to visualize how different the two strings are. We will only take into account ...
Vessel's user avatar
  • 345
3 votes
1 answer
136 views

Coding puzzle - Passing year books

Question: There are n students, numbered from 1 to n, each with their own yearbook. They would like to pass their yearbooks around and get them signed by other students. You're given a list of n ...
Hariharasudhan Gunasekaran's user avatar
6 votes
3 answers
499 views

Leetcode: Largest Number

I was trying out leetcode's Largest Number. As per the challenge's description: Given a list of non-negative integers nums, arrange them such that they form the largest number and return it. Since ...
ccot's user avatar
  • 361
2 votes
0 answers
67 views

Last Stone Weight Problem in Haskell Using `fold`

A previous solution of this code has been posted on Code Review before. This solution is more complicated then that one, but more performant (see the below) Why is this another Question instead of a ...
WesAtWork's user avatar
  • 171
2 votes
3 answers
576 views

Extract data from poorly formatted phonebook

The Problem John keeps a backup of his old personal phone book as a text file. On each line of the file he can find the phone number (formated as +X-abc-def-ghij where X stands for one or two digits),...
Vessel's user avatar
  • 345

1
2 3 4 5
…
67