Forum
A place to discuss topics/games with other webDiplomacy players.
Page 666 of 1419
FirstPreviousNextLast
Enzyme (100 D)
16 Oct 10 UTC
Can someone explain what just happened?
New to the site, and I'm having some trouble interpreting the symbols/rules. I'm *NOT* looking for advice, just an explanation of what happened.
5 replies
Open
Le Masticateur (119 D)
15 Oct 10 UTC
Question About Retreating
I have a question regarding the rules of retreating. I'm new to this game and I didn't venture to read all of the threads, so I'm sorry if this topic was already reviewed.
5 replies
Open
basvanopheusden (2176 D)
16 Oct 10 UTC
a great gunboat game
To all in this game, well played.
3 replies
Open
fuzz (0 DX)
16 Oct 10 UTC
need 1 more like rite now
1 reply
Open
Z (0 DX)
13 Oct 10 UTC
Question for Programmers
Im making an array, and I insert a value at a point in the array, and any unused area is assigned a zero. eg [7,3] and each previous cell gets a zero. My question is how do i write a method that deletes the excess zeros, but keeps the value. Later on, ill have to have it delete zeros when i have information in the first, third, seventh cell etc, and the rest are filled with zeros.
Page 2 of 4
FirstPreviousNextLast
 
stratagos (3269 D(S))
13 Oct 10 UTC
Solution:
Step One: Print Our Array Values
Step Two: Get an intern to do it for you

(kidding)
abgemacht (1076 D(G))
13 Oct 10 UTC

login as: arlevin
[email protected]'s password:
Linux DeepwaterHorizon 2.6.32-25-generic #44-Ubuntu SMP Fri Sep 17 20:05:27 UTC 2010 x86_64 GNU/Linux
Oh, are we writing real code now? OK:

program reorg

implicit none

integer :: N,i,j
double precision :: tmp
double precision, dimension(:), allocatable :: A

print *,'How many elements are in your array?'
read *,N

allocate(A(1:N))

open(10,file='array',status='old')

read(10,*)A(:)

close(10)

do i=1,N
if(A(i)==0)then
do j=i+1,N
if(A(j)/=0)then
tmp=A(i)
A(i)=A(j)
A(j)=tmp
EXIT
endif
enddo
endif
enddo

open(10,file='array_new',status='replace')

write(10,*)A(:)

close(10)

end program reorg
figlesquidge (2131 D)
13 Oct 10 UTC
Interesting thread.
Am I missing something, or do we not even know the intended language?
abgemacht (1076 D(G))
13 Oct 10 UTC
Ignore the garbage at top, copy+pasted too much...
abgemacht (1076 D(G))
13 Oct 10 UTC
@figle

We gave him the general approach and pseudo code. Now I guess we're all just doing it in our language of choice.
fortknox (2059 D)
13 Oct 10 UTC
at least it hasn't broken into a language flamewar (yet) ;)

I was just offering Z a working example when I posted mine.
abgemacht (1076 D(G))
13 Oct 10 UTC
That's because everyone knows the best language is TI's Basic for the TI-83 Plus.
Draugnar (0 DX)
13 Oct 10 UTC
Like hell. It's 360/370 Assembly Language. ZAP anyone? :-)
Draugnar (0 DX)
13 Oct 10 UTC
@Abgemacht - the double loop example is inefficient and you should never abort for next loops early. Instead, use a while loop where the condition to stop the loop is the condition that you EXIT on. Also, your outerloop should only go to N-1.
abgemacht (1076 D(G))
13 Oct 10 UTC
@Draug

Agreed on all points.
figlesquidge (2131 D)
13 Oct 10 UTC
Sorry, reason I asked was more due to the properties of different languages and what the most efficient methods would actually be.
abgemacht (1076 D(G))
13 Oct 10 UTC
Draug's method would be the best, I'd say.
fortknox (2059 D)
13 Oct 10 UTC
A do/while/for/until loop all breaks down to a single type of loop in assembly. I don't think breaking out of an inner loop early is really that dangerous, or even that different in machine code (and if it is inefficient, you'll only notice it if the array has like 1million+ cells).

It's like people's aversion to 'gotos'. Gotos == jump in assembly, and a function call is a jump. I'm not saying I have gotos (it makes the code unreadable as hell), but it is a valid way to code and it doesn't make things inefficient or anything.
Draugnar (0 DX)
13 Oct 10 UTC
Fortknox is right, the breaking out isn't less efficient. It's more the readability and maintainability issues (i.e. standards) that I don't like about it. The efficiency comes in not restarting a second loop at i+1. Instead, maintaining a counter that you increment as needed is mroe efficient. Only by milliseconds on a small array, but a thousands or millions of elements array would start to show the slow down, especially if the number of zeros was about equal to the number of non-zeros in that particular example.
Draugnar (0 DX)
13 Oct 10 UTC
Just to get some timings, I made the array 1000 and had a random number generator generate the numbers such that 50% of the time there should be zero and the other 50%, some number. The array population ran so fast I had to reseed the generator with a seed from the previous random number to not wind up with just a few blocks of the same number.

Anyhow, here is the output with the times.

Start: 16:44:29.8141
Raw
array [ 0, 438305, 353579, 346409, 0, 0, 0, 0, 0, 478509, 0, 0, 0, 48539, 0, 925
52, 233922, 0, 91848, 446501, 151454, 129779, 0, 0, 0, 0, 0, 0, 221651, 0, 0, 16
750, 350256, 327090, 0, 0, 443703, 405425, 9249, 0, 493638, 0, 441239, 149451, 0
, 0, 0, 0, 0, 60628, 328192, 0, 327471, 0, 0, 0, 275310, 0, 57690, 442619, 96385
, 0, 79257, 0, 0, 0, 47346, 475169, 40362, 0, 152383, 462895, 0, 308474, 352613,
0, 161884, 25806, 433901, 0, 112774, 0, 0, 0, 54314, 0, 0, 152212, 128167, 4114
87, 0, 0, 0, 145208, 61266, 0, 0, 0, 0, 0, 0, 57132, 0, 0, 0, 435588, 0, 0, 0, 4
33742, 0, 0, 85454, 59042, 0, 309818, 492235, 0, 0, 91521, 0, 429749, 482591, 48
1043, 0, 227919, 381428, 368984, 308374, 110081, 0, 157108, 0, 168284, 0, 0, 0,
55742, 0, 13908, 0, 149284, 466847, 416897, 272453, 70370, 0, 351063, 0, 0, 0, 0
, 381642, 168001, 0, 7732, 118773, 0, 267409, 0, 158074, 0, 0, 40278, 0, 0, 1129
40, 441228, 402772, 14890, 0, 0, 361213, 0, 84526, 248351, 0, 0, 410710, 27034,
0, 0, 0, 342091, 0, 101417, 0, 289225, 187740, 0, 0, 0, 102360, 181404, 0, 0, 0,
0, 0, 0, 0, 211557, 458437, 0, 0, 437956, 27145, 0, 333604, 0, 0, 375514, 0, 22
2402, 160970, 0, 242371, 472069, 0, 0, 0, 236752, 0, 0, 426345, 146822, 255723,
0, 0, 132742, 0, 0, 0, 0, 0, 0, 0, 149740, 0, 0, 340420, 0, 312494, 0, 143459, 3
39392, 0, 269997, 0, 0, 0, 0, 174497, 376293, 0, 213762, 406255, 0, 0, 0, 177269
, 0, 0, 0, 0, 450136, 167471, 0, 0, 0, 176907, 421301, 33537, 304005, 0, 251678,
0, 136196, 0, 219177, 339331, 0, 0, 346873, 0, 0, 0, 279092, 452031, 163442, 0,
208387, 370191, 0, 201788, 0, 283821, 1342, 0, 0, 412594, 276326, 423612, 35843
8, 0, 0, 297600, 499746, 0, 0, 158563, 51337, 474598, 0, 201807, 0, 0, 279268, 3
98886, 0, 0, 0, 170482, 0, 372965, 83550, 361244, 0, 0, 413460, 0, 276523, 34139
9, 206082, 179842, 0, 0, 0, 0, 333208, 20334, 0, 0, 0, 0, 30929, 0, 259547, 0, 1
97861, 321334, 0, 240445, 280914, 310954, 0, 273362, 0, 452788, 0, 0, 0, 149644,
0, 498893, 58515, 443503, 0, 133261, 0, 0, 0, 66390, 0, 352902, 0, 197188, 0, 4
55543, 0, 192282, 0, 46527, 0, 64833, 126638, 0, 255965, 321790, 0, 0, 348881, 0
, 0, 171674, 0, 380390, 91508, 0, 0, 0, 0, 0, 0, 148670, 0, 0, 418078, 256749, 0
, 77331, 398215, 322733, 0, 0, 0, 91875, 0, 140871, 302679, 0, 0, 0, 137260, 0,
172733, 0, 7838, 495856, 452836, 0, 0, 499657, 191455, 0, 0, 253150, 0, 0, 40069
4, 415087, 0, 8170, 0, 292414, 202067, 0, 0, 60554, 0, 459923, 144021, 0, 0, 308
801, 185691, 405260, 0, 0, 0, 493762, 494228, 0, 0, 0, 0, 0, 0, 0, 443, 160658,
0, 290758, 65747, 0, 0, 141092, 0, 0, 0, 135533, 0, 0, 213602, 0, 208014, 0, 321
406, 356776, 0, 490599, 62960, 0, 0, 258392, 248027, 309646, 0, 117204, 62768, 3
18364, 138970, 172156, 378633, 190231, 216187, 287642, 188468, 180358, 311060, 3
44475, 186349, 161117, 325590, 184290, 487395, 212253, 66456, 22924, 0, 430522,
317359, 101529, 45968, 0, 359851, 0, 218873, 0, 0, 453706, 225843, 0, 187788, 0,
0, 246389, 0, 206450, 432358, 490235, 0, 0, 393846, 0, 39591, 66858, 37900, 0,
152775, 253619, 0, 0, 213422, 0, 428229, 396113, 184723, 0, 0, 0, 394573, 0, 0,
254297, 0, 0, 0, 0, 0, 347544, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224986, 107982, 256520
, 267839, 0, 241998, 0, 445140, 130602, 0, 0, 493922, 82279, 358670, 13684, 0, 3
12223, 0, 220780, 0, 0, 481769, 47435, 0, 0, 315129, 93079, 0, 412471, 18013, 17
3428, 0, 0, 0, 0, 0, 53716, 324420, 0, 143278, 0, 143265, 0, 0, 0, 0, 123802, 24
991, 0, 212501, 0, 343483, 0, 299018, 298842, 351986, 122884, 438552, 392632, 0,
0, 0, 226979, 301633, 441038, 141963, 0, 363230, 273116, 438353, 429994, 476793
, 459071, 37654, 129024, 129982, 0, 131577, 0, 0, 25975, 0, 197722, 0, 468875, 0
, 0, 0, 0, 0, 0, 0, 448781, 281171, 0, 164745, 0, 246672, 423345, 0, 439014, 0,
0, 358035, 273609, 0, 0, 406506, 0, 0, 0, 79399, 0, 0, 41931, 0, 309663, 0, 0, 6
9162, 0, 0, 0, 481530, 187785, 363868, 0, 381095, 401354, 215795, 496919, 0, 416
375, 0, 0, 275689, 0, 0, 253606, 0, 122471, 0, 0, 128956, 0, 386847, 391762, 112
181, 0, 299378, 371955, 433983, 431371, 0, 0, 0, 487822, 287862, 122037, 0, 0, 0
, 55038, 0, 142347, 402442, 0, 0, 88871, 186341, 0, 0, 278589, 0, 0, 155266, 0,
0, 473078, 0, 0, 0, 0, 0, 87283, 0, 0, 0, 0, 196760, 131063, 355197, 0, 0, 0, 0,
147875, 369579, 151436, 0, 0, 0, 62407, 0, 326398, 303944, 0, 0, 37542, 0, 0, 2
33085, 230601, 0, 0, 0, 0, 0, 0, 71857, 0, 287092, 0, 143932, 446565, 0, 75020,
73314, 0, 160511, 0, 0, 95185, 0, 403190, 388671, 295535, 0, 203097, 0, 215406,
273472, 421765, 438882, 0, 164016, 0, 0, 53905, 62805, 0, 94795, 33902, 0, 0, 39
9225, 0, 0, 0, 0, 177781, 21026, 240900, 0, 400716, 0, 345941, 61860, 0, 0, 6247
0, 0, 226874, 446975, 0, 0, 0, 0, 0, 0, 363681, 0, 0, 468367, 0, 46348, 94706, 0
, 144118, 0, 0, 0, 211022, 0, 76096, 202952, 0, 0, 0, 19471, 0, 0, 208249, 27549
8, 0, 0, 0, 0, 413741, 498161, 0, 0, 0, 66895, 367636, 79051, 0, 286805, 0, 4063
94, 239378, 0, 329054, 0, 0, 126397, 0, 0, 0, 0, 0, 136504, 0, 97681, 0, 16091,
71974, 0, 166402, 343375, 0, 0, 399091, 0, 0, 480728, 202683, 456199, 0, 411033,
0, 412548, 244762, 0, 474803, 0, 195668, 0, 0, 374384, 405071, 70688, 0, 0, 296
616, 433237, 0, 225381, 465981, 0, 211306, 329683, 471101, 0, 0, 0, 16984, 0, 0,
322263, 75270, 0, 0, 0, 0, 0, 496285, 0, 69167, 317950, 0, 380665, 0, 131871, 4
74851, 0, 326051, 22360, 156269, 0, 0, 0, 0, 97474, 0, 0, 0, 479574, 323870, 0,
0, 195981, 161744, 0, 0, 0, 0, 170128, 0, 139419]

Drained
array [ 438305, 353579, 346409, 478509, 48539, 92552, 233922, 91848, 446501, 151
454, 129779, 221651, 16750, 350256, 327090, 443703, 405425, 9249, 493638, 441239
, 149451, 60628, 328192, 327471, 275310, 57690, 442619, 96385, 79257, 47346, 475
169, 40362, 152383, 462895, 308474, 352613, 161884, 25806, 433901, 112774, 54314
, 152212, 128167, 411487, 145208, 61266, 57132, 435588, 433742, 85454, 59042, 30
9818, 492235, 91521, 429749, 482591, 481043, 227919, 381428, 368984, 308374, 110
081, 157108, 168284, 55742, 13908, 149284, 466847, 416897, 272453, 70370, 351063
, 381642, 168001, 7732, 118773, 267409, 158074, 40278, 112940, 441228, 402772, 1
4890, 361213, 84526, 248351, 410710, 27034, 342091, 101417, 289225, 187740, 1023
60, 181404, 211557, 458437, 437956, 27145, 333604, 375514, 222402, 160970, 24237
1, 472069, 236752, 426345, 146822, 255723, 132742, 149740, 340420, 312494, 14345
9, 339392, 269997, 174497, 376293, 213762, 406255, 177269, 450136, 167471, 17690
7, 421301, 33537, 304005, 251678, 136196, 219177, 339331, 346873, 279092, 452031
, 163442, 208387, 370191, 201788, 283821, 1342, 412594, 276326, 423612, 358438,
297600, 499746, 158563, 51337, 474598, 201807, 279268, 398886, 170482, 372965, 8
3550, 361244, 413460, 276523, 341399, 206082, 179842, 333208, 20334, 30929, 2595
47, 197861, 321334, 240445, 280914, 310954, 273362, 452788, 149644, 498893, 5851
5, 443503, 133261, 66390, 352902, 197188, 455543, 192282, 46527, 64833, 126638,
255965, 321790, 348881, 171674, 380390, 91508, 148670, 418078, 256749, 77331, 39
8215, 322733, 91875, 140871, 302679, 137260, 172733, 7838, 495856, 452836, 49965
7, 191455, 253150, 400694, 415087, 8170, 292414, 202067, 60554, 459923, 144021,
308801, 185691, 405260, 493762, 494228, 443, 160658, 290758, 65747, 141092, 1355
33, 213602, 208014, 321406, 356776, 490599, 62960, 258392, 248027, 309646, 11720
4, 62768, 318364, 138970, 172156, 378633, 190231, 216187, 287642, 188468, 180358
, 311060, 344475, 186349, 161117, 325590, 184290, 487395, 212253, 66456, 22924,
430522, 317359, 101529, 45968, 359851, 218873, 453706, 225843, 187788, 246389, 2
06450, 432358, 490235, 393846, 39591, 66858, 37900, 152775, 253619, 213422, 4282
29, 396113, 184723, 394573, 254297, 347544, 224986, 107982, 256520, 267839, 2419
98, 445140, 130602, 493922, 82279, 358670, 13684, 312223, 220780, 481769, 47435,
315129, 93079, 412471, 18013, 173428, 53716, 324420, 143278, 143265, 123802, 24
991, 212501, 343483, 299018, 298842, 351986, 122884, 438552, 392632, 226979, 301
633, 441038, 141963, 363230, 273116, 438353, 429994, 476793, 459071, 37654, 1290
24, 129982, 131577, 25975, 197722, 468875, 448781, 281171, 164745, 246672, 42334
5, 439014, 358035, 273609, 406506, 79399, 41931, 309663, 69162, 481530, 187785,
363868, 381095, 401354, 215795, 496919, 416375, 275689, 253606, 122471, 128956,
386847, 391762, 112181, 299378, 371955, 433983, 431371, 487822, 287862, 122037,
55038, 142347, 402442, 88871, 186341, 278589, 155266, 473078, 87283, 196760, 131
063, 355197, 147875, 369579, 151436, 62407, 326398, 303944, 37542, 233085, 23060
1, 71857, 287092, 143932, 446565, 75020, 73314, 160511, 95185, 403190, 388671, 2
95535, 203097, 215406, 273472, 421765, 438882, 164016, 53905, 62805, 94795, 3390
2, 399225, 177781, 21026, 240900, 400716, 345941, 61860, 62470, 226874, 446975,
363681, 468367, 46348, 94706, 144118, 211022, 76096, 202952, 19471, 208249, 2754
98, 413741, 498161, 66895, 367636, 79051, 286805, 406394, 239378, 329054, 126397
, 136504, 97681, 16091, 71974, 166402, 343375, 399091, 480728, 202683, 456199, 4
11033, 412548, 244762, 474803, 195668, 374384, 405071, 70688, 296616, 433237, 22
5381, 465981, 211306, 329683, 471101, 16984, 322263, 75270, 496285, 69167, 31795
0, 380665, 131871, 474851, 326051, 22360, 156269, 97474, 479574, 323870, 195981,
161744, 170128, 139419, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

End: 16:44:30.1341
Draugnar (0 DX)
13 Oct 10 UTC
Here is the guts of "static void Main(string[] args)"

// initialize an array of integers
System.Random r = new Random(System.DateTime.Now.Millisecond);
int[] array;
array = new int[1000];
int ran = r.Next(1, 1000000);
for (int i = 0; i < array.GetLength(0); i++)
{
r = new Random(ran);
ran = r.Next(1, 1000000);
if (ran < 500000)
{
array[i] = ran;
}
else
{
array[i] = 0;
}
}

// output the initialized array
System.Console.WriteLine(String.Format("Start: {0:HH:mm:ss.ffff}", System.DateTime.Now));
System.Console.WriteLine("Raw");
WriteArray(array);
System.Console.WriteLine();

// drain the array
DrainArray(array);

// output the array after draining
System.Console.WriteLine("Drained");
WriteArray(array);
System.Console.WriteLine();
System.Console.WriteLine(String.Format("End: {0:HH:mm:ss.ffff}", System.DateTime.Now));

System.Console.ReadLine();
Draugnar (0 DX)
13 Oct 10 UTC
For a more accurate read of the time, I just display the start and end time from either side of the Drain method.

1 million elements:
Start: 16:55:07.5431
End: 16:55:07.6001

10 million elements:
Start: 16:57:04.6421
End: 16:57:05.0861

It takes longer to setup the array than to drain it. :-)
Draugnar (0 DX)
13 Oct 10 UTC
Here's the new main I used:

System.Console.SetBufferSize(80, 1000);
// initialize an array of integers
System.Random r = new Random(System.DateTime.Now.Millisecond);
int[] array;
array = new int[10000000];
int ran = r.Next(1, 1000000);
for (int i = 0; i < array.GetLength(0); i++)
{
r = new Random(ran);
ran = r.Next(1, 1000000);
if (ran < 500000)
{
array[i] = ran;
}
else
{
array[i] = 0;
}
}

// output the initialized array
//System.Console.WriteLine("Raw");
//WriteArray(array);
//System.Console.WriteLine();

System.Console.WriteLine(String.Format("Start: {0:HH:mm:ss.ffff}", System.DateTime.Now));
// drain the array
DrainArray(array);
System.Console.WriteLine(String.Format("End: {0:HH:mm:ss.ffff}", System.DateTime.Now));
System.Console.WriteLine();

// output the array after draining
//System.Console.WriteLine("Drained");
//WriteArray(array);
//System.Console.WriteLine();

System.Console.ReadLine();
fortknox (2059 D)
14 Oct 10 UTC
@abgemacht : I do agree that Draug's method is more efficient. I don't even argue the point.
This was intended for a coding newbie, so I was making mine more readable. It's like a sorting algorithm... I'd go for a bucket sort to show a newbie instead of a quicksort (actually, I'd show them the strategy pattern and let them make multiple implementations... that, or I'd show them how to find the algorithm in some API or library somewhere).

This may be a whole different discussion, but efficiency should never be the purpose of code unless that is a direct requirement (like, this method will run during the prelaunch cycle of the spaceshuttle, so it needs to happen in 0.4s or less), or it is discovered to be a bottleneck in the program.

A foundation point of extreme programming is "make the code work, THEN make the parts efficient that need it." Point being, if you concentrate all your focus on making something you THINK needs to be efficient, you may be wasting your time, because it isn't the problem, but some other part is.
abgemacht (1076 D(G))
14 Oct 10 UTC
@fortknox

You and I are in complete agreement. I was merely responding to figle's question. You'll notice that my code wasn't as efficient either. There were two reasons for this 1) it was the first way I thought of doing it. 2) As you said, he's a newbie, so making him understand any way of doing it is more important that understanding the best way.

A decent part of my research is coding, but I spend very little time on optimization. The algorithms themselves are already more efficient, so, while code optimization is nice, it doesn't make that big of a difference overall.
Draugnar (0 DX)
14 Oct 10 UTC
Coming from the realm of web apps that run on a nationwide company, I automatically analyze for efficiency because we won't always have time to go back and rework it and the team gets dinged when the super users decide something is too slow. And, while this example would be easy to rework to be more efficient form either of the other two versions, not all patterns are so readily reworked.
abgemacht (1076 D(G))
14 Oct 10 UTC
Yes, but you have a specific reason to be effecient. I suppose i do too, but I'm not that great of a coder.
Draugnar (0 DX)
14 Oct 10 UTC
That and it's just the way I think...
abgemacht (1076 D(G))
14 Oct 10 UTC
haha yeah. My only point was that I was trying to answer figle's question, not bash fortKnox,
fortknox (2059 D)
14 Oct 10 UTC
Don't worry, abgemacht.... my heart... will heal... *sniff*

;-)
Draugnar (0 DX)
14 Oct 10 UTC
I might try converting fortknox's pattern to C# this weekend and do a time comparison. It's unfair to compare times between Java and C# as Java will lose that one because of the less optimized run anywhere byte code it cruches down to, versus C#'s environment specific byte code.
philcore (317 D(S))
14 Oct 10 UTC
Has anyone else noticed that having gotten his homework answer, Z has long ago abandoned the thread?
Draugnar (0 DX)
14 Oct 10 UTC
Yeah, but it's been a good programmers thread nonetheless.
abgemacht (1076 D(G))
14 Oct 10 UTC
Not only that, but I don't think he was even logged in long enough to get our answers.
orathaic (1009 D(B))
15 Oct 10 UTC
interesting convrsation definitely, to think i missed it all...

i'm still wondering why you had a array of (presumably) mostly zeros... i recall, in college, setting up an array of pointers, and pointing them at hte nawer of a calculation when they had it returned to them (so i could check if they were null and recursively call the calculation...)

The point being i wanted to reduce the memory usage by not assigning memory to each array element unless it was needed. (oh and because the recursive call i was given to work with did the calculation whenever it was asked for it, even when it had already worked out the answer 100 times... but i didn't want to add a very large new array as that might be bad...)

lots of fun...

Page 2 of 4
FirstPreviousNextLast
 

93 replies
curtis (8870 D)
15 Oct 10 UTC
gunboat live
7 replies
Open
Dpddouglass (908 D)
14 Oct 10 UTC
New public game, 150 pts, 3 day turns
http://webdiplomacy.net/board.php?gameID=39976
1 reply
Open
President Eden (2750 D)
15 Oct 10 UTC
HEY JACKASS, VOTE DRAW
In case you missed it the first couple times. You cannot advance past the stalemate line, you're not doing anything to try, so stop dragging the game out and vote draw. For the bystanders: http://webdiplomacy.net/board.php?gameID=40053#gamePanel
20 replies
Open
Stenrosen (1110 D)
15 Oct 10 UTC
Bug?
In this game (http://webdiplomacy.net/board.php?gameID=39585) Oz retreated a fleet from Dumont dUrville to Vostok (in spring 2003, retreats). It seems like a bug to me, but please enlighten me...
3 replies
Open
penguinflying (111 D)
15 Oct 10 UTC
Signaling in gunboat games?
Can someone please explain any standard conventions that exist for signaling in gunboat games? Like...I think ordering a support hold to someone else's unit must mean something, but I'm not sure what.
8 replies
Open
Fear Rua (133 D)
14 Oct 10 UTC
Moves saved or ready
Hi, another newby question. If you have moves saved but not ready when the movement phase ends, will these moves be implemented, or will you be treated as having not entered any moves?

Is there any help page that explains how the webdiplomacy interface works, as opposed to the rules of the game? All I can find are the FAQ, the introduction, and the rulebook, none of which provide many details of this.
6 replies
Open
peterwiggin (15158 D)
15 Oct 10 UTC
linux help?
In light of recent tradition . . .
6 replies
Open
Thucydides (864 D(B))
15 Oct 10 UTC
Remember my diplomacy club idea?
I just wanted you blokes to know that it's actually happening, I've been approved.
5 replies
Open
Iceray0 (266 D(B))
15 Oct 10 UTC
Fuck yea
I haven't played a game in forever and i've gone from barely breaking the top 40% to being in the top 30%
I am a badass. It's not due to new members, it's 100% badassness.
3 replies
Open
eaglesfan642 (0 DX)
12 Oct 10 UTC
Please join
Please join http://webdiplomacy.net/board.php?gameID=39922
75 bet
World diplomacy
2 replies
Open
Lando Calrissian (100 D(S))
14 Oct 10 UTC
Live Games Tonight
Is there any interest in a high-ish pot live gunboat tonight? I'd set up a game and make it password protected. I'm thinking maybe 50 yen buy-in. Reply or message if this interests you.
1 reply
Open
mapleleaf (0 DX)
09 Oct 10 UTC
read ZEITOUN...
...if you haven't read it already. It's by Dave Eggers.
2 replies
Open
Tom Bombadil (4023 D(G))
14 Oct 10 UTC
New 101d WTA anon game
36 hour phases. All press. Join up!
2 replies
Open
hopsyturvy (521 D)
14 Oct 10 UTC
Server errors
for info, *not* a moaning thread.
5 replies
Open
no pants (100 D)
13 Oct 10 UTC
StP bug?
see post
8 replies
Open
Thucydides (864 D(B))
12 Oct 10 UTC
Personal Philosophy
A this risk of appearing egotistical... I would like to share with you guys something I wrote.
33 replies
Open
Conservative Man (100 D)
13 Oct 10 UTC
What did I do wrong on this math problem?
I'm trying to find the equation of a parabola by using 3 of its points. The points are (1,6) (3,26) and (-2,21). I'm trying to find the form y=ax^2+bx+c. I worked out a to be 2.5, but the book says it is 3. You can find my work inside.
45 replies
Open
stratagos (3269 D(S))
14 Oct 10 UTC
ARARUGH!
I HATE MISORDERS!

That is all. The EOG comments on this one are going to be fucking *Fascinating* to read, when everyone asks WTF I was thinking
1 reply
Open
obiwanobiwan (248 D)
10 Oct 10 UTC
I am REALLY Losing Faith...
I am rapidly lost my faith in democracy--living through it the last decade plus, from the last couple disgraceful years of Clinton to Bush II's Regime to Obama's Bust (AND Ahnuld and our near-last education, jobs, etc. in CAL) right here in my home state, I now think maybe Plato was right...and Hobbes...I'm not advocating for "1984" or an Emperor or Reich here, but...well, all this bickering and I see FAR more hurt and waste than good...discuss?
126 replies
Open
stratagos (3269 D(S))
14 Oct 10 UTC
Whoo hoo, you go Chile!
You guys have one hell of a country - I can't see us in the states being able to pull off what you guys did anywhere *near* as smoothly. You should be *damn* proud of the bar you've set for the rest of us screwed up, selfish nations when it comes to caring about our citizens.
18 replies
Open
obiwanobiwan (248 D)
10 Oct 10 UTC
Give The Title Of Your Autobiography
Simple enough--one sentence, give a fitting title of your autobiography if you were to write it today.
57 replies
Open
jman777 (407 D)
13 Oct 10 UTC
Who Took The PSAT Today?
Did anyone here take the PSAT today? I did and had form W. It wasn't that bad except for the fact that I messed up some formulas.
8 replies
Open
baumhaeuer (245 D)
25 Aug 10 UTC
Experament
Details inside.
201 replies
Open
omgwhathappened (0 D)
14 Oct 10 UTC
Spring 1903
gameID=39477

need a replacement austria. has 6 centers, and no one is currently aggressive. italy, germany and england are fighting france, and austria is not under fire from either russia or turkey. good set up, and we'd like a replacement for the guy who JUST left.
2 replies
Open
Conservative Man (100 D)
09 Oct 10 UTC
Am I crazy?
See inside
75 replies
Open
Page 666 of 1419
FirstPreviousNextLast
Back to top