# Questions tagged [programming-challenge]

Programming challenges are off-site challenges meant to offer programmers educational experiences while testing their abilities.

3,267 questions
Filter by
Sorted by
Tagged with
1 vote
22 views

### Cleanly modifying values in hashmap for a k-sum challenge

Just started learning Rust and here's a program that has caused me some agony to implement in Rust. This is very easy to implement in C++, but Rust's borrow checker is causing all sorts of trouble. My ...
• 33
131 views

### Count the number of magical stones [closed]

There is a magical stone of mass 2N lying at the origin of the number line. For the next N seconds, the following event happens: Let us define the decomposition of a magical stone as follows: If there ...
1 vote
87 views

### JavaScript function that generates Fibonacci like sequences of given order

Generalizations of Fibonacci numbers Fibonacci numbers of higher order A Fibonacci sequence of order $n$ is an integer sequence in which each sequence element is the sum of the previous $n$ ...
• 1,490
1 vote
47 views

### A simple JavaScript function that does prime factorization

This is a simple JavaScript function that does prime factorization. I wrote it on an Android phone with online editor (I don't have access to computers in night time): Code: ...
• 1,490
116 views

### FizzBuzz in JavaScript (node.js), my first JavaScript program

I had just decided to learn JavaScript, so I wrote this program. I am sure you know what FizzBuzz is so I wouldn't describe it here. Console output: ...
• 1,490
1 vote
50 views

### Infix calculator programming challenge Kattis.com

I'm working on this C++ coding problem: Input is a sequence of up to commands, one per line, ending at end of file. Each command is a definition, a calculation, or a clear. All tokens within a ...
48 views

### Algorithm for twoSum

This is my PHP algorithm for the twoSum problem in leetCode: ...
1 vote
39 views

### PyQt6 program that lets you adjust the HSV values of an RGB color

I don't know how to actually describe what this script does concisely. I am writing GUI programs using PyQt6, and I want the most beautiful palette for my programs, so I browsed Wikipedia for a bunch ...
• 1,490
103 views

### LeetCode: C# fibonacci number iterative solution

https://leetcode.com/problems/fibonacci-number/ The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones,...
• 5,249
130 views

### Find local maxima of a sequence

I'm well versed in Python and Java, am just starting out with C++. Am enjoying the language and would really appreciate feedback on this solution. kata: Return positions and values of the "peaks&...
126 views

### Codewars - How many pages in a book?

Problem Statement Every book has n pages with 1 to n pages. The summary is made by adding ...
1 vote
77 views

### Finding the winner of a tic-tac-toe game in Swift

Working on the problem Find Winner on a Tic Tac Toe Game, I took several hours longer than an artificial time constraint the site had for mock interview purposes. This leads me to wonder if my ...
60 views

### Leetcode problem: minimum removal to make valid parentheses

I was working on this problem on leetcode Question Your task is to remove the minimum number of parentheses ( '(' or ')', in any positions ) so that the resulting parentheses string is valid and ...
• 179
80 views

### Python 3 number convertor that converts floats between decimal and bases 2-36

This is a Python 3 script that converts any real number (ints and floats) from decimal notation to any positional number system ...
• 1,490
47 views

### Distribute items over array in order to minimize the difference between min and max array values

I came across this problem in a programming challenge a few days ago. I came up with the implementation below, however it resulted in a "time limit exceeded" failure for a few of the test ...
• 419
34 views

### Haskell solution to Day 2 problem of Advent of Code '21

I won't restate the problem in full, but in a nutshell you have to parse a file with a "direction" and a "magnitude", for instance: ...
• 199
32 views

...
65 views

### Algorithm Challenge: Fuzzy Search

I recently took part in an algorithm challenge to create a Fuzzy search with the following criteria: Given a set array, create a function that receives one argument and returns a new array containing ...
48 views

### Finding all "triplets" of an integer array but in a more optimal manner

I'm practicing the following problem Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. ...
• 31
54 views

### Function to sum all Armstrong numbers within a range

I've tried to solve a challenge posted on a LinkedIn forum using Haskell - a language I'm still learning the basics of - and, while the code works correctly, I would like to get some feedback on the ...
• 199
46 views

### follow-up - Checking Nested Bracket Levels in Strings Programming Challenge

A follow-up to this question, this post improves on test case issues. To restate problem parameters, a given string S is considered closed if it: Has a matching ...
• 2,897
166 views

### Programming Challenge - Capturing Bracket Levels

I don't have a formal description for this problem, but here are the parameters: Given a string S check that each opening bracket has a matching closing bracket. ...
• 2,897
123 views

### GeekTrust: Traffic problem - functional programming

First attempt to write functional programming, been following OO paradigm all through my programming journey Please review the code and let me know if any comments and violations of functional ...
95 views

### Array rotation in C++

I am completely new to data structures and algorithms. I tried this problem on hackerank. I got the desired output but my code wasn't efficient enough to execute in the given time limit. How can I ...
• 89
60 views

### Programming Challenge: Python 3 DNS query resolver using socket

This is a DNS query resolver written in Python 3 using socket, I wrote it entirely by myself, it supports 8 primary DNS query types: A, NS, CNAME, SOA, PTR, MX, TXT,...
• 1,490
56 views

### Chapter 8 Challenge: Add employee names to a department

The boring but exciting challenge: Using a HashMap and HashSet, create a text interface to allow a user to add employee names ...
• 61
119 views

### Programming Challenge - Game Scoring

Can this solution be made more efficient? game_scoring.py ...
• 2,897
1 vote
124 views

### HackerRank CountingSort 1 in C#

Comparison Sorting Quicksort usually has a running time of n x log(n), but is there an algorithm that can sort even faster? In general, this is not possible. Most sorting algorithms are comparison ...
581 views

### Calculator using variable names

I've recently been assigned an assignment to create a word calculator, and given my knowledge in python is still quite lacking, I want to ask if anybody has any better ideas for any possible solutions....
380 views

### LFU Cache implementation in Python 3

Need some feedback on this implementation of LFU cache in python3. Original problem : https://leetcode.com/problems/lfu-cache/ Would really appreciate some feedback on readability, understandability ...
• 63
74 views

### Highly divisible triangular number

Highly divisible triangular number, my solution My solution of challenge from Project Euler takes too much time to execute. Although on lower numbers it works fine. Anyone could look up to my code and ...
• 31
733 views

### Coding exercise to implement IsApproximatelyEqual in Java

this assignment was given to me within the job application process (well, really not much infos given): for our applikation we have to compare very often floating point numbers (double, float). Can ...
• 2,392
438 views

### Which fruit fall onto my house?

I am following a question on a programming challenge website (here's the original reference). What I have is a house (start & endpoint) and some types of trees at their respective location points. ...
• 33
1 vote
86 views

### It is considered a daemon if it runs in the background - creating a daemon in C

I created a daemon that creates a fifo file with a default name, then is been blocked waiting for messages on that fifo. When an interactive process writes data to that fifo, the daemon wakes up and ...
• 1
66 views

### Maximum Depth of Binary Tree in JavaScript

The task Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. ...
• 3,955
22 views

### Maximum length of a row made up from given dominoes

Given a set of dominoes, find the maximum length of a row that can be made using some of those dominoes. Rotating the dominoes is allowed. Recall: A domino piece consists of 2 numbers from 0 to 6 (e....
129 views

### Encoded string algorithm with given rules

Looking for general feedback and if there is a solution that can reduce the time complexity from the current O(n2)? Thank you. Problem Statement Consider a string that consists of lowercase English ...
181 views

### Kattis challenge, processing string with special characters and conditions

I'm new to programming challenges and I'm attempting the following Kattis challenge Sim. This problem is an extension of another Kattis problem - backspace. In that problem, every time we see a ...
82 views

### Maximum subarray sum modulo m

This is a well-known problem from a HackerRank challenge: Given an array and a number M, output the maximum of all subarray sums modulo M, M between 1 and 1E14. A ...
• 581
413 views

### Wordle puzzle game

I am a beginner programmer with not much experience, the little I do have is with Python specifically. With all the fuss going around about the popular word game "Wordle" I wanted to ...
125 views

### Kattis Battle Simulation

I have a working program for a problem, but need to optimize it in a way where the processing time is less than 3 seconds. This is where I found the problem: https://open.kattis.com/problems/...
• 21
1 vote
66 views

### Find longest palindrome in a string (LeetCode problem 5)

The code below is my solution to the following problem (problem #5 on LeetCode): Given a string s, return the longest palindromic substring in s. I wonder whether my use of iterators is an overkill. ...
157 views

### Round Robin algorithm implementation

I wrote a program that implements the Round Robin planning algorithm. The total number of processes is read directly from the input standard, and for each process the arrival time and execution time ...
• 1
57 views

### Stamp Combination Kattis

I tried to solve Stamp Combination problem on Kattis, which basically gives an integer array and a target number. The problem asks whether we can find a contiguous subarray which starts at either end ...
• 21
47 views

### Advent of Code 2021 Day 4

Here is my attempt at Advent of Code Day 4 using Haskell. A file contains list of number in first line. And subsequent lines have the bingo Cards ...
• 237
90 views

### Finding the minimum element of a stack of numbers

As part of an online programming challenge, I wrote a program that implements a stack of integers, supporting adding and removing elements, finding the last inserted element, and the minimum element. ...
• 131
128 views

### CodeForce 230 Dragon Fighting, Sorting without using array

Problem: https://codeforces.com/problemset/problem/230/A Kirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he's got to defeat all $n$ dragons that live on this ...
68 views

### Extract and write fasta files using Biopython based on input from another file

I have the below code that takes a sequence file and another file with a list of contigs and extracts the sequences and writes them to a file, specifically based on the file with the contig list. The ...