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

learn more… | top users | synonyms (3)

2
votes
1answer
24 views

Jesse and Cookies

Jesse loves cookies. He wants the sweetness of all his cookies to be greater than value K. To do this, Jesse repeatedly mixes two cookies with the least sweetness. ...
7
votes
3answers
291 views

UVA 750: 8 Queens Chess

In chess it is possible to place eight queens on the board so that no one queen can be taken by any other. Write a program that will determine all such possible arrangements for eight queens given ...
1
vote
0answers
46 views

Encryption by transposing text in a grid

I wrote a Java program that given a text message will print the encoded message. The problem is described in this link. Summary: We have to write a program that will encrypt a message that do not ...
4
votes
1answer
68 views

Check if the array contains duplicate values

The problem is old and simple but I wanted to try it in a different way. With some extra memory I have created an OOP-based solution. Hopefully it doesn't hurt in the interview. ...
3
votes
2answers
78 views

Insert node in sorted doubly linked list

Description: Given a reference to the head of a doubly-linked list and an integer, create a new Node object having data value and insert it into a sorted linked list. Code: ...
7
votes
1answer
261 views

Get nth node from end in a linked list

Description: You’re given the pointer to the head node of a linked list and a specific position. Counting backwards from the tail node of the linked list, get the value of the node at the given ...
3
votes
1answer
52 views

Huffman tree decoding

Description: Huffman coding assigns variable length codewords to fixed length input characters based on their frequencies. More frequent characters are assigned shorter codewords and less ...
2
votes
1answer
54 views

Google Foobar Challenge: Ion Flux Relabeling

I am currently working on a Foobar challenge, the Ion Flux Relabelling. I came up with a java solution but Google returns an OutOfMemoryError. The prompt is, ...
0
votes
0answers
169 views

Drawing Book Hackerrank

Description: Brie’s Drawing teacher asks her class to open their -page book to page number . Brie can either start turning pages from the front of the book (i.e., page number ) or from the back ...
6
votes
2answers
85 views

100 Locker Problem Expanded

The locker problem for 100 lockers is simple: A school has 100 lockers and 100 students. All lockers are closed on the first day of school. As the students enter, the first student, denoted S1, ...
4
votes
0answers
34 views

Brainf**k interpreter in Ruby

I wrote this interpreter for a code challenge. Can this be written any cleaner/smaller? Could I reduce the amount of nested conditional/loops? ...
1
vote
2answers
92 views

HackerRank, Cracking the Coding Interview: Arrays - Left Rotation

I just wanted to get some constructive feedback on my solution for this problem taken from the HackerRank Cracking the Coding Interview series. CTCI Arrays Left Rotation Problem Statement ...
4
votes
1answer
113 views

UVA online p957 - “Popes”

This is the "Popes" problem from UVa Online Judge: On the occasion of Pope John Paul II's death, the American weekly magazine Time observed that the largest number of Popes to be selected in a 100-...
8
votes
2answers
66 views

Project Euler #2 (classic) - Sum of even fibonacci numbers below 4 million

I'm looking to use LISP as best I can, not just get the right answer. This is very early on in my LISP career so feedback is welcome and exciting! Recently asked about Project Euler #1, got some ...
4
votes
2answers
165 views

Sum of all multiples of 3 or 5 below 1000 (Project Euler #1 - typical)

I'm learning LISP and am starting with Project Euler. I would love some initial feedback on my LISP code for this simple task. I know it spits out the correct answer, but what I'm not sure about is ...
1
vote
2answers
49 views

Finding next lexicographic largest permutation of a string - C++

I was working on one of the Hackerrank programs, Bigger is Greater, and it basically deals with finding the next largest lexicocraphic permutation of a string. I've implemented my solution, following ...
4
votes
2answers
72 views

Project Euler Problem 6: sum of squares and square of sums

This is a very simple task, but I'm curious if there is a better, more 'Pythonic' way to solve this. ...
0
votes
0answers
32 views

Algorithm design for CodeChef - Base Attack

I was working on a CodeChef challenge: Base attack. I have a working solution but it is not fast enough. Could you recommend anything to make it faster? ...
3
votes
2answers
50 views

Kattis challenge to finding the number of different elements in a set

I have started doing Kattis challenges from their website. For now I am still at the low complexity ones. The first line of input contains a single positive integer T≤50 indicating the number of ...
6
votes
1answer
137 views

Navigating a bounded 2D list (Advent of Code, Day 2: “Bathroom Security”)

I'm trying to solve the following Advent of Code problem in F# for practice. Description of problem (can be found here): Basically, there's a 'key pad' that I need to figure the combination to. To ...
3
votes
1answer
45 views

Time limit exceeded on finding out the GCD and LCM of a Python list

I'm doing this HackerRank exercise which expands on the problem on finding the GCD and LCM of a list. Assuming lists a and b as ...
5
votes
1answer
65 views

Shortest Path (BFS) through a maze

Background I have decided to use this year's Advent Of Code to learn Haskell. I feel like I vaguely understand the language and can solve most of the problems with relative ease. However, the code I ...
2
votes
1answer
52 views

Find a substring count in an string

This code is written to find substring count in a string in Python 3. The original problem description is here. Please suggest better ways of solving this. ...
4
votes
4answers
157 views

Counting nucleobases in a nucleotide

This question is part of a series solving the Rosalind challenges. For the previous question in this series, see Calculating protein mass ruby. The repository with all my up-to-date solutions so far ...
5
votes
1answer
86 views

Google FooBar XOR Checksum Challenge

Google FooBar came up a few days ago and I took it as a challenge to learn python quickly while having fun. However, I ran into one challenge today that has left me stumped, I've come up with a ...
4
votes
0answers
63 views

Advent Of Code 2016 Day 9 Part 1 Solution

This code gives the solution to Part 1 of this question: http://adventofcode.com/2016/day/9 Summary: You have to find the length of the input string after using the markers to duplicate parts of it. ...
3
votes
2answers
86 views

Bridge Crossing - Classic Puzzle

Problem - The classic puzzle of finding the minimum amount of time required to cross a bridge given that only two people can cross the bridge at any one time. Since they have only one flashlight (it's ...
2
votes
1answer
108 views

HackerRank NCR codesprint: Spiral Message

Problem statement: https://www.hackerrank.com/contests/ncr-codesprint/challenges/spiral-message You've intercepted an encoded spy message! The message originated as a single line of one or more ...
1
vote
1answer
106 views

Splitwise clone done right

I have started this project basically for learning perspective and wanted to learn good object oriented design. What I am trying to do is making clone of something like this but this is a command line ...
3
votes
1answer
36 views

Querying a phone directory until end of input is reached

I need to create a phone directory with given inputs, then I need to query the dictionary for unknown number of given keys, if not found, print Not found. Link of Original HackerRank Problem here ...
3
votes
1answer
138 views

Storing and retrieving student scores in three subjects

This is written to find percentages of three subjects. Original HackerRank practice problem is here. Input Format The first line contains the integer N, the number of students. The next N ...
2
votes
1answer
33 views

Go version of Advent of Code, day 5 - Dealing with runes

I tried to solve the Advent of Code quiz for day 5 in Go, since my brute force algorithm wasn't efficient in Ruby. I solved the first part of the quiz with the following Go code. ...
4
votes
2answers
85 views

Project Euler problems 1 and 2 in python

What do you think about my code? I am a beginner and just started doing some algorithmic exercises to sharpen up my python skills. Here is code for problem #1: ...
3
votes
1answer
85 views

Testing an Address Book

I have completed the following coding exercise. However, I got poor result for testing. I need some help to find out what is missed, incorrect, or incomplete in the testing section. I would appreciate ...
5
votes
1answer
79 views

2016 Advent of Code - Day05

Day 5: How About a Nice Game of Chess? You are faced with a security door designed by Easter Bunny engineers that seem to have acquired most of their security knowledge by watching hacking ...
1
vote
1answer
119 views

Advent of Code Day 1 - “No Time for a Taxicab”

Advent of Code is a fun competition. Here is a link to the first day. Each day has two parts. --- Day 1: No Time for a Taxicab --- Santa's sleigh uses a very high-precision clock to guide its ...
2
votes
1answer
36 views

Count the number of biggest numbers on the board

I coded two answers to this challenge. The first one was a standard attempt, but after it timed out, I figured out the "trick" to solving the problem much more simply. However, I'd still appreciate ...
4
votes
2answers
114 views

Find the election winner

Challenge There are n citizens voting in this year's HackLand election. Each voter writes the name of their chosen candidate on a ballot and places it in a ballot box. The candidate with the ...
7
votes
1answer
219 views

Advent of Code - Day 01

Advent of Code is a fun competition. Here is a link to the first day. Each day has two parts. --- Day 1: No Time for a Taxicab --- Santa's sleigh uses a very high-precision clock to guide its ...
3
votes
1answer
94 views

Advent of Code 2016 Day 1 “No Time for a Taxicab”

I already solved it in JavaScript, where I'm more comfortable. I pretty much ported the algorithm from there. I wanted to try the first Advent of Code puzzle in a new language and I picked Racket. ...
6
votes
2answers
91 views

Check if string is or can be made into a “valid string”

The Challenge: A valid string is one in which all distinct characters occur the same number of times. Given a string S, check if the string can be made valid by removing less than or equal to ...
3
votes
2answers
104 views

Inserting and deleting elements in a list

In my code, I use fast method of reading input and a custom model of list. After reading the input into my 'list'. The problem is that, when I test my code, most answers are correct, but for some ...
4
votes
1answer
158 views

Fizz, Buzz, or FizzBuzz?

I was messing around online at work the other day when our phone systems went down. I came across the R programming language. Now I'm not guru with programming by ...
5
votes
1answer
84 views

Isomorphic strings in LeetCode

I solved this problem: Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a ...
3
votes
1answer
95 views

Palindrome finder [closed]

So I tried the brute force method after visiting https://www.programiz.com/python-programming/examples/palindrome on palindromes. Any comment on how I can improve my coding will be much appreciated. ...
3
votes
1answer
84 views

Google Foobar Level 3 - Lucky Triples (Find the Access Codes)

I have been working on this problem for 3 days now. I wrote a piece of java code that works perfectly on my machine testing in Eclipse, but when I put it in Foobar, it either returns "Error(400) Bad ...
3
votes
1answer
70 views

Partition Equal Subset Sum Challenge LeetCode

I solved this problem in LeetCode. Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both ...
3
votes
2answers
74 views

Get height for tallest possible stack of boxes

This code is meant to compute the height for the tallest stack of boxes out of a given collection of boxes. A box has width, height, and depth dimensions. The height of a stack of boxes is the sum of ...
0
votes
0answers
37 views

Find max in-order difference in array

Given an array A of integers, find the maximum of j - i subjected to the constraint of A[i] <= A[j]. If there is no solution possible, return 0. Example : A : [3 5 4 2] Output : 2 for the pair ...
7
votes
3answers
422 views

Word Pattern challenge in LeetCode

I solved this problem from LeetCode: Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter ...