[AccessD] OT: Friday Puzzles

Kevin thewaddles at sbcglobal.net
Fri Apr 23 20:32:27 CDT 2010


70% get medals...

I want to be #512 in the first line...And yes I did this in 3 minutes

Sub FindLastMan()
    Call FindLastManStanding(1000)
End Sub
Sub FindLastManStanding(TotalCount As Variant)
    Dim i                                         As Variant
    Dim x                                         As Variant
    Dim lastRow                                   As Variant
    Dim lastCol                                   As Variant
    Dim col                                       As Collection

    'Fill Column A with Total Count
    For i = 1 To TotalCount
        Cells(i, 1).Value = i
    Next
    
    'Determine Last Row and Last Column
    lastRow = ActiveSheet.UsedRange.Row - 1 +
ActiveSheet.UsedRange.Rows.Count
    lastCol = ActiveSheet.UsedRange.Column - 1 +
ActiveSheet.UsedRange.Columns.Count

    Do While Cells(lastRow + 1, lastCol).End(xlUp).Row <> 1
    'Odd Guys get shot
        Set col = New Collection
        lastRow = ActiveSheet.UsedRange.Row - 1 +
ActiveSheet.UsedRange.Rows.Count
        lastCol = ActiveSheet.UsedRange.Column - 1 +
ActiveSheet.UsedRange.Columns.Count
        For Each i In Range(Cells(1, lastCol), Cells(lastRow + 1,
lastCol).End(xlUp))
            If IsOdd(i.Row) = False Then
                col.Add i.Value
            End If
        Next
        'Populate next column with Even Guys
        For x = 1 To col.Count
            Cells(x, lastCol + 1).Value = col(x)
        Next
        Set col = Nothing
    Loop
End Sub
Function IsOdd(num As Variant) As Boolean
    If num Mod 2 = 1 Then
        IsOdd = True
    End If
End Function

Kevin Waddle


thewaddles at sbcglobal.net
It is necessary to rouse the heart to pray, otherwise it will become quite
dry. The attributes of prayer must be: love of God, sincerity, and
simplicity. --John of Kronstadt
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller
Sent: Friday, April 23, 2010 6:43 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] OT: Friday Puzzles

If you must have a Friday joke... "Don't make a fool of yourself. God beat
you to it."

Two puzzles for Friday.

You are one of 1000 people who shall be executed using the following
procedure. You are lined up single-file, shoulder to shoulder. Every other
person will be shot, starting with the first. The survivors of that round
will line up shoulder to shoulder, and the process repeated, until there is
only one person left. Assuming that you wish to be the sole surivor, what
position in the line would you choose? You have 3 minutes to decide.


At the end of a battle, the general regrouped his soldiers. They had done
badly. 70% of them had lost, at least, one eye. 75% had lost at least one
ear. 80% had lost, at minimum, an arm. 85% of the soldiers had lost one leg.
The general wants to know how many of his men had lost, at minimum, one eye,
one ear, one arm and one leg. He is stingy with the medals so he wants to
reward the fewest number of soldiers. What percentage of the soldiers should
receive medals? You have 5 minutes to decide.

Arthur
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list