0

I managed ~120 in c++(no big-nums in c++, made it a bit harder) with no external libraries and a "very" limited knowledge of programming. Have hit the wall now (mostly the math i think).

Has anyone else given this a go and how did they do?

This is not supposed to be a bragging contest, just curious to know how others did.

5
Contributors
22
Replies
23
Views
6 Years
Discussion Span
Last Post by frogboy77
0

I've solved 80 of them using F# as I'm trying to learn F# and figure this is a good way to go about it :)

0

Depends on the problem :) Some of them I'm not sure how to express in F# yet, others I'm not sure how to do the math. One hint though, almost all the hard math ones use something from Euler's work to solve.

And it's not really the understanding of the math, it's what method to use

Edited by Momerath: n/a

0

I use to do it, got busy with other stuff. Not sure how many I solved but passed level 1. What problem are you stuck on?

0

Thanks for the pointer to this. I hadn't come across this before. Did six of them before bed last night, in three languages. Brute force solutions, mostly, but I'm going to try to think of more clever approaches before I read the discussion of the problems.

I don't know if this one is in there, but it's a fun one:
You have an array of 100 booleans. First pass sets them all to true. Second pass starts at the second one and toggles every other one. Third pass starts at the third and toggles every third, and so on up to the 100th pass, which simply toggles the 100th.

The brute force solution is easy to code, of course. The challenge is to work out which elements will be true at the end, without running the brute force solution.
The solution can be generated by an incredibly simple one-pass loop, with one step in the body of the loop.

0

@jon.kiparsky
The harder ones are well beyond brute force range so looking for a better solution is definitely the way to go. The even harder ones are well beyond my mathematical ability.

What do you mean by toggle? Is this erastosthenes?

Edited by frogboy77: n/a

0

It's not erastosthenes. What he means be toggle is that if it is false, make it true and if true make it false.

And pick a problem, maybe we can all work out a solution together :)

0

317 is bugging the crap out of me, but i feel like it's a pen and paper one not really needing much in the way of code.

0

Looking at that, I don't come up with any clever ideas for modelling it. I can visualize it, I think, but I'd have to think about it a little while before I could convert that into anything descriptive.
Have you got one that doesn't involve ballistics?

0

317 doesn't seem too hard. You just need to determine the shape formed by the 'projectiles'. I'm guessing it's a parabola, but I'll need to perform some steps to determine if it is. Once you have that, it's just determining the height and the radius of the circle formed at the base (ground).

0

Take each word and find if it forms a square number. Keep those words. Find if any of the square words is an anagram of another word in the list (I'd start with the largest square number and work backwards). Once you find one, you are done.

0

I would imagine that there's a finite set of pairs of n-digit numbers which satisfy the conditions for this problem. That might be a good place to start.

0

Take each word and find if it forms a square number

The digits are assigned to letters arbitrarily. That's a lot of combinations to work through, and it wouldn't eliminate much - How may square numbers can you find by arbitrarily substituting digits for the letters in CARE? Oh, how many 4-digit primes are there?

0

There are 36 patterns that fit for CARE but not all those have 'anagrams'. For example, 33 and 99 (1089 and 9801) are one pair. So take CARE as 1089 and does 9801 form an anagram (ERAC). No, so it's not a valid pair. Continue through the list and see what you can find. You only need to check 32^2 through 99^2. By finding the pairs first you can speed up your search.

And there are 1061 four digit primes. Not sure what primes has to do with this problem.

0

Sorry, posting before coffee. Squares, not primes. Must have primes on the brain.

Having had my coffee and arrived at work, I'm reading the problem again.
I'd probably make a list of anagrams and save their patterns, something like
(CARE, RACE) (1234, 3214)

and a similar list for numbers
(1296, 9216) (1234, 3214)

and match the one against the other. That gives you the whole list, and you can look for whatever you want - largest individual number, total number of such pairs, whatever. And you get to re-use some code. :)

0

I have this moment solved with Python 131 problems starting New Years time as I earlier had posted help on some problems in Python forum for others and thought to do those myself.

For the 98, I have following functions in my solution in Python (first cross post for your post was my solution of other problem) not including the implementation:

def is_anagram(k,s):
"goes through the letters of second word (s) and returns s if anagram"

def squares_by_length(length):
"generate squares whose length is given"

def make_mapping(word, digits):
"make mapping if not double mapped same number to different letters, digits can be integer or string"

def map_to_number(word, mapping):


When I run the main code I get the solution in 480 ms in Python 2.7.

Maybe this gives you some hint without telling too much.

0

Pretty much what i knew i was lacking, i can do the anagram part and the generation of the squares, it's the mapping part i don't think i have the knowledge of the language for. Need to do some more reading.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.