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
1 vote
0 answers
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 ...
user avatar
  • 33
0 votes
0 answers
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 ...
user avatar
1 vote
1 answer
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\$ ...
user avatar
1 vote
1 answer
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: ...
user avatar
2 votes
2 answers
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: ...
user avatar
1 vote
1 answer
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 ...
user avatar
0 votes
2 answers
48 views

Algorithm for twoSum

This is my PHP algorithm for the twoSum problem in leetCode: ...
user avatar
  • 3
1 vote
0 answers
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 ...
user avatar
0 votes
2 answers
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,...
user avatar
  • 5,249
0 votes
3 answers
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&...
user avatar
3 votes
1 answer
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 ...
user avatar
1 vote
1 answer
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 ...
user avatar
2 votes
1 answer
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 ...
user avatar
  • 179
3 votes
1 answer
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 ...
user avatar
0 votes
1 answer
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 ...
user avatar
0 votes
1 answer
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: ...
user avatar
  • 199
0 votes
0 answers
32 views

Python one-line binary search

...
user avatar
3 votes
1 answer
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 ...
user avatar
0 votes
0 answers
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. ...
user avatar
  • 31
3 votes
1 answer
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 ...
user avatar
  • 199
2 votes
1 answer
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 ...
user avatar
  • 2,897
3 votes
2 answers
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. ...
user avatar
  • 2,897
4 votes
0 answers
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 ...
user avatar
3 votes
1 answer
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 ...
user avatar
  • 89
2 votes
2 answers
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,...
user avatar
6 votes
0 answers
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 ...
user avatar
  • 61
2 votes
1 answer
119 views

Programming Challenge - Game Scoring

Can this solution be made more efficient? game_scoring.py ...
user avatar
  • 2,897
1 vote
1 answer
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 ...
user avatar
11 votes
2 answers
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....
user avatar
6 votes
1 answer
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 ...
user avatar
  • 63
3 votes
1 answer
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 ...
user avatar
  • 31
4 votes
2 answers
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 ...
user avatar
  • 2,392
3 votes
1 answer
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. ...
user avatar
  • 33
1 vote
2 answers
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 ...
user avatar
  • 1
3 votes
1 answer
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. ...
user avatar
  • 3,955
2 votes
0 answers
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....
user avatar
3 votes
2 answers
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 ...
user avatar
4 votes
1 answer
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 ...
user avatar
2 votes
1 answer
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 ...
user avatar
  • 581
4 votes
3 answers
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 ...
user avatar
2 votes
3 answers
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/...
user avatar
  • 21
1 vote
2 answers
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. ...
user avatar
0 votes
1 answer
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 ...
user avatar
  • 1
0 votes
0 answers
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 ...
user avatar
  • 21
2 votes
1 answer
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 ...
user avatar
  • 237
3 votes
1 answer
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. ...
user avatar
  • 131
-3 votes
3 answers
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 ...
user avatar
0 votes
1 answer
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 ...
user avatar
0 votes
0 answers
64 views

Optimizing my code for Project Euler+ problem #1 on HackerRank

The Project Euler contest is ongoing on HackerRank and the first problem is finding out the sum of multiples of 3 and 5 below a certain number N. Two of the hidden test cases fail when I execute my ...
user avatar
0 votes
0 answers
60 views

Leetcode #462 (Minimum Number of Arrows to Burst Balloons), with and without optimization

I have an interesting optimization and I want to get some confirmation on whether it's valid: I was solving Leetcode #452: Minimum Number of Arrows to Burst Balloons (description in footnote [1]) and ...
user avatar
  • 243

1
2 3 4 5
66