Lukas S. Posted July 24, 2012 at 01:46 AM Report Share #469883 Posted July 24, 2012 at 01:46 AM (edited) Bem tava a ver um site e vi lá desafio para programadores criando programas que sejam capazes de eles próprios resolverem os problemas deste site http://challenge.greplin.com/ Gostaria que ao resolvessem colocassem aqui Feito e enviassem as respostas por pm .... E que venham aqui dizer se conseguiram ou não Edited July 24, 2012 at 03:25 AM by Lukas S. E o Impossível foi criado por pessoas fracas pra acabar com o sonho das pessoas fortes. Não deixes que acabem com o teu. Sonha , luta , ambiciona e realiza. Se amas , se gostas tu vais conseguir. Cala todas as pessoas que um dia duvidaram de ti e prova que foste mais forte de qualquer outro. Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted July 24, 2012 at 03:16 AM Report Share #469892 Posted July 24, 2012 at 03:16 AM eu tenho isso feito e já testei no site, foi ate bastante simples ... IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
Lukas S. Posted July 24, 2012 at 03:22 AM Author Report Share #469894 Posted July 24, 2012 at 03:22 AM Podes colocar aqui ? E o Impossível foi criado por pessoas fracas pra acabar com o sonho das pessoas fortes. Não deixes que acabem com o teu. Sonha , luta , ambiciona e realiza. Se amas , se gostas tu vais conseguir. Cala todas as pessoas que um dia duvidaram de ti e prova que foste mais forte de qualquer outro. Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted July 24, 2012 at 03:25 AM Report Share #469896 Posted July 24, 2012 at 03:25 AM (edited) isto foi quase tudo à brute force ... pode ser que apareça alguém com tempo para implementar algoritmos mais eficientes #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> void printSubString(char * string, int index, int size) { int i; for (i = 0; i < size; i++) printf("%c", string[i+index]); } int fibonacci(int x1, int x2) { return x1 + x2; } int isprime(int x) { int i; for (i = 2; i <= sqrt(x); i++) { if ((x % i) == 0) return 0; } return 1; } int dfs(int array[], int size, int target, int sum, int index) { int i, count = 0; for (i = index; i >= 0; i--) { if (sum + array[i] == target) count++; else if (sum + array[i] < target) count += dfs(array, size, target, sum + array[i], i - 1); } return count; } void exec1() { char * source = "FourscoreandsevenyearsagoourfaathersbroughtforthonthiscontainentanewnationconceivedinzLibertyanddedicatedtothepropositionthatallmenarecreatedequalNowweareengagedinagreahtcivilwartestingwhetherthatnaptionoranynartionsoconceivedandsodedicatedcanlongendureWeareqmetonagreatbattlefiemldoftzhatwarWehavecometodedicpateaportionofthatfieldasafinalrestingplaceforthosewhoheregavetheirlivesthatthatnationmightliveItisaltogetherfangandproperthatweshoulddothisButinalargersensewecannotdedicatewecannotconsecratewecannothallowthisgroundThebravelmenlivinganddeadwhostruggledherehaveconsecrateditfaraboveourpoorponwertoaddordetractTgheworldadswfilllittlenotlenorlongrememberwhatwesayherebutitcanneverforgetwhattheydidhereItisforusthelivingrathertobededicatedheretotheulnfinishedworkwhichtheywhofoughtherehavethusfarsonoblyadvancedItisratherforustobeherededicatedtothegreattdafskremainingbeforeusthatfromthesehonoreddeadwetakeincreaseddevotiontothatcauseforwhichtheygavethelastpfullmeasureofdevotionthatweherehighlyresolvethatthesedeadshallnothavediedinvainthatthisnationunsderGodshallhaveanewbirthoffreedomandthatgovernmentofthepeoplebythepeopleforthepeopleshallnotperishfromtheearth"; char * target = NULL; int size = strlen(source); int s, i, j; target = malloc(size + 1); for (i = size - 1; i > 0; i--) target[size - i] = source[i]; target[size] = '\0'; for (s = 10; s > 0; s--) { for (i = size - s; i > 0; i--) { for (j = size - s; j > 0; j--) { if (strncmp(&(source[i]), &(target[j]), s) == 0) { printf("exec1 >> found : "); printSubString(source, i, s); printf("\n"); free(target); return; } } } } free(target); } void exec2() { int x1 = 0; int x2 = 1; int s, d, i, found = 0; while (!found) { i = fibonacci(x1, x2); x1 = x2; x2 = i; if (isprime(i) && i > 227000) found = 1; } i += 1; s = 0; d = 2; while (i != 1) { if (isprime(d) && i % d == 0) { s += d; while (i % d == 0) i /= d; } else ++d; } printf("exec2 >> found : %d\n", s); } void exec3() { int array[] = {3, 4, 9, 14, 15, 19, 28, 37, 47, 50, 54, 56, 59, 61, 70, 73, 78, 81, 92, 95, 97, 99}; int size = sizeof(array) / sizeof(int); int s, i; s = 0; for (i = size - 1; i >= 2; i--) s += dfs(array, size, array[i], 0, i - 1); printf("exec3 >> found : %d\n", s); } int main() { exec1(); exec2(); exec3(); return 0; } Edited July 24, 2012 at 03:26 AM by HappyHippyHippo IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
Lukas S. Posted July 24, 2012 at 03:27 AM Author Report Share #469897 Posted July 24, 2012 at 03:27 AM (edited) Esse código no primeiro nivel e um bocado malsito .... deixo aqui uma solução mais fácil easy Edited July 24, 2012 at 03:32 AM by Lukas S. E o Impossível foi criado por pessoas fracas pra acabar com o sonho das pessoas fortes. Não deixes que acabem com o teu. Sonha , luta , ambiciona e realiza. Se amas , se gostas tu vais conseguir. Cala todas as pessoas que um dia duvidaram de ti e prova que foste mais forte de qualquer outro. Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted July 24, 2012 at 03:28 AM Report Share #469898 Posted July 24, 2012 at 03:28 AM nop ... corre o código que te aparece as 3 soluções IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
Lukas S. Posted July 24, 2012 at 03:34 AM Author Report Share #469901 Posted July 24, 2012 at 03:34 AM Já vi.... Alguma vez tinhas exprimentado fazer usando Download da string para uma var? E o Impossível foi criado por pessoas fracas pra acabar com o sonho das pessoas fortes. Não deixes que acabem com o teu. Sonha , luta , ambiciona e realiza. Se amas , se gostas tu vais conseguir. Cala todas as pessoas que um dia duvidaram de ti e prova que foste mais forte de qualquer outro. Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted July 24, 2012 at 03:40 AM Report Share #469902 Posted July 24, 2012 at 03:40 AM (edited) Já vi.... Alguma vez tinhas exprimentado fazer usando Download da string para uma var? download ?? eu fiz copy paste do que eles apresentaram estar agora a abrir ligações tcp/ip para pedir um recurso a um servidor http ... uff que trabalheira Esse código no primeiro nivel e um bocado malsito .... deixo aqui uma solução mais fácil easy tu não deves estar bem acordado, o código que apresentas-te é exatamente igual ao meu só que em VB ou C# (uma .net qualquer) ... vai dormir antes de dizer esse tipo de coisas ... Edited July 24, 2012 at 03:41 AM by HappyHippyHippo IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
Lukas S. Posted July 24, 2012 at 03:45 AM Author Report Share #469904 Posted July 24, 2012 at 03:45 AM download ?? eu fiz copy paste do que eles apresentaram estar agora a abrir ligações tcp/ip para pedir um recurso a um servidor http ... uff que trabalheira tu não deves estar bem acordado, o código que apresentas-te é exatamente igual ao meu só que em VB ou C# (uma .net qualquer) ... vai dormir antes de dizer esse tipo de coisas ... LooooooooooooL desculpa não tinha visto bem ... sorry é mesmo sono 😉 E o Impossível foi criado por pessoas fracas pra acabar com o sonho das pessoas fortes. Não deixes que acabem com o teu. Sonha , luta , ambiciona e realiza. Se amas , se gostas tu vais conseguir. Cala todas as pessoas que um dia duvidaram de ti e prova que foste mais forte de qualquer outro. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now