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.
3,284
questions
6
votes
3
answers
718
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 ...
5
votes
1
answer
357
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 ...
5
votes
3
answers
855
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 ...
6
votes
2
answers
398
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 ...
2
votes
1
answer
41
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 ...
3
votes
1
answer
219
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 ...
3
votes
2
answers
92
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 ...
3
votes
2
answers
58
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:
...
3
votes
1
answer
152
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 ...
9
votes
2
answers
566
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 ...
5
votes
2
answers
338
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 ...
3
votes
1
answer
96
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 ...
5
votes
1
answer
337
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 ...
2
votes
0
answers
33
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 ...
2
votes
3
answers
564
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),...