Jump to content

CaptainJolly

Member
  • Posts

    38
  • Joined

  • Last visited

Reputation Activity

  1. Like
    CaptainJolly got a reaction from Sundanc3 in Printing out Truth Tables for xOR, OR, and their equivalence in C   
    Perfect, thank you for the explanation!
     
    Just to update on my progress:
    Here's what I have so far.
        int p = 0, q = 0, r = 0;    //count++; p = count & 1; q = count & 2; r = count & 4;    for (int count = 0; count <= 7; count++)    {        r = count & 1;        q = (count & 2)/2;        p = (count & 4)/4;        printf("p:%d q:%d r:%d\n", p, q, r);    } Next step is just to get the bit values instead of the decimals.
     
    Thanks again!
     
    [EDIT] - Got the correct permutation and list of values
  2. Like
    CaptainJolly reacted to Sundanc3 in Printing out Truth Tables for xOR, OR, and their equivalence in C   
    Your implication and biconditional functions seem like they would behave correctly. As for the incrementation of p q and r. I would increment an int from 0-7, change that int to its binary expression. This will be the same as the combined numbers for p q and r. Then you would just have to find a way to separate those digits so you can operate on them separately. You can use a bit mask. If you don't know what that is. This is an example
     
     
    Say I have the bit string     0 1 1   and I only wanted to know what the first value is. I can do an AND operation on those bits    0 1 1   (3 & 1) = 1   Another example     1 1 1   7 & 4 = 4 ( this would be to find your p value for iteration number 7)
                                                                                                                                                                                                           0 0 1                                                      1 0 0
                                                                                                                                                                                                          --------                                                    ---------
                                                                                                                                                                                                           0 0 1                                                      1 0 0
     
    This method would only bring down the first value in the string. Then if I wanted to know what value existed in the first value place I would compare it with the int value 1(if true then value is 1) or 0. The second place would be 2 (if true, then the value is 1) or 0 (if true then the value is 0). The third place would be 4(if true then the value would be 1) or 0. 
     
     
    I hope that makes somewhat sense. There is probably a better and more elegant way but this is just what I came up with off the top of my head right now. Hope it helps 
     
     
    EDIT: Looking back at the pseudocode you have above. What I have said is essentially that but instead of saying p = count & 4. You would need to find the bit value because that expression would not result in what you want. It would give you either a 4 or 0 (not 1 or 0). 
  3. Like
    CaptainJolly got a reaction from Forlorenes in Five-Hour Developer Freebie Bundle   
    Learn the fundamentals to HTML Javascript JQuery HTML5 all in 1 hour sessions FOR FREE!
     
    Enjoy!
     
    https://deals.lockergnome.com/sales/the-5-hour-developer-freebie-bundle
  4. Like
    CaptainJolly got a reaction from emachado99 in [NewEgg] Kingston SSDNow 55% Off - 240GB - Shell Shocker   
    Makes sense why they're selling them so cheap now. I guess to get rid of their stock of the bad NANDs.
     
    Best of luck to those who make the purchase I'll stay away from this one. Thanks for the share indefinitely.
  5. Like
    CaptainJolly got a reaction from Maxibonbits in Five-Hour Developer Freebie Bundle   
    Learn the fundamentals to HTML Javascript JQuery HTML5 all in 1 hour sessions FOR FREE!
     
    Enjoy!
     
    https://deals.lockergnome.com/sales/the-5-hour-developer-freebie-bundle
  6. Like
    CaptainJolly reacted to GarnetDevil in [USA] $9 NZXT S340 (Amazon)   
    Price:
    $8.76 + $59.45 shipping
     

  7. Like
    CaptainJolly got a reaction from nanox760 in Five-Hour Developer Freebie Bundle   
    Learn the fundamentals to HTML Javascript JQuery HTML5 all in 1 hour sessions FOR FREE!
     
    Enjoy!
     
    https://deals.lockergnome.com/sales/the-5-hour-developer-freebie-bundle
  8. Like
    CaptainJolly got a reaction from Wingfan in Thermal compound   
    I've been using the Antec Formula 7 Thermal Paste for all my personal as well as Freelance use and I've never had any re-occuring heat issues from machines I've taken in DUE to heat issues .
  9. Like
    CaptainJolly reacted to DoubleY in How did you guys save up for your PC?   
    I watered plants. Lot and lots of plants
  10. Like
    CaptainJolly reacted to Cacao in What do you think about my new website?   
    You don't say?
  11. Like
    CaptainJolly got a reaction from Camul in Free USPS Shipping Boxes with Worldwide Free Shipping!   
    Mortgage free houses for EVERYONE!
  12. Like
    CaptainJolly got a reaction from MellowCream in Free USPS Shipping Boxes with Worldwide Free Shipping!   
    Mortgage free houses for EVERYONE!
  13. Like
    CaptainJolly got a reaction from emachado99 in Free USPS Shipping Boxes with Worldwide Free Shipping!   
    Mortgage free houses for EVERYONE!
  14. Like
    CaptainJolly reacted to jam08060 in The under 100 line challenge!   
    So I got bored and wrote an encryption program using the one-time-pad algorithm in under 100 lines.
    import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.security.SecureRandom;import java.util.Arrays;public class Leonardo { public static void main(String args[]){ FileInputStream in = null; FileOutputStream out = null; FileOutputStream keyfile = null; try { String filename = ""; //Enter file to encrypt here in = new FileInputStream(filename); out = new FileOutputStream(filename.split("\\.")[0] + "_encrypted." + filename.split("\\.")[1]); keyfile = new FileOutputStream(filename.split("\\.")[0] + "_key.txt"); int b; int index = 0; byte[] binaryContents = new byte[1024]; while((b=in.read())!=-1){ if(index >= binaryContents.length) { binaryContents = Arrays.copyOf(binaryContents, (binaryContents.length + binaryContents.length/4)); } binaryContents[index] = (byte)b; index++; } if(binaryContents.length > index) { binaryContents = Arrays.copyOf(binaryContents, index); } in.close(); SecureRandom random = new SecureRandom(); byte[] key = new byte[binaryContents.length]; random.nextBytes(key); for(int i=0; i<binaryContents.length; i++) { binaryContents[i] = (byte)(binaryContents[i] ^ key[i]); } out.write(binaryContents); keyfile.write(key); out.close(); keyfile.close(); } catch(FileNotFoundException fnfe) { System.err.println(fnfe.getMessage()); } catch(IOException ie) { System.err.println(ie.getMessage()); } finally { try { if(in != null) in.close(); if(out != null) out.close(); if(keyfile != null) keyfile.close(); } catch(IOException ie) { System.err.println(ie.getMessage()); } } }} Also, I wrote a decryption program in under 100 lines to go along with it.
    import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.util.Arrays;public class Michelangelo { public static void main(String args[]){ FileInputStream in = null; FileOutputStream out = null; FileInputStream key = null; try{ String filename = ""; //Enter file to be decrypted here in = new FileInputStream(filename);; out = new FileOutputStream(filename.replaceAll("_encrypted", "")); key = new FileInputStream(filename.replaceAll("_encrypted", "_key")); int b; int index = 0; byte[] binaryContents = new byte[1024]; while((b=in.read())!=-1){ if(index >= binaryContents.length) { binaryContents = Arrays.copyOf(binaryContents, (binaryContents.length + binaryContents.length / 4)); } binaryContents[index] = (byte)b; index++; } if(binaryContents.length > index) { binaryContents = Arrays.copyOf(binaryContents, index); } in.close(); byte[] keyContents = new byte[binaryContents.length]; key.read(keyContents); key.close(); for(int i=0; i<binaryContents.length; i++) { out.write((int)(binaryContents[i] ^ keyContents[i])); } out.close(); } catch(FileNotFoundException fnfe) { System.err.println(fnfe.getMessage()); } catch(IOException ie) { System.err.println(ie.getMessage()); } finally { try { if(in != null) in.close(); if(key != null) key.close(); if(out != null) out.close(); } catch(IOException ie) { System.err.println(ie.getMessage()); } } }} Enjoy!
  15. Like
    CaptainJolly got a reaction from Thunderjolt in Google Fiber is (most likely) coming to my area!   
    Lucky you... Congratulations!
     

  16. Like
    CaptainJolly reacted to madknight3 in Google Fiber is (most likely) coming to my area!   
    I vote that since many people on the forums will be jealous of this person, and because jealousy can cause social problems, he should be banned to keep the community happy!
     

    Congrats on the chance to one day possibly have Google Fiber.
  17. Like
    CaptainJolly got a reaction from Levent in What determines "Ping"?   
    Ping is considered the latency in ms for a packet to go from one end to the other and back(don't know how long it took if the information doesn't come back to us).
     
    Will going upgrading your bandwidth and the backbone of your network help with your latency?
    Most definitely, especially when you're measurement is via a light wave(fiber optics).
    HOWEVER, it should also be accounted for that depending on the server location, time of day, number of users on that network trying to access that same packet, etc etc your ping may go up or it may go down. Of course, if you can get through past certain network destinations faster than another node on that same network your ping will almost always be lower than theirs.
     
    Note sure if I'm making sense there but let me know.
×