Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> CodeChallange #1
soliniak
post
Post #1





Grupa: Zarejestrowani
Postów: 66
Pomógł: 0
Dołączył: 8.08.2009

Ostrzeżenie: (0%)
-----


Coś dla "ambitniejszych" użytkowników serwisu (IMG:style_emoticons/default/wink.gif)
Czy jest ktoś w stanie napisać skrypt (i nie mam na myśli metod bruteforce (IMG:style_emoticons/default/tongue.gif) ) który mógłby rozwiązać poniższą zagadkę? (IMG:style_emoticons/default/smile.gif)
Ja sam nie jestem w stanie czegoś takie zrobić, a zastanawia mnie jakby taki kod mógł wyglądać (IMG:style_emoticons/default/wink.gif)
(IMG:http://img-9gag-fun.9cache.com/photo/aeY1ONQ_700b.jpg)
Pozdrawiam
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
!*!
post
Post #2





Grupa: Zarejestrowani
Postów: 4 298
Pomógł: 447
Dołączył: 16.11.2006

Ostrzeżenie: (0%)
-----


Internet podpowiada kodem

  1. $index = "01246";
  2. $base = strlen($index);
  3. $len = 3;
  4.  
  5. $x = array();
  6.  
  7. for ($i = 0, $l = pow(strlen($index), $len); $i < $l; $i++) {
  8. $x[] = str_pad(dec2any($i, $base, $index), $len, "0", STR_PAD_LEFT);
  9. }
  10.  
  11. function dec2any( $num, $base=62, $index=false ) {
  12. if (! $base ) {
  13. $base = strlen( $index );
  14. } else if (! $index ) {
  15. $index = substr( $index ,0 ,$base );
  16. }
  17. $out = "";
  18. for ( $t = floor( log10( $num ) / log10( $base ) ); $t >= 0; $t-- ) {
  19. $a = floor( $num / pow( $base, $t ) );
  20. $out = $out . substr( $index, $a, 1 );
  21. $num = $num - ( $a * pow( $base, $t ) );
  22. }
  23. return $out;
  24. }
  25.  
  26. echo '<pre>';
  27. echo count($x);
  28. print_r($x);


I nie możesz wykluczyć bruteforce od strony programistycznej, a to że da się to rozwiązać w głowie to inna bajka (IMG:style_emoticons/default/wink.gif)
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 11.10.2025 - 05:01