Tagged Questions
8
votes
3answers
337 views
Finding the largest of a series of numbers being XORed
I'm working on solving a problem involving finding the largest of a series of numbers being XORed.
This is the actual problem:
Xorq has invented an encryption algorithm which uses bitwise XOR
...
2
votes
1answer
99 views
Sum the Multiples of 3 and 5
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below N.
...
4
votes
1answer
33 views
Basic Reverse Polish CL Parser
K and R Exercise 5-10
Write the program expr, which evaluates a reverse Polish expression
from the command line, where each operator or operand is a separate
argument.
For example,
...
5
votes
3answers
129 views
Go Aaaaaaaaaaah
The problem is described in full here - Aaah!.
Input
The input consists of two lines. The first line is the “aaah”
Jon Marius is able to say that day. The second line is the “aah” the
...
1
vote
2answers
48 views
Skiena's Programming Challenges: The Trip problem
I have the following solution for the Trip problem from Skiena's and Revilla's Programming Challenges (full problem description here).
...
4
votes
3answers
70 views
String self-similarity
It's a string problem I have been making on Hackerrank. It is executing fine on all test cases except the last two. These last two test case are declaring it "Terminated due to time out".
C programs ...
2
votes
1answer
51 views
Two squares or not two squares - constant time optimization
I have been trying to solve this problem, and after a bit of googling, I realised a \$O(\sqrt{n})\$ time complexity works fine (though the algorithm suggested is different from that I have used). My ...
4
votes
3answers
154 views
Penney Game - mapping macros to strings
The SPOJ problem:
Given a 40 character string representing outcomes of 40 coin tosses,
find the frequency destribution of all the possible outcome triplets.
So, for string like : HHHH....40 Hs ...
0
votes
1answer
51 views
Why is this code giving me a wrong answer? [closed]
I have solved this problem in C, but I get wrong answer every time, could you maybe tell me what I did wrong? Also, don't laugh at my code, I started learning C 7 days ago :)
...
5
votes
2answers
101 views
Genomic Range Query
Recently I worked on one of the Codility Training - Genomic Range Query (please refer to one of the evaluation report for the detail of this training).
The proper approach for this question is using ...
3
votes
1answer
286 views
Function to find sum of digits in the number a^b where a, b are positive integers
I was solving Project Euler problem 16, which asks to find the sum of digits of the number 2 raised to the power 1000. Using Python, it can be solved in one line of code:
...
-2
votes
2answers
87 views
Finding the sum of all positive integers given a set of integers [closed]
http://www.spoj.com/problems/SIZECON/
This is my code for the problem:
...
4
votes
3answers
209 views
Please review my solution to Project Euler program 1
Can someone give me suggestions on how to improve this program?
The objective is to find the sum of all the multiples of 3 or 5 below 1000.
...
3
votes
2answers
202 views
Project Euler #1 - Multiples of 3 and 5
If we list all the natural numbers
below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum
of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
...
1
vote
1answer
72 views
Square free Integer
I am an amateur programmer and I tried coding this problem using the TurboC++ IDE (though my code is in C), but the site's compiler throws a "TIME LIMIT EXCEEDED" error. How can I optimize my code ...
4
votes
1answer
312 views
Why is this divide and conquer algorithm inefficient?
I was solving one of the problem in USACO 2007 Open Silver:
Description
Farmer John has taken his cows on a trip to the city! As the sun sets, the cows gaze at the city horizon and observe ...
1
vote
1answer
313 views
Can this solution to Project Euler #15 be improved?
I'm not a C programmer, just wanted to make a fast solution to the problem. Here's my code:
...
2
votes
3answers
189 views
Mimicking T9 cell messaging
Today I solved a question from Google Code Jam: mimicking a cell phone keypad messaging.
Here is the program, with goto statements. I know it is an unstructured ...
10
votes
6answers
3k views
Sum of all primes under 2 million
I have this assignment to write the optimized space and time code for finding the sum of all primes under 2 million in c/c++. Im using the following function to check if each number is prime
...