[AccessD] OT: Friday Puzzles

Drew Wutka DWUTKA at Marlow.com
Fri Apr 23 11:11:27 CDT 2010


And actually, I mis-grouped my post (clumped group three in with 2...).
My code just put the numbers in with VBcrlf in between....

So the new code is:

Private Sub Command1_Click()
Dim Victims As Collection
Dim vt As Victim
Dim i As Long
Dim strTemp As String
Dim strPaste As String
Dim intRound As Long
Set Victims = New Collection
For i = 1 To 1000
    Set vt = New Victim
    vt.OriginalPosition = i
    Victims.Add vt, "ID:" & i
    Set vt = Nothing
Next i
intRound = 1
Do Until Victims.Count <= 1
    For i = 1 To Victims.Count Step 2
        Set vt = Victims(i)
        vt.Shot = True
        Set vt = Nothing
    Next i
    'Remove shot victims
    strTemp = ""
    For Each vt In Victims
        If vt.Shot Then
            Victims.Remove "ID:" & vt.OriginalPosition
        Else
            strTemp = strTemp & vt.OriginalPosition & ","
        End If
    Next
    Me.List1.AddItem Left(strTemp, Len(strTemp) - 1)
    If Victims.Count > 1 Then
        strPaste = strPaste & "Round " & intRound & " Survivors:" &
vbCrLf & Left(strTemp, Len(strTemp) - 1) & vbCrLf & vbCrLf
    Else
        strPaste = strPaste & "Final Survivor:" & vbCrLf & Left(strTemp,
Len(strTemp) - 1) & vbCrLf
    End If
    intRound = intRound + 1
Loop
Clipboard.Clear
Clipboard.SetText strPaste
End Sub

(Watch for line wrap)

With the following saved as 'Victim' Class Module:

Option Explicit
Public OriginalPosition As Long
Public Shot As Boolean
Private Sub Class_Initialize()
Shot = False
End Sub

Which will display the results in a listbox, and put the following into
the clipboard to paste (of course, this is VB6, VBA doesn't have the
'clipboard' object)

Round 1 Survivors:
2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,5
2,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,1
00,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,1
36,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,1
72,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,2
08,210,212,214,216,218,220,222,224,226,228,230,232,234,236,238,240,242,2
44,246,248,250,252,254,256,258,260,262,264,266,268,270,272,274,276,278,2
80,282,284,286,288,290,292,294,296,298,300,302,304,306,308,310,312,314,3
16,318,320,322,324,326,328,330,332,334,336,338,340,342,344,346,348,350,3
52,354,356,358,360,362,364,366,368,370,372,374,376,378,380,382,384,386,3
88,390,392,394,396,398,400,402,404,406,408,410,412,414,416,418,420,422,4
24,426,428,430,432,434,436,438,440,442,444,446,448,450,452,454,456,458,4
60,462,464,466,468,470,472,474,476,478,480,482,484,486,488,490,492,494,4
96,498,500,502,504,506,508,510,512,514,516,518,520,522,524,526,528,530,5
32,534,536,538,540,542,544,546,548,550,552,554,556,558,560,562,564,566,5
68,570,572,574,576,578,580,582,584,586,588,590,592,594,596,598,600,602,6
04,606,608,610,612,614,616,618,620,622,624,626,628,630,632,634,636,638,6
40,642,644,646,648,650,652,654,656,658,660,662,664,666,668,670,672,674,6
76,678,680,682,684,686,688,690,692,694,696,698,700,702,704,706,708,710,7
12,714,716,718,720,722,724,726,728,730,732,734,736,738,740,742,744,746,7
48,750,752,754,756,758,760,762,764,766,768,770,772,774,776,778,780,782,7
84,786,788,790,792,794,796,798,800,802,804,806,808,810,812,814,816,818,8
20,822,824,826,828,830,832,834,836,838,840,842,844,846,848,850,852,854,8
56,858,860,862,864,866,868,870,872,874,876,878,880,882,884,886,888,890,8
92,894,896,898,900,902,904,906,908,910,912,914,916,918,920,922,924,926,9
28,930,932,934,936,938,940,942,944,946,948,950,952,954,956,958,960,962,9
64,966,968,970,972,974,976,978,980,982,984,986,988,990,992,994,996,998,1
000

Round 2 Survivors:
4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,10
0,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,17
2,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,24
4,248,252,256,260,264,268,272,276,280,284,288,292,296,300,304,308,312,31
6,320,324,328,332,336,340,344,348,352,356,360,364,368,372,376,380,384,38
8,392,396,400,404,408,412,416,420,424,428,432,436,440,444,448,452,456,46
0,464,468,472,476,480,484,488,492,496,500,504,508,512,516,520,524,528,53
2,536,540,544,548,552,556,560,564,568,572,576,580,584,588,592,596,600,60
4,608,612,616,620,624,628,632,636,640,644,648,652,656,660,664,668,672,67
6,680,684,688,692,696,700,704,708,712,716,720,724,728,732,736,740,744,74
8,752,756,760,764,768,772,776,780,784,788,792,796,800,804,808,812,816,82
0,824,828,832,836,840,844,848,852,856,860,864,868,872,876,880,884,888,89
2,896,900,904,908,912,916,920,924,928,932,936,940,944,948,952,956,960,96
4,968,972,976,980,984,988,992,996,1000

Round 3 Survivors:
8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,1
76,184,192,200,208,216,224,232,240,248,256,264,272,280,288,296,304,312,3
20,328,336,344,352,360,368,376,384,392,400,408,416,424,432,440,448,456,4
64,472,480,488,496,504,512,520,528,536,544,552,560,568,576,584,592,600,6
08,616,624,632,640,648,656,664,672,680,688,696,704,712,720,728,736,744,7
52,760,768,776,784,792,800,808,816,824,832,840,848,856,864,872,880,888,8
96,904,912,920,928,936,944,952,960,968,976,984,992,1000

Round 4 Survivors:
16,32,48,64,80,96,112,128,144,160,176,192,208,224,240,256,272,288,304,32
0,336,352,368,384,400,416,432,448,464,480,496,512,528,544,560,576,592,60
8,624,640,656,672,688,704,720,736,752,768,784,800,816,832,848,864,880,89
6,912,928,944,960,976,992

Round 5 Survivors:
32,64,96,128,160,192,224,256,288,320,352,384,416,448,480,512,544,576,608
,640,672,704,736,768,800,832,864,896,928,960,992

Round 6 Survivors:
64,128,192,256,320,384,448,512,576,640,704,768,832,896,960

Round 7 Survivors:
128,256,384,512,640,768,896

Round 8 Survivors:
256,512,768

Final Survivor:
512

Drew (code boy) Wutka


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Simon Bamber
Sent: Friday, April 23, 2010 10:56 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] OT: Friday Puzzles

Susan,

You are forgetting that the devil is in the detail and Drew dropped a
zero so got shot.  No second chances when you are lined up like that.

Simon
The information contained in this transmission is intended only for the person or entity 
to which it is addressed and may contain II-VI Proprietary and/or II-VI Business 
Sensitive material. If you are not the intended recipient, please contact the sender 
immediately and destroy the material in its entirety, whether electronic or hard copy. 
You are notified that any review, retransmission, copying, disclosure, dissemination, 
or other use of, or taking of any action in reliance upon this information by persons 
or entities other than the intended recipient is prohibited.





More information about the AccessD mailing list