Page 1 of 1

Another Typo Challenge

Posted: Tue Feb 10, 2009 2:23 am
by deutronium
I wrote a PHP script which is trying all possible characters for all positions in the string and it found no solution.

Is there a special trick?
Am I looking in the wrong direction?
Can I assume that $x is zero before calling the given line?
The programming language of this challenge is still PHP, isn't it?
Is there a PHP function which name is just 1 character long (to be placed before the parentheses in the string)?

Re: Another Typo Challenge

Posted: Tue Feb 10, 2009 6:54 am
by rmplpmpl
deutronium wrote:I wrote a PHP script which is using eval() and is trying all possible characters for all positions in the string and it found no solution.

Is there a special trick?
Am I looking in the wrong direction?
Can I assume that $x is zero before calling the given line?
The programming language of this challenge is still PHP, isn't it?
Is there a PHP function which name is just 1 character long (to be placed before the parentheses in the string)?
It's 99% about mathematics and 1% about informatics.

Posted: Tue Feb 10, 2009 8:30 am
by MagneticMonopole
@deutronomium: Your approach did work just fine for me. (Well, I had perl feed expressions to fresh instances of a php interpreter. In your case, could previous eval()s have influenced the result of the current one?)

@rmplpmpl: Normally, I'd agree. In this particular case, not...

Posted: Tue Feb 10, 2009 4:14 pm
by deutronium
>> In your case, could previous eval()s have influenced the result of the current one?

I don't hope so. I reassigned $x and $y in every iteration and I let my other variables end with two underscores so that this eval should not influence them.

Posted: Tue Feb 10, 2009 5:25 pm
by MerickOWA
If you're trying all possible characters for all positions, you will find the answer eventually.

The challenge is still in PHP.

Posted: Tue Feb 10, 2009 8:51 pm
by deutronium
Thanks for the answers, it works now :-)

Although I explicity reassigned the variables in every iteration their values got corrupted somehow, after I added an explicit unset() for the variables it worked!

Posted: Thu Mar 12, 2009 10:48 am
by wiz1989
Just don't get the answer for this one.
I wrote a bruteforcing code like you did as well. But I made it with C#.
Also, it works fine for "Typo", but I don't get any results for "Another Typo". So I guess, it's php-depending, isn't it?
Thx for any hints =)

Posted: Thu Mar 12, 2009 3:15 pm
by b0bA
I would say it's more a general programming style you miss, instead of a php-depending code only.
The hint by rmplpmpl is the best here. You should care about the 1% in computer science. I guess your BF-Algo is missing at least 0ne char ;)

Posted: Thu Mar 12, 2009 11:41 pm
by wodkahack0r
Hm. I figured out what char to change. But it always says: '.....' is incorrect. My solution is 100% correct as any calculator gets the right result from the modified version. Any idea what could be wrong?

- Forget it. My position was off-by-one. It works now.

Re: Another Typo Challenge

Posted: Fri Mar 27, 2009 12:58 pm
by horst
rmplpmpl wrote:
deutronium wrote:I wrote a PHP script which is using eval() and is trying all possible characters for all positions in the string and it found no solution.

Is there a special trick?
Am I looking in the wrong direction?
Can I assume that $x is zero before calling the given line?
The programming language of this challenge is still PHP, isn't it?
Is there a PHP function which name is just 1 character long (to be placed before the parentheses in the string)?
It's 99% about mathematics and 1% about informatics.
Well, after many tries with a calculator and a C(++) program I must say that this is a little bit more about informatics than just 1%. Although this challenge isn't necessarily PHP dependent and is solvable without programming, in this case I had to brute force the PHP code to get the hint to the tiny difference between C and PHP.

Posted: Sat Mar 28, 2009 12:45 am
by gfoot
Maybe I'm misremembering, but I don't think this depended on a difference between C and PHP.

Posted: Sun Mar 29, 2009 12:48 am
by Chocoholic
True, the solution works in both C and C++ as well. However using an interpreted language as PHP helps if one really wants to brute-force it to save a few minutes thinking. A program in C would have to be recomplied every time something is changed.

Posted: Thu Mar 13, 2014 11:16 am
by magnus
THe solution even works in Java !!