As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [programming-challenge]

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

Filter by
Sorted by
Tagged with
10 votes
4 answers
1k 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 ...
Erikson Thomas's user avatar
2 votes
3 answers
190 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/...
Ted's user avatar
  • 21
1 vote
2 answers
115 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. ...
AlwaysLearning's user avatar
0 votes
1 answer
278 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 ...
Mark's user avatar
  • 449
2 votes
1 answer
100 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 ...
presci's user avatar
  • 249
3 votes
1 answer
344 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. ...
gparyani's user avatar
  • 131
-3 votes
3 answers
508 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 ...
Jahirul Sarker's user avatar
0 votes
1 answer
131 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 ...
Susheel Busi's user avatar
2 votes
1 answer
163 views

AdventofCode 2021: Day 3 Solution

I am beginner to Haskell. Here is my solution to Advent of Code 2021 Day 3. Let me know what you think. I was looking at the transpose function and decided not to use head & tail function. Given ...
presci's user avatar
  • 249
1 vote
2 answers
132 views

Function wrapper that prints the result

(English) I was recently challenged to make a simple program that does the following: Function f accepts as a parameter a function g, which returns a value. Function f must return a function h which ...
Noel's user avatar
  • 13
2 votes
3 answers
265 views

567: Permutation in String

So I've been working on this for a few days actually. I implemented a solution to the LeetCode problem: 567. Permutation in String The Problem Given two strings s1(queryStr) and s2(sourceStr), return ...
Josh Sanders's user avatar
0 votes
1 answer
108 views

Advent of Code 2021 Day 4: Play Bingo against a Giant Squid

[This is my first post here - though I have been lurking in the back reading, plussing, and hopefully learning for over two years] Below is my solution for Advent of Code 2021 Day 4, where you are ...
Aganju's user avatar
  • 189
-1 votes
1 answer
82 views

Codewars Runtime Error

I am currently trying to solve the problem "Is my friend cheating?" on Codewars. The Text are the Details to the Problem: A friend of mine takes the sequence of all numbers from 1 to n (...
Florian's user avatar
3 votes
1 answer
99 views

Project Euler problem 11 in Rust: largest product of consecutive elements in a grid

I wrote the following Rust code for euler project problem 11. It works and a small test is included, but I am not very happy about the code. At first I wanted to chain together iterators for all the ...
hkBst's user avatar
  • 198
3 votes
0 answers
74 views

Advent of Code 2021: day 10- Syntax Scoring

The following code solves day 10 in the advent of code challenge. The goal for this time around is evaluating whether a line of brackets is complete, has a syntax error or is missing some closing ...
N3buchadnezzar's user avatar
3 votes
1 answer
107 views

2021 Advent of Code, Day 1 Part 2: Keeping error-handling simple while chaining iterators with Rust

This question is with respect to Day 1, Part 2 of the 2021 Advent Of Code challenge, which requires comparing values from a rolling window taken from integers streamed as input. This answer is correct,...
Charles Duffy's user avatar
3 votes
1 answer
203 views

Efficiently calculating perfect powers in Haskell

I'm trying to calculate perfect powers to solve this code wars challenge: https://www.codewars.com/kata/55f4e56315a375c1ed000159/haskell The number 81 has a special property, a certain power of the ...
jdkleuver's user avatar
3 votes
0 answers
179 views

Advent of Code 2021, Day 3 in Haskell

This is a working solution to today's Advent of Code puzzle, written in Haskell. However, I feel like this solution is not optimal. ...
Scriptim's user avatar
  • 131
1 vote
0 answers
59 views

Euler Project Problem #3 Optimization Needed

Well I was solving Problem 3 from Project Euler, but I just found out that my code is really bad, it would take so much time to finish processing the code and I honestly do not know how to optimize it....
fabinfabinfabin's user avatar
3 votes
1 answer
247 views

Reading input in idiomatic Rust for Advent of Code Day 2

I'm trying to write idiomatic and fast Rust code by solving AoC challenges this year! :-) Link to AoC Day 2 problem The input format in this problem is a list of lines each containing one string token ...
Gaurang Tandon's user avatar
4 votes
1 answer
174 views

Advent of Code 2021: day 1

I am doing the Advent of Code challenge to learn Rust (obviously there may be spoilers if you still want to do the challenge). The instructions are too long to include verbatim so I will link them and ...
NeRoboto's user avatar
  • 143
1 vote
1 answer
139 views

Minimum Window Substring in Swift exceeds LeetCode runtime check

This is a popular question on LeetCode: 76. Minimum Window Substring Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in ...
Shawn Frank's user avatar
1 vote
0 answers
116 views

String search using Rabin-Karp algorithm

I am trying to solve a needle in haystack using Rabin-Karp algorithm, but for large inputs my code takes way too long time. Here is the part which apparently is too slow: ...
Ach113's user avatar
  • 111
1 vote
1 answer
174 views

Euler Project Problem 2 JavaScript

Just solved Euler Project Problem 2 using JavaScript and I would like to know how I could improve my code. I do think it looks good, but you never know. Problem Statement Each new term in the ...
fabinfabinfabin's user avatar
1 vote
1 answer
723 views

HackerRank - Climbing the Leaderboard: I don't understand why my code is exceeding the time limit

Climbing the Leaderboard An arcade game player wants to climb to the top of the leaderboard and track their ranking. The game uses Dense Ranking, so its leaderboard works like this: The player with ...
One Curious Person's user avatar
5 votes
2 answers
425 views

DNA Challenge from CS50

Added the problem link below and my implementation of it. Took me a few hours to program. I have added comments to explain my thought process. Problem Link Goal - To implement a program that ...
singhsokhal's user avatar
1 vote
1 answer
418 views

Python IPv6 verifier, parser and converter

This is a simple Python 3 program that verifies whether a string is a valid IPv6 address or not, parses IPv6 address to its hexadecimal and decimal values, and converts an integer to IPv6 format. I am ...
Ξένη Γήινος's user avatar
3 votes
1 answer
92 views

IOSP Kata: merge two sorted arrays without iterators

I wrote the code below as a Kata to practice the Integration Operation Segregation Principle (IOSP, clean-code-developers.com). I would like to have some feedback ...
Turing85's user avatar
  • 137
2 votes
3 answers
145 views

Finds Keywords in Log Files

This is my first project in C and I wanted a more experienced person's insight on how I made the whole program. Just looking for feedback it works how I want it to. The Github is here. Thank you so ...
cobb208's user avatar
  • 21
4 votes
1 answer
359 views

Determine whether an array contains duplicate values

My solution for the leet code problem to search an array of ints for duplicate values and return a boolean seems quite efficient (< 90% of submissions runtime). However, I am currently reviewing ...
d0rf47's user avatar
  • 143
3 votes
2 answers
395 views

pattern matching coding challenge

I have implemented a simple pattern matching for the below algorithm in Java with time complexity of O(n)(n is the size of the input array). Any suggestions for optimization?? one of the most ...
teja sri's user avatar
3 votes
3 answers
457 views

Find the average score, given data in a table with labeled columns not in a fixed order

I was on Hacker Rank for the first time and there was a question that required to get the inputs from STDIN and use collections.namedtuple(). It was my first time ...
seriously's user avatar
  • 153
6 votes
2 answers
210 views

Container with most water, with pre-computation of possible bounds

Here's my attempt at leetcode's container with most water. Problem: Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn ...
kubatucka's user avatar
  • 310
1 vote
2 answers
115 views

Evaluate the roots of Bhaskara’s formula

I'm creating a program that finds the roots of Bhaskara’s formula and prints them. I'm looking for advice to improve my logic more and more. ...
appaabdo10's user avatar
3 votes
1 answer
127 views

Find potentional sponsor for every animal

This is a programming challenge in Czeck. My translation follows. Does anyone know what the time complexity of my code is? Input: The first line contains 2 integers: the number of animals 1 ≤N ≤100 ...
DemonCZ's user avatar
  • 33
1 vote
0 answers
107 views

Python functions to serialize nested data structures human readably

See Serializing (nested) data structures in a human-readable format for more details. In the last two days I have significantly improved my function, and wrote seven implementations of it. I have ...
Ξένη Γήινος's user avatar
5 votes
3 answers
721 views

Counting swaps in a sequence sorting algorithm

I have been working on this question, https://open.kattis.com/problems/sequences. You are given a sequence, in the form of a string with characters ‘0’, ‘1’, and ‘?’ only. Suppose there are n ‘?’s. ...
ChickenCoding123's user avatar
2 votes
3 answers
285 views

Leetcode First Unique Character in a String code optimisation

I was working on First Unique Character in a String Question Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. Example 1: ...
D_S_X's user avatar
  • 189
-2 votes
1 answer
67 views

leetcode 169 optimzations reducing complexity [closed]

This is for leetcode problem: https://leetcode.com/problems/majority-element There is something wrong with the way I create solutions, and not sure how to stop doing it. Basically the problem is I ...
Preston_Jarvis's user avatar
0 votes
1 answer
502 views

Codeforces - problem: (A) Mike and palindrome

While on SO someone posted this question and I gave it a quick try. My solution passed all the testcases. Link to the problem: Problem: (A) Mike and palindrome Question: Mike has a string s ...
Ch3steR's user avatar
  • 634
2 votes
1 answer
127 views

CodeChef - Red Alert

I have solved this problem from the CodeChef platform using the Python prorgamming language Here is the code: ...
King Cold's user avatar
  • 339
2 votes
1 answer
771 views

Find the closest match to a string [closed]

Input The first line of input contains a string s: the word misspelled by your partner. Assume that your partner did not add or remove any letters; they only replaced letters with incorrect ones. The ...
Anony's user avatar
  • 123
2 votes
2 answers
259 views

Drug Analyzer challenge

What do I need help with? I'm doing the challenge below, in which I need to increase code performance. It's currently at 63% and I need to increase it to at least 71% however I can't optimize more ...
Manassés G.'s user avatar
2 votes
3 answers
690 views

Find the 'n' most frequent words in a text, aka word frequency

I'm doing freeCodeCamp's Coding Interview Prep to improve my JavaScript skills. This challenge is called "Word Frequency", and is based on the Rosetta Code's entry of the same name. The ...
NPN328's user avatar
  • 751
2 votes
3 answers
105 views

Phrase to acronym in C from exercism.io

I am learning C and doing challenges like those found on exercism.io and the various data structure & algorithm sites. I have a sense that while this works and it makes sense to me that it can be ...
jgnovak-dev's user avatar
0 votes
2 answers
314 views

Year/month difference calculator

My program calculates the user's age in years and months. It takes the user's birth year and month and then the current year and month as input. ...
Ahmed Saleh's user avatar
0 votes
1 answer
177 views

Leetcode 662. Maximum Width of Binary Tree Javascript FlatMap attempt - Time Limit Exceeded

Problem Statement: Given the root of a binary tree, return the maximum width of the given tree. The maximum width of a tree is the maximum width among all levels. The width of one level is defined as ...
Prashin Jeevaganth's user avatar
3 votes
3 answers
2k views

Calculate movie ticket price

My program displays the price of a movie ticket. The price is based on the customer’s age. If the user enters a negative number, the program displays the “Invalid age” message. ...
Sahid Adin's user avatar
3 votes
1 answer
1k views

Recursive solution of ordered Coin Combinations II (CSES)

Question Link Consider a money system consisting of n coins. Each coin has a positive integer value. Your task is to calculate the number of distinct ordered ways you can produce a money sum x using ...
randomUser's user avatar
9 votes
2 answers
757 views

Yet another minesweeper field calculator

The task is to read in a data file containing a representation of a rectangular array with '*' signifying a mine and '.' signifying the absence of one. Each such array is preceded by a row and column ...
Edward's user avatar
  • 65k

1 2
3
4 5
66