 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
|
 |
|
 |
08-19-2009, 02:56 PM
|
#21 (permalink)
|
|
The Contributor
Join Date: Mar 2009
Location: US
Posts: 76
Thanks: 0
|
Cant use echo :)
|
|
|
|
08-19-2009, 03:13 PM
|
#22 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Thanks ioan1k, I've changed it to use printf... which feels silly because there's not much brain involved in finding an alternative to echo/print. 
|
|
|
|
08-19-2009, 03:19 PM
|
#23 (permalink)
|
|
The Addict
Join Date: Jun 2008
Posts: 335
Thanks: 2
|
I can't believe implode escaped me! Good one Salathe.
|
|
|
|
08-19-2009, 03:24 PM
|
#24 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
My first thought went to array_map just like yours, so had to think of an alternative and implode was it. 
|
|
|
|
08-19-2009, 04:01 PM
|
#25 (permalink)
|
|
The Contributor
Join Date: Feb 2009
Posts: 73
Thanks: 30
|
Ean 13
Challege 6 (EAN 13)
This was my first challenge in school.I have completed this challenge in 2 hours. Because I had no idea of VB.net
So here it is.
Quote:
Step One: From the right to left, start with odd position, assign the odd/even position to each digit.
101742256780.
( the odd numbers are 0
Step Two: Sum all digits in odd position and multiply the result by 3.
Step Three: Sum all digits in even position. (1+1+4+2+6+8)=22
Step Four: Sum the results of step three and four: 63+22=85
Step Five: Divide the result of step four by 10. The check digit is the number which adds the remainder to 10. In our case, divide 85 by 10 we get the remainder 5. The check digit then is the result of 10-5=5.
|
Example: 101742256780
step 2: (0+7+2+5+7+0)*3=63
step 3: (1+1+4+2+6+8)=22
step 4: 63+22=85
step 5:
85 by 10 we get the remainder 5. The check digit then is the result of 10-5=5.
|
|
|
|
08-19-2009, 04:25 PM
|
#26 (permalink)
|
|
The Contributor
Join Date: Mar 2009
Location: US
Posts: 76
Thanks: 0
|
php Code:
$number = 101742256780; // STEP 1$split = preg_split('//', $number, - 1, PREG_SPLIT_NO_EMPTY ); $a = 0; $even = array(); $odd = array(); foreach ($split as $k => $v) { if ($a % 2) { $odd[] = (int ) $v; } else { $even[] = (int ) $v; } $a++; }// STEP 2$oddsum = 0; foreach ($odd as $k => $v) { $oddsum += $v; }$oddsum = $oddsum * 3; // STEP 3$evensum = 0; foreach ($even as $k => $v) { $evensum += $v; }// STEP 4$sumall = ($evensum + $oddsum) / 10; $final = $sumall - (substr($sumall, strpos($sumall, '.') + 1, 1)); echo 'Check Digit : ' . $final;
Hows that
|
|
|
|
08-19-2009, 06:43 PM
|
#27 (permalink)
|
|
The Contributor
Join Date: Feb 2009
Posts: 73
Thanks: 30
|
Quote:
Originally Posted by ioan1k
Hows that
|
I am sorry. It is not about odd/even numbers. It is about odd/even postions.
From the right to left, start with odd position, assign the odd/even position to each digit.
Lets take this number 101742256780 as an example.
From right to left:
101742256780
The first odd position 0 , the second 7 , the third 5 and so on.
Here again this numbers which are in [] are odds.
1[0]1[7]4[2]2[5]6[7]8[0].
Step Two: Sum all digits in odd position (not odd numbers)and multiply the result by 3.
Step Three: Sum all digits in even position. (1+1+4+2+6+8)=22
Step Four: Sum the results of step three and four: 63+22=85
Step Five: Divide the result of step four by 10. The check digit is the number which adds the remainder to 10. In our case, divide 85 by 10 we get the remainder 5. The check digit then is the result of 10-5=5.
|
|
|
|
08-19-2009, 06:50 PM
|
#28 (permalink)
|
|
The Contributor
Join Date: Mar 2009
Location: US
Posts: 76
Thanks: 0
|
Quote:
Originally Posted by hello-world
I am sorry. It is not about odd/even numbers. It is about odd/even postions.
From the right to left, start with odd position, assign the odd/even position to each digit.
Lets take this number 101742256780 as an example.
From right to left:
101742256780
The first odd position 0 , the second 7 , the third 5 and so on.
Here again this numbers which are in [] are odds.
1[0]1[7]4[2]2[5]6[7]8[0].
Step Two: Sum all digits in odd position (not odd numbers)and multiply the result by 3.
Step Three: Sum all digits in even position. (1+1+4+2+6+8)=22
Step Four: Sum the results of step three and four: 63+22=85
Step Five: Divide the result of step four by 10. The check digit is the number which adds the remainder to 10. In our case, divide 85 by 10 we get the remainder 5. The check digit then is the result of 10-5=5.
|
This is what I did 
|
|
|
|
08-19-2009, 09:02 PM
|
#29 (permalink)
|
|
The Contributor
Join Date: Feb 2009
Posts: 73
Thanks: 30
|
SOLVED
That was the best.
only the last step.
It is 85 /10 the remainder will be 5 . And 10 -5 is 5
next Challenge ???
|
|
|
|
08-19-2009, 09:07 PM
|
#30 (permalink)
|
|
The Addict
Join Date: Jun 2008
Posts: 335
Thanks: 2
|
Thought to post it again as it's hard to see on my solution to another challenge post..
Challenge 5 (Salathe: added challenge number so we can keep track))
Construct your a looping method to mimic for using only variables inside the scope of the function ( no global keyword )
( I don't expect the break keyword to be respected, that would be a slight more difficult )
|
|
|
|
08-19-2009, 10:08 PM
|
#31 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Maybe I'm just tired but earlier today the challenge 5 description didn't make any sense, and now it still doesn't.  Would you mind rephrasing it and/or correcting the broken English, Enfernikus?
Last edited by Salathe : 08-19-2009 at 10:50 PM.
|
|
|
|
08-19-2009, 11:33 PM
|
#32 (permalink)
|
|
The Addict
Join Date: Jun 2008
Posts: 335
Thanks: 2
|
Quote:
Originally Posted by Salathe
Maybe I'm just tired but earlier today the challenge 5 description didn't make any sense, and now it still doesn't.  Would you mind rephrasing it and/or correcting the broken English, Enfernikus?
|
Certainly, sorry for the misunderstanding. Essentially the task is to mimic the for loop
php Code:
for( $i = 0; $i < 10; ++$i ) { //What ever code you want here }
WITHOUT using any other loops or global variables.
P.S. Sorry if my English has it's mistakes, it's not my native tongue.
|
|
|
|
08-20-2009, 01:30 AM
|
#33 (permalink)
|
|
how quixotic are you?
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
|
Would this work?
PHP Code:
<?php
function myloop($x=0) { if($x < 10) { echo $x; $x++; myloop($x); } }
myloop();
|
|
|
|
08-20-2009, 01:49 AM
|
#34 (permalink)
|
|
The Addict
Join Date: Jun 2008
Posts: 335
Thanks: 2
|
Quote:
Originally Posted by ETbyrne
Would this work?
PHP Code:
<?php
function myloop($x=0)
{
if($x < 10)
{
echo $x;
$x++;
myloop($x);
}
}
myloop();
|
Nay, I have the solution I wrote up on my work computer at the office I'll post it, I was looking for a more complete and versatile answer. But I suppose that will do the trick as well for something simplistic.
|
|
|
|
08-21-2009, 01:59 PM
|
#35 (permalink)
|
|
The Addict
Join Date: Jun 2008
Posts: 335
Thanks: 2
|
For the purpose of wanting to see this go on I'll just post the reply to my own challenge and say we move on to one that's less convoluted; suppose I can charge up my English to the confusion hah.
Use:
php Code:
$d = array('foo', 'rootof', 'doaine', 'fofid'); Loop ($d, 0, 10, function(& $value, & $i){ if( $i == 0 ) $value = 'This is cool'; if( $i == 3 ) $value = 'This is the last element?'; }); print_r($d);
Function:
php Code:
function Loop ( Array & $data, $from, $to, Closure $callback){ static $count; if( $count == 0 ) { $count = $from; $callback($data[ $count], $count); ++ $count; Loop ($data, $from, $to, $callback); } if( $count < $to && array_key_exists($count, $data)) { $callback($data[ $count], $count); ++ $count; Loop ($data, $from, $to, $callback); }}
|
|
|
|
08-21-2009, 02:31 PM
|
#36 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Challenge 7
Let me open by saying, I've no idea if this one will be super-easy or impossible. The hint in the code should provide a useful starting point. OK on with the challenge.
Given the mystical code below, implement the function challenge7 so as to output the encoded, hidden message. Only the insides of the function (denoted by the "your code here" comment) can be modified, no other parts of the script. The resulting message will be 22 characters in length, containing only valid ASCII characters and will constitute a short, plain-English sentence like one might post in this forum.
PHP Code:
<?php
function challenge7($message) { // Your code here }
ob_start('challenge7'); // Hint: Base 64 echo ' ============ US 06ID cgcn R hcnl5bn Vw IGdu cm8 gVg ============ '; ob_end_flush();
|
|
|
|
08-25-2009, 02:27 PM
|
#37 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
Are you sure you encoded it right? It comes out as gibberish when converted to ascii or anything else.
|
|
|
|
08-25-2009, 10:52 PM
|
#38 (permalink)
|
|
The Wanderer
Join Date: Sep 2007
Posts: 7
Thanks: 0
|
Quote:
Originally Posted by Village Idiot
Are you sure you encoded it right? It comes out as gibberish when converted to ascii or anything else.
|
Same with my efforts but I am no expert on decoding.
PHP Code:
<?php
function challenge7($message) {
$encodedMsg = '
============
US 06ID cgcn
R hcnl5bn Vw
IGdu cm8 gVg
============
';
return (str_replace($encodedMsg, base64_decode($encodedMsg), $message));
}
ob_start('challenge7');
// Hint: Base 64
echo '
============
US 06ID cgcn
R hcnl5bn Vw
IGdu cm8 gVg
============
';
ob_end_flush();
?>
Outputs:
Code:
Q-: 7 rtaryynup gnro V
I also tried a bunch of different alterations of the encoded string. Any more hints you can give?
|
|
|
|
08-26-2009, 11:19 AM
|
#39 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
I like scrambled eggs because they are so deliciouse and they make me faint.
You asked for a hint,
enjoy ;)
-CF
|
|
|
|
09-28-2009, 06:16 PM
|
#40 (permalink)
|
|
The Contributor
Join Date: Mar 2009
Location: US
Posts: 76
Thanks: 0
|
Everyone give up on posting a challenge?
Here is a new one ...
Decrypt the following string
Code:
dc:f5:16:77:f2:b6:99:7b
:e4:fc:88:e2:c0:80:44:e8
:6d:26:3e:b5:d2:8e:1f:f5
:3e:f5:44:cf:6a:bd:f0:9e
:44:d0:6a:a0:24:3e:f4:d7
Hint ... the result is 32 bytes long
This is composed of a encrypting Hybrid algorithm using various encryption methods, I doubt that this is crackable (but that is the challenge)
Challenge Level: Advanced
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|