|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On December 03 2012 06:09 Fyodor wrote:Show nested quote +On December 03 2012 05:56 darkness wrote: Java: Is it possible to send output across the network to every user within a linked a list? If yes, how? I've tried some google search, but I found nothing. for each loop? I'm not sure I understand at what level your problem is.
Some users are added to a linked list. I want to deliver a msg to all of them. They're all connected. loop is ok, but how do I make sure everyone receives the message? E.g. out.println("text") doesn't ask for receiver.
|
On December 03 2012 08:24 darkness wrote:Show nested quote +On December 03 2012 06:09 Fyodor wrote:On December 03 2012 05:56 darkness wrote: Java: Is it possible to send output across the network to every user within a linked a list? If yes, how? I've tried some google search, but I found nothing. for each loop? I'm not sure I understand at what level your problem is. Some users are added to a linked list. I want to deliver a msg to all of them. They're all connected. loop is ok, but how do I make sure everyone receives the message? E.g. out.println("text") doesn't ask for receiver.
That depends on what you want to send it through...
|
What does a <> b mean in Python?
|
On December 03 2012 18:51 Arnstein wrote: What does a <> b mean in Python?
a does not equal b. It's like != in c-syntax.
a = 1 b = 2
a <> b => true
|
On December 03 2012 18:51 Arnstein wrote: What does a <> b mean in Python?
I know nothing about Python but a simple Google search came up with the answer in half a minute...
Checks if the value of two operands are equal or not, if values are not equal then condition becomes true.
|
On December 03 2012 18:57 Thorakh wrote:I know nothing about Python but a simple Google search came up with the answer in half a minute... Checks if the value of two operands are equal or not, if values are not equal then condition becomes true.
I didn't find it with Google, because the search would not include <>. So if I searched "What does <> mean in Python?" I would get: "What does Python mean?" etc. Of course I would rather get the answer quickly from Google instead of waiting for an answer here. Thanks for the answer!
On December 03 2012 18:56 Tobberoth wrote:a does not equal b. It's like != in c-syntax. a = 1 b = 2 a <> b => true
After checking it in Python, this is what I could conclude as well, but I just don't see the logic behind it? a < b means that a is less than b and vice versa, so it seems logical to me that a <> b means that a is less than b and b is less than a, which would return False all the time? Also, Python already have !=. Maybe I'm just stupid? Thanks anyways for clearing up my confusion
|
On December 03 2012 08:42 Morfildur wrote:Show nested quote +On December 03 2012 08:24 darkness wrote:On December 03 2012 06:09 Fyodor wrote:On December 03 2012 05:56 darkness wrote: Java: Is it possible to send output across the network to every user within a linked a list? If yes, how? I've tried some google search, but I found nothing. for each loop? I'm not sure I understand at what level your problem is. Some users are added to a linked list. I want to deliver a msg to all of them. They're all connected. loop is ok, but how do I make sure everyone receives the message? E.g. out.println("text") doesn't ask for receiver. That depends on what you want to send it through...
Post more code! Put it on github and link for easiness.
On December 03 2012 18:51 Arnstein wrote: What does a <> b mean in Python?
Did they just stick this in there for people coming from php (it's not exactly the same thing in php but it's close - in php it checks for !equality after implicit type conversions), or is there another language they're both getting this syntax from?
|
On December 03 2012 19:36 teamamerica wrote:Show nested quote +On December 03 2012 08:42 Morfildur wrote:On December 03 2012 08:24 darkness wrote:On December 03 2012 06:09 Fyodor wrote:On December 03 2012 05:56 darkness wrote: Java: Is it possible to send output across the network to every user within a linked a list? If yes, how? I've tried some google search, but I found nothing. for each loop? I'm not sure I understand at what level your problem is. Some users are added to a linked list. I want to deliver a msg to all of them. They're all connected. loop is ok, but how do I make sure everyone receives the message? E.g. out.println("text") doesn't ask for receiver. That depends on what you want to send it through... Post more code! Put it on github and link for easiness. Did they just stick this in there for people coming from php (it's not exactly the same thing in php but it's close - in php it checks for !equality after implicit type conversions), or is there another language they're both getting this syntax from? <> Is used in both SQL and Visual basic.
|
I didn't find it with Google, because the search would not include <>. So if I searched "What does <> mean in Python?" I would get: "What does Python mean?" etc. Of course I would rather get the answer quickly from Google instead of waiting for an answer here. Thanks for the answer! Searched for "python operators".
|
On December 03 2012 19:17 Arnstein wrote:Show nested quote +On December 03 2012 18:57 Thorakh wrote:On December 03 2012 18:51 Arnstein wrote: What does a <> b mean in Python?
I know nothing about Python but a simple Google search came up with the answer in half a minute... Checks if the value of two operands are equal or not, if values are not equal then condition becomes true. I didn't find it with Google, because the search would not include <>. So if I searched "What does <> mean in Python?" I would get: "What does Python mean?" etc. Of course I would rather get the answer quickly from Google instead of waiting for an answer here. Thanks for the answer! Show nested quote +On December 03 2012 18:56 Tobberoth wrote:On December 03 2012 18:51 Arnstein wrote: What does a <> b mean in Python?
a does not equal b. It's like != in c-syntax. a = 1 b = 2 a <> b => true After checking it in Python, this is what I could conclude as well, but I just don't see the logic behind it? a < b means that a is less than b and vice versa, so it seems logical to me that a <> b means that a is less than b and b is less than a, which would return False all the time? Also, Python already have !=. Maybe I'm just stupid? Thanks anyways for clearing up my confusion  Think of it like this: a <> b
Is a smaller than b? Yes? Then they are not equal, so true. If not, is a bigger than b? If yes, they are not equal, so true. If both are false (when they are the same), it returns false.
|
On December 03 2012 20:14 Tobberoth wrote:Show nested quote +On December 03 2012 19:17 Arnstein wrote:On December 03 2012 18:57 Thorakh wrote:On December 03 2012 18:51 Arnstein wrote: What does a <> b mean in Python?
I know nothing about Python but a simple Google search came up with the answer in half a minute... Checks if the value of two operands are equal or not, if values are not equal then condition becomes true. I didn't find it with Google, because the search would not include <>. So if I searched "What does <> mean in Python?" I would get: "What does Python mean?" etc. Of course I would rather get the answer quickly from Google instead of waiting for an answer here. Thanks for the answer! On December 03 2012 18:56 Tobberoth wrote:On December 03 2012 18:51 Arnstein wrote: What does a <> b mean in Python?
a does not equal b. It's like != in c-syntax. a = 1 b = 2 a <> b => true After checking it in Python, this is what I could conclude as well, but I just don't see the logic behind it? a < b means that a is less than b and vice versa, so it seems logical to me that a <> b means that a is less than b and b is less than a, which would return False all the time? Also, Python already have !=. Maybe I'm just stupid? Thanks anyways for clearing up my confusion  Think of it like this: a <> b Is a smaller than b? Yes? Then they are not equal, so true. If not, is a bigger than b? If yes, they are not equal, so true. If both are false (when they are the same), it returns false.
Ah, it makes much more sense if you think of it like that 
|
For all those that know C++:
The program i'm looking at outputs a total count of all the records within x number of files, what would stop it from displaying over a billion? Instead of displaying a billion, it chops of the right number. e.g. 1,000,000,123 100,000,012
Any ideas? Don't really want to post the code as there is tonnes of it, and i never use C++.
|
On December 03 2012 00:47 Recognizable wrote: Hey, I just started coding but I keep messing up the syntax for else, elif and if statements in Python. Especially when to whitespace and where to put and, or and not. Could someone give me an example? Would be very much appreciated because I just can't figure it out :/ Also, are there other sites like CodeAcademy? I really like the "Review" parts where you have to solve these puzzles and code yourself with help ofcourse, but everything else is kinda boring to me.
Edit: Figured it out with the help of google. Still don't fully understand what whitespace does but atleast my code works. I believe I had no problems in Java with if and else statements. Check out http://codingbat.com/. Pretty cool tutorials for both Python and Java.
|
On December 04 2012 00:07 Rixxe wrote:
For all those that know C++:
The program i'm looking at outputs a total count of all the records within x number of files, what would stop it from displaying over a billion? Instead of displaying a billion, it chops of the right number. e.g. 1,000,000,123 100,000,012
Any ideas? Don't really want to post the code as there is tonnes of it, and i never use C++.
Is the threshhold at which the bug happens really exactly a billion? As in, it works correctly for 999,999,999 but not for 1,000,000,000? That's an odd number to have a problem with, since it's not close to the maximum value boundary for any numerical number type (int or unsigned int would freak out much earlier, and long still has lots of space), so I would guess your error is either in how you're storing the string or how you're displaying it.
Is it possible that you're outputting your value using a string that's defined as an array of characters, and you've only allocated enough space to the array to allow 9 digits?
|
On December 04 2012 00:20 AmericanUmlaut wrote:Show nested quote +On December 04 2012 00:07 Rixxe wrote:
For all those that know C++:
The program i'm looking at outputs a total count of all the records within x number of files, what would stop it from displaying over a billion? Instead of displaying a billion, it chops of the right number. e.g. 1,000,000,123 100,000,012
Any ideas? Don't really want to post the code as there is tonnes of it, and i never use C++.
Is the threshhold at which the bug happens really exactly a billion? As in, it works correctly for 999,999,999 but not for 1,000,000,000? That's an odd number to have a problem with, since it's not close to the maximum value boundary for any numerical number type (int or unsigned int would freak out much earlier, and long still has lots of space), so I would guess your error is either in how you're storing the string or how you're displaying it. Is it possible that you're outputting your value using a string that's defined as an array of characters, and you've only allocated enough space to the array to allow 9 digits? In this day and age virtually every int is (at least) 32 bits. Both signed and unsigned ints can easily handle a billion.
|
On December 04 2012 00:20 AmericanUmlaut wrote:Show nested quote +On December 04 2012 00:07 Rixxe wrote:
For all those that know C++:
The program i'm looking at outputs a total count of all the records within x number of files, what would stop it from displaying over a billion? Instead of displaying a billion, it chops of the right number. e.g. 1,000,000,123 100,000,012
Any ideas? Don't really want to post the code as there is tonnes of it, and i never use C++.
Is the threshhold at which the bug happens really exactly a billion? As in, it works correctly for 999,999,999 but not for 1,000,000,000? That's an odd number to have a problem with, since it's not close to the maximum value boundary for any numerical number type (int or unsigned int would freak out much earlier, and long still has lots of space), so I would guess your error is either in how you're storing the string or how you're displaying it. Is it possible that you're outputting your value using a string that's defined as an array of characters, and you've only allocated enough space to the array to allow 9 digits?
This is what as been defined to store the 5 different totals:
int RECTOTS[5] = { 0, 0, 0, 0, 0 }; // record totals
It's difficult to see what else could be causing the issue, as half of it isn't commented. The error is when it becomes more than 9 digits, i can only look at output + the code. Unfortunatly i'm not able to debug it or i would.
Anything obvious that might contribute to the problem with the code below? Sorry it's not much to go on.
/* LOG_TOT() : display totals */ void LOG_TOT(int VAL, char *MSTR) { int LN; char FMSTR[12];
if (VAL == 0) return; // ignore zero totals
memset(ORBf, ' ', 80); LN = sprintf(ORBf, "%s", MSTR); ORBf[LN] = ' '; FMAT_NUM(VAL, FMSTR, 16); sprintf(&ORBf[36], " = %-s\n", FMSTR); XLOG_REC(ORBf); return;
}
|
umm, divide it by ten? that way it will strip the tens digit and would not show the decimal if you had int
|
On December 04 2012 00:33 Rixxe wrote:Show nested quote +On December 04 2012 00:20 AmericanUmlaut wrote:On December 04 2012 00:07 Rixxe wrote:
For all those that know C++:
The program i'm looking at outputs a total count of all the records within x number of files, what would stop it from displaying over a billion? Instead of displaying a billion, it chops of the right number. e.g. 1,000,000,123 100,000,012
Any ideas? Don't really want to post the code as there is tonnes of it, and i never use C++.
Is the threshhold at which the bug happens really exactly a billion? As in, it works correctly for 999,999,999 but not for 1,000,000,000? That's an odd number to have a problem with, since it's not close to the maximum value boundary for any numerical number type (int or unsigned int would freak out much earlier, and long still has lots of space), so I would guess your error is either in how you're storing the string or how you're displaying it. Is it possible that you're outputting your value using a string that's defined as an array of characters, and you've only allocated enough space to the array to allow 9 digits? This is what as been defined to store the 5 different totals: int RECTOTS[5] = { 0, 0, 0, 0, 0 }; // record totals
It's difficult to see what else could be causing the issue, as half of it isn't commented. The error is when it becomes more than 9 digits, i can only look at output + the code. Unfortunatly i'm not able to debug it or i would. Anything obvious that might contribute to the problem with the code below? Sorry it's not much to go on.
/* LOG_TOT() : display totals */ void LOG_TOT(int VAL, char *MSTR) { int LN; char FMSTR[12];
if (VAL == 0) return; // ignore zero totals
memset(ORBf, ' ', 80); LN = sprintf(ORBf, "%s", MSTR); ORBf[LN] = ' '; FMAT_NUM(VAL, FMSTR, 16); sprintf(&ORBf[36], " = %-s\n", FMSTR); XLOG_REC(ORBf); return;
}
What I gather from this code is that the number is formatted in FMSTR. What I gather from your earlier post is that the number includes commas (or periods) to separate thousands etc. This makes the total number of characters for 1,000,000,000 thirteen, but only eleven characters fit. Hence the weird behaviour.
|
On December 04 2012 00:42 Shenghi wrote:Show nested quote +On December 04 2012 00:33 Rixxe wrote:On December 04 2012 00:20 AmericanUmlaut wrote:On December 04 2012 00:07 Rixxe wrote:
For all those that know C++:
The program i'm looking at outputs a total count of all the records within x number of files, what would stop it from displaying over a billion? Instead of displaying a billion, it chops of the right number. e.g. 1,000,000,123 100,000,012
Any ideas? Don't really want to post the code as there is tonnes of it, and i never use C++.
Is the threshhold at which the bug happens really exactly a billion? As in, it works correctly for 999,999,999 but not for 1,000,000,000? That's an odd number to have a problem with, since it's not close to the maximum value boundary for any numerical number type (int or unsigned int would freak out much earlier, and long still has lots of space), so I would guess your error is either in how you're storing the string or how you're displaying it. Is it possible that you're outputting your value using a string that's defined as an array of characters, and you've only allocated enough space to the array to allow 9 digits? This is what as been defined to store the 5 different totals: int RECTOTS[5] = { 0, 0, 0, 0, 0 }; // record totals
It's difficult to see what else could be causing the issue, as half of it isn't commented. The error is when it becomes more than 9 digits, i can only look at output + the code. Unfortunatly i'm not able to debug it or i would. Anything obvious that might contribute to the problem with the code below? Sorry it's not much to go on.
/* LOG_TOT() : display totals */ void LOG_TOT(int VAL, char *MSTR) { int LN; char FMSTR[12];
if (VAL == 0) return; // ignore zero totals
memset(ORBf, ' ', 80); LN = sprintf(ORBf, "%s", MSTR); ORBf[LN] = ' '; FMAT_NUM(VAL, FMSTR, 16); sprintf(&ORBf[36], " = %-s\n", FMSTR); XLOG_REC(ORBf); return;
}
What I gather from this code is that the number is formatted in FMSTR. What I gather from your earlier post is that the number includes commas (or periods) to separate thousands etc. This makes the total number of characters for 1,000,000,000 thirteen, but only eleven characters fit. Hence the weird behaviour.
Great, thankyou for the explanation.
Cheers
|
original = raw_input('Enter a word:') word = original.lower() pyg = 'ay' new_wordV = word+pyg #w/Vowel new_wordC = original[1:]+word[0]+pyg #w/Consonant first = original[0] if len(original) > 0 and original.isalpha(): if first == "a" or first == "i" or first == "e" or first == "o" or first == "u" or first == "A" or first == "I" or first == "E" or first == "O" or first == "U" : print new_wordV else: print new_wordC else: print 'empty'
Can this be made to look easier/less lines of code? If so could you give me some pointers what I could do(don't do it for me) Because I once posted something here 5+ lines and it was all done in like 2 :O. Especially the line with all the first==, it bugs me. I tried messing around a bit but nothing worked. Also I'd like to add coding yourself(mostly) is really fun, I just spent 10 minutes pressing in random words and I was amazed at how it worked haha.
|
|
|
|