| devonrevenge (668) | |
|
yeah kay, but in order for it to specific you would have to dictate more or less whats in it, else i could just go and get something from th net right? but then it has to be within my skill range (i got the hang of beginner style linked lists) i got something in the pipline, but i still need to think about it lots | |
|
|
|
| iseeplusplus (297) | |
|
Write a program that correctly guesses a combination of 4, 2 digit, numbers/symbols. Symbols may be from the following set: {!, @, #, $, %, ^, &, *, ?, <, >, ~}. For example, a combination may be: 4$-79-##-@1 Your program must first generate the random combination. Then your program may make an unlimited amount of guesses. The feedback from each test must be true or false. Bonus points if your program uses concurrency. | |
|
Last edited on
|
|
| devonrevenge (668) | |
| hrmm, kay. | |
|
|
|
| Catfish3 (117) | ||
|
Write a program that reverses a file (byte by byte). It has to work on both text files and binary files. It gets the input file and new output file as command line parameters. For example:
In the above usage example, by reversing outputFile.bin, you must get a new file identical to the original inputFile.jpg. http://www.cplusplus.com/forum/articles/13355/ http://www.cprogramming.com/tutorial/lesson14.html http://cplusplus.com/reference/fstream/ | ||
|
|
||
| devonrevenge (668) | |
|
bucky talks about that at the end of his youtube thing, i never listened to that one cos thats when i got exited about sdl, im allready working iseeplusplus's one, urs next, i was actually sad when i ran out of challenges; although that was one of the ones i didnt do. urs is next | |
|
|
|
| devonrevenge (668) | |||
|
is this the definition of spaghetti code cos it aint going well, i proly a bit rusty can i get tiny tiny hints
| |||
|
|
|||
| Catfish3 (117) | |
|
In solving iseeplusplus' problem, I disregarded the dashes completely. They're aesthetic, and not part of the problem. They're probably there to encourage a concurrent solution. Anyway, the problem is that you need to brute force the randomly generated combination. And since you have 22 symbols in groups of 8, you get a total of 228 permutations... I think. Which is a lot. So iseeplusplus, could we see your own solution for now? Bonus points for concurrency using the C++11 library. @ devonrevenge: a hint would be to use backtracking to generate each permutation until you stumble upon the right one. http://en.wikipedia.org/wiki/Backtracking | |
|
|
|
| devonrevenge (668) | |
| oh yeah 54875873536 is a big number, best not repeat stuff | |
|
|
|
| Catfish3 (117) | |||||
Digits and symbols, letters excluded. At least you forgot about the uppercase ones. | |||||
|
|
|||||
| iseeplusplus (297) | |||
I havn't tested it, nor have I tried doing it in parallel yet, but this is how I would go about it.
Making it run in parallel shouldn't be too difficult. Just test the first numPermutation / numThreads in the first thread, initialize symbolIndex2[] to start at numPermutations / numThreads, and have it run for the same number of iterations, and so on. | |||
|
Last edited on
|
|||
| chrisname (5896) | |
| Can someone elaborate on iseeplusplus' task? I'm not sure what it's supposed to do. Generate four pairs of two digits/symbols? Randomly or iteratively? Then the user or the program guesses? What's the correct string? The example one in the post? | |
|
|
|
| Catfish3 (117) | |
|
@ chrisname: I understand it as: Randomly generate a permutation (with repetition) of length 8, consisting of decimal digits and the given symbols. Then brute force it. | |
|
|
|
| iseeplusplus (297) | |
|
Yeah, it doesn't really make a difference wether you consider it 4 pairs of characters, or just 8 characters I guess. You are supposed to brute force it. You need to generate a random combo just so you have something to brute force. | |
|
Last edited on
|
|
| devonrevenge (668) | |||
|
how is this concurrent? i dont see how its possible to get more than one thing at a time running. any idea how i can escape my crack function once i got the right code??
| |||
|
Last edited on
|
|||
| Jackson Marie (456) | |
|
Write a program that locks the computer input and does some crazy actions (suggestions) : crazy mouse moving, random messages, and showing crazy characters... Consider : windows.h And do some beep sounds... (Crazy, but good exercise) | |
|
|
|
| iseeplusplus (297) | |
|
What I posted isn't concurrent. To get more than one thing running at a time, you need to spawn a number of threads each testing a different portion of the domain. If one thread finds the correct combination, it needs to notify the other threads so they can terminate. Think about a combo of 3 numbers from 1 to 3. Makes for 3^3 possible permutations: 111, 112, 113, 121, 122, 123, 131, 132, 133, 211, 212, 213, 221, 222, 223, 231, 232, 233, 311, 312, 313, 321, 322, 323, 331, 332, 333 In the case of our problem, we have 22 symbols. I have the symbols in an array, so I can pretend that the index which corresponds to it is the symbol as I'm generating permutations. This way you can imagine you have some very large number represented in a base 22 numerical system. You count up from 1 to 22^8 in this numerical system, and you get all of the combinations. So based off of my example, you would need to figure out what is numPermutations / numThreads in base 22. Then initialize separate symbolIndex[]'s to start at some offsets, and run the permutation generating loop for numPermutations / numThreads iterations, for each thread, each starting with it's own symbolIndex initialized appropriately. For example, if I were testing in base 10, the permutations for a 3 digit combo, that would be 10^3 permutations (1000). If I spawn 100 threads, then the first checks 0 through 9, the second thread checks 10 through 19, and so on. | |
|
Last edited on
|
|
| devonrevenge (668) | |||
|
wait wait i am sticking to thing im doing now... @jackson marie i am trying to stick to sdl api for now, i will have to play with all that later, why dont you do a 'prove your not spoonlicker exercice, they fun XD' perhaps you could help me actually guys, my functions fine-ish im sure i will eventualy solve it but can you see why im not going on to do the second pair? the console tells me i found the first pair and then starts again, i was hoping the bool would cancel that one and move on to crack pair two here 'tis
i havnt finnished making it beautiful yet but i need to test it with couts here and there etc | |||
|
Last edited on
|
|||
| devonrevenge (668) | |
|
wait i got it :D i love that feeling when i finish the code could you hint on how i can concurrentify it? | |
|
Last edited on
|
|
| iseeplusplus (297) | |
|
Your testing pairs individually instead of the whole combo at once. That means you only need to test a max of 7744, with your set, times. If you test the whole combo at once, you need to test a maximum of 54,875,873,536 times, as in the problems specifications, or with your set, 14,048,223,625,216 times. | |
|
Last edited on
|
|
| devonrevenge (668) | |||
|
Proof i not spoonlicker :D can i get some constructive criticism please? (on the code) and if you consider yourself a beginner please try and write a more efficient code :P EDIT: oh @iseeplusplus, i thought it would be better to break it down :/ kay i get on changing it. EDIT:would you judge me if i made it flick through combinations in green letters? (you know, red head , blonde brunette)
and you can see all my working out too. how you make that concurrent? | |||
|
Last edited on
|
|||