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

learn more… | top users | synonyms (2)

3
votes
1answer
29 views

De Casteljau's Algorithm Tool for Khan Academy Contest

So I wrote this code for a contest going on over at Khan Academy known as "Pixar in a Program". The goal of the contest is to create an entry that uses one of the skills shown in the new "Pixar in a ...
2
votes
2answers
74 views

Solving for equilibrium index in an array

I did a sample on Codility and finished the test task. The problem description is very short: The equilibrium index of a sequence is an index such that the sum of elements at lower indexes is ...
1
vote
2answers
88 views

Determining if two strings are anagrams

Two strings are said to be anagrams of each other if the letters of one string may be rearranged to make the other string. For example, the words 'elvis' and 'lives' are anagrams. In this ...
2
votes
1answer
46 views

Optimize program to test for divisibility of numbers 3.0

This is a follow up on my previous question. JS1's answer suggested that I should use a precomputed table containing all permutations of the lowest valid number for each number between 1 and MAX. It ...
3
votes
1answer
59 views

Testing for divisibility of numbers - follow-up

(Here is the follow up question) I had another go at trying to speed up my program described in my previous question. JS1's answer was particulary helpful and now my code is only about 20% slower ...
5
votes
1answer
50 views

Project Euler no. 17: Counting letters to write the numbers from 1 to 1000

I'm very new to programming and am admittedly embarrassed sharing my code for critique. This code works and produces the correct answer to the Project Euler Problem 17, which asks how many letters ...
2
votes
2answers
76 views

Program to test for divisibility of numbers

(EDIT: here is the follow up qusetion) Using this program to test for the smallest number where its permutations or itself is divisible by 10 or less numbers is twice as slow as the fastest program I ...
1
vote
1answer
35 views

Find permutation of a specified lexicographic rank

This is one result of my work on Project Euler to learn Java. I'm interested in how well this conforms to best practices as well as any recommendations on efficiency. (I'm pretty sure this code is a ...
2
votes
2answers
60 views

Waterloo Programming Contest: The Game of 31

Please review my program for the Game of 31. The game of 31 was a favourite of con artists who rode the railroads in days of yore. The game is played with a deck of 24 cards: four labelled each ...
2
votes
1answer
32 views

Project Euler Problem 2 in Java

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By ...
2
votes
2answers
57 views

Project Euler #85: Find the rectangular grid with closest to 2M rectangles

For one place that I interviewed at (for a Python developer position) I worked with one of the devs on two Project Euler problems, one being problem 85. We talked through different approaches and came ...
5
votes
2answers
95 views

Project Euler problem 79: deducing a passcode

For one place that I interviewed at (for a Python developer position) I worked with one of the devs on two Project Euler problems, one being problem 79. We talked through different approaches and came ...
3
votes
2answers
250 views

Project Euler #42 - Triangle Numbers

Here is the Euler problem referenced, it says: The n\$^{th}\$ term of the sequence of triangle numbers is given by, t\$_n\$ = ½n(n+1); so the first ten triangle numbers are: 1, 3, 6, 10, ...
3
votes
2answers
45 views

Project Euler 62: cubic permutations, logic

Problem 62 of Project Euler goes The cube, 41063625 (3453), can be permuted to produce two other cubes: 56623104 (3843) and 66430125 (4053). In fact, 41063625 is the smallest cube which has ...
6
votes
3answers
619 views

Find total number of phone numbers formed by the movement of Knight and Bishop on keypad

I recently gave a test on HackerRank, and submitted my answer for the following question. I passed all the test cases but company told me that the answer is not efficient, and they are not moving ...
2
votes
1answer
34 views

Summations and products in F#

I was bored, and looking to do something that involved anonymous functions, and it was suggested by @Quill, that I create a summation function. I decided to also include a product function as well to ...
2
votes
2answers
82 views

Gluing pieces of scrambled text (challenge on CodeEval)

I'm trying to solve this challenge on CodeEval. Quoting: For example, you can put pieces together and get the original text: evil pl vil pla il plan The answer is ‘evil plan’. Your ...
2
votes
3answers
74 views

Palindrome numbers - Project Euler Problem 4

Project Euler Problem #4: Largest palindrome product: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. ...
5
votes
1answer
47 views

Project Euler 40: directly calculate digits of Champernowne's constant

I implemented Project Euler problem 40 in Java. It works correctly, producing the correct answer. During the course of implementing this program, I wrote a method that directly calculates a digit of ...
5
votes
1answer
77 views

Project Euler: #36 Binary and Base 10 Palindromes

Here is the Euler problem referenced, it says: The decimal number, 585 = 1001001001\$_2\$ (binary), is palindromic in both bases. Find the sum of all numbers, less than one million, which ...
9
votes
5answers
160 views

ASCII generator

Today I stumbled upon CodinGame, a site with programming challenges. I'll describe one of them. ASCII art allows you to represent forms by using characters. To be precise, in our case, these forms ...
4
votes
2answers
75 views

Flowers Challenge on HackerRank

I worked through the Flowers challenge on hackerrank.com and would like to get feedback on solution and algorithm implementation. It was suggested by hackerrank to review greedy algorithm to solve ...
-1
votes
0answers
50 views

Returning the range of a number as a palindrome [migrated]

I like to do programming challenges in my free time to teach myself and keep fresh, this one I can't seem to optimize though and it's driving me insane. The goal is essentially, "Given a number, ...
4
votes
4answers
90 views

“Tractor” Python implementation

This is the Tractor problem from the Kattis problems archive. Problem Statement Bessie the Cow has stolen Farmer John’s tractor and is running wild on the coordinate plane! She, however, is a ...
3
votes
2answers
74 views

“Cut the sticks” Python implementation

Problem Statement You are given N sticks, where the length of each stick is a positive integer. A cut operation is performed on the sticks such that all of them are reduced by the length of the ...
1
vote
1answer
37 views

Euler #25 Scala

I usually write Euler solutions in Javascript. On problems requiring very large integers I have decided to learn Scala and take advantage of BigInt. I wrote a ...
6
votes
3answers
943 views

“Angry Professor” Python implementation

Problem Statement The professor is conducting a course on Discrete Mathematics to a class of N students. He is angry at the lack of their discipline, and he decides to cancel the class if there ...
2
votes
3answers
34 views

Project Euler 30 - Digit fifth powers in Rust

I am trying to move from Python to a systems programming language so this is a bit of a challenge for me. ...
4
votes
1answer
82 views

Ad-hoc lexical scanner

Challenge: Build an ad-hoc scanner for a calculator language. Specifications: The tokens for the language are as follows: assign → := plus → + minus → - times → * div → / ...
7
votes
1answer
160 views

A more optimized way of finding prime factors

I've solved Project Euler #3, but solving the same in Hacker Rank which has time constraint of < 4 seconds doesn't work. I've tried using the square root solution for speeding up but it fails. ...
-3
votes
0answers
77 views

Is there a way to reduce the execution time of the following code

I am a beginner trying to learn javascript at Hackerearth. There was this problem: Marut is great warrior. Marut loves his girlfriend Shizuka very much. Being jealous from Marut's love, the ...
4
votes
1answer
52 views

Project Euler # 22: Names scores

Problem 22, here, asks the following: Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical ...
6
votes
2answers
68 views

Project Euler #19: Counting Sundays in the 20th century using Pandas

Project Euler #19 asks: How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)? I'm hoping I wasn't too off course from the spirit of the ...
1
vote
2answers
42 views

“Time Conversion” Python implementation

Problem Statement You are given time in AM/PM format. Convert this into a 24 hour format. Note Midnight is \$ 12:00:00AM \$ or \$ 00:00:00 \$ and 12 Noon is \$ 12:00:00PM. \$ Input Format ...
2
votes
2answers
97 views

“Even Tree” Python implementation

Problem Statement You are given a tree (a simple connected graph with no cycles). You have to remove as many edges from the tree as possible to obtain a forest with the condition that : Each ...
4
votes
3answers
120 views

Project Euler problem 2

This is a question about Project Euler number 2, a relatively easy one. The question is: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with ...
1
vote
2answers
80 views

Euler problem 5

I am starting to learn Rust and it seems pretty awesome but it's way different than any C based language. I want to know how can I make this code more idiomatic and also how can I improve my solution ...
1
vote
2answers
56 views

Project Euler #4 “Largest Palindrome product” in Python

Given A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product ...
1
vote
1answer
51 views

“Flipping bits” Python implementation

Problem Statement You will be given a list of 32 bits unsigned integers. You are required to output the list of the unsigned integers you get by flipping bits in its binary representation (i.e. ...
4
votes
1answer
56 views

“Lonely Integer” Python implementation

Problem Statement There are N integers in an array A. All but one integer occur in pairs. Your task is to find the number that occurs only once. Input Format The first line of the input ...
4
votes
2answers
790 views

Funny String Java Solution

I'm a little rusty in Java, but I'm using it to get ready for interviews. Here's the problem description from HackerRank: Problem Statement Suppose you have a string \$S\$ which has length ...
2
votes
3answers
102 views

Pangrams python implementation

Given Roy wanted to increase his typing speed for programming contests. So, his friend advised him to type the sentence "The quick brown fox jumps over the lazy dog" repeatedly, because it is a ...
3
votes
2answers
51 views

Project Euler #18: Maximum path sum I

Problem I want to receive advice on my code, which takes 0.012 seconds. ...
3
votes
1answer
95 views

Project Euler #14: Longest Collatz sequence

Problem : source Which starting number, under one million, produces the longest chain? n → n/2 (n is even) n → 3n + 1 (n is odd) I want to receive advice on my code. It is too slow... It ...
1
vote
1answer
36 views

Project Euler #12: Highly divisible triangular number

I want to receive advice on my code. It is too slow... The problem I am trying to solve is: What is the value of the first triangle number to have over five hundred divisors? ...
5
votes
4answers
622 views

Plus Minus in Python

You're given an array containing integer values. You need to print the fraction of count of positive numbers, negative numbers and zeroes to the total numbers. Print the value of the fractions ...
5
votes
2answers
58 views

Printing octo-thorpes

Given a number, for example, \$6\$, this Python function should print hashes in the following format: # ## ### #### ##### ###### This is the ...
1
vote
3answers
63 views

Diagonal difference

Given You are given a square matrix of size N×N. Calculate the absolute difference of the sums across the two main diagonals. Input Format The first line contains a single integer N. The ...
10
votes
4answers
549 views

Optimizing Project Euler Solution #12

Just to reiterate my prev. post, as I think it helps structure my weaknesses. Coding methodology: Is the algorithm I used feasible or mostly correct? If not, how do I correct it and why won't it ...
1
vote
2answers
58 views

Project Euler #12 in Racket

Problem here. It's not exactly the brute force approach but I'm not using any sort of pre-calculated primes table, and I'm definitely not using the coprimality trick shown in the PE pdf. I'm finding ...