Countdown to PDC09: Hard Hat Challenges Are Back! (Sort of)

Download this episode

Download Video

Description

Do you easily get car sick?  If so, you’re in for a ride as Mike and Jennifer go mobile and take their show on the road this week.  This episode includes the return of the Hard Hat Challenge, starting with the apple pie puzzle from last year that remains unsolved to this day.  But there are other ways to win!  Enter the INETA coding challenge and you may win a free ticket to PDC.  Additional updates on sessions, hotels, PDC Classics and more are covered in this show, that’s very much on the go. 

http://microsoftpdc.com/ 

Tags:

PDC09, PDC 2009

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      Alex Keizer

      Sleeping in your car?!?

    • User profile image
      ZippyV

      Congratulations, you just won a 'internal only' PDC poster.

       

      EDIT: link to Ineta in the video is wrong.

    • User profile image
      Chris​Stepaniuk

      Darn, commented then clicked refresh... *tear*

    • User profile image
      Alex Keizer

      Cool!

    • User profile image
      wisnia

      There is no link to the blog post about embeding the pdc font into the SL app Sad

    • User profile image
      mswanson

      Good catch. Here's a link to David Isbitski's post.

       

      And by the way, nobody in this thread has answered the challenge correctly yet. The poster is for the first correct answer.

    • User profile image
      Ref'X

      New to the hard hat challenges here, but sounded fun. =) I'm pretty sure I'm on the right track... *pretty* sure... lol.

       

      -Stephen

    • User profile image
      Ref'X

      Yeah, nevermind. lol. The quest for the solution continues! I was focusing on groupings of 7 and dot matrix... and somehow fitting in pi along with the fact that you switched positions before showing it. Maybe that'll help someone else... or throw them completely off. lol.

       

      -Stephen

    • User profile image
      wisnia

      Is the vertical line in the first column, second row meaningful or not? It's on the picture you posted but not on the PDC 2008 video and just wondering.

    • User profile image
      gbrayut

      I see a pretty strong pattern that happens 5 times with certain rows "off by one" but I can't find any use for it. Seems to validate the empty cell at the end, but I can't find any way to relate it to Pie or Pi. Time for dinner, so I guess I'll have to try again in the morning. 

    • User profile image
      mswanson

      To tell you the truth, I never noticed that small vertical line. I can confirm that it's not important at all.

    • User profile image
      Adam​Speight2008

      Does the sequence go left to right then next line? or  Left column top to bottom Next Column?

    • User profile image
      CKurt

      Let's see if this is right.

       

      Is the answer: NOIZE ?

       

      Used letter - number subsitution with the numer of PI

    • User profile image
      ivan_

      Looks like a bunch of punch cards. http://en.wikipedia.org/wiki/Punch_card

      Smiley

       

      print them out, rotate back and forth and you get I ♥ PDC   Smiley

    • User profile image
      mswanson

      Sorry, CKurt...that isn't the correct answer. Sadly, ivan_, your answer isn't correct either.

       

      To answer Adam's question, the order is left column, top-to-bottom, next column, top-to-bottom, etc.

    • User profile image
      wisnia

      Hmm... every seven rows there is a blank row so there must some pattern, now just have decode it Big Smile

       

      And what's more, the groups are very symetrical in a vertical way. What I mean is that if a group of seven row begins with a row which has 6 black dots, it also ends with a row with 6 black dots... hmm...

    • User profile image
      Adam​Speight2008

      Solved it:

      It says SEE YOU AT PDC2008.

      I'll post method later.

    • User profile image
      Adam​Speight2008

      As promised the method. (Note: The zipped up solution is also available in the SandBox)

       

      Make sure that the textbox is using a Monospaced font, has Multiline and Scrollbars=Vertical

      Public Class Form1
       Private Sub ShowSolution(ByRef useThisTextBox As TextBox)
       ' Initialise and array of string lists.
       Dim columns(6) As List(Of String)
       For i As Integer = 0 To 6 : columns(i) = New List(Of String) : Next
       ' Get Digits of PI
       Dim piStr As String = My.Resources.pi.Replace(Environment.NewLine, "") 
      ' Get PDC Image text representation.
       Dim tfp As New FileIO.TextFieldParser("Resources/PDC2008.txt")
       Dim del() As String = {" "}
       tfp.Delimiters = del
       While tfp.EndOfData = False
       Dim f() = tfp.ReadFields 
      ' Place field into correct column. 
      For i As Integer = 0 To f.Count - 1
       columns(i).Add(f(i))
       Next
       End While tfp.Close()
       ' Collate the columns into a single column.
       For i As Integer = 0 To 5
       columns(6).AddRange(columns(i).ToArray)
       Next 
      ' Rotate Left by corrisponding PI digit
       For i As Integer = 0 To columns(6).Count - 1
       For j As Integer = 0 To Integer.Parse(piStr(i))
       columns(6)(i) = STR_ROR(columns(6)(i), False)
       Next
       Next
       ' Rotate To Right.
       For i As Integer = 0 To columns(6).Count - 1
       columns(6)(i) = STR_ROR(columns(6)(i), True)
       Next
       ' Build the output string.
       useThisTextBox.Text = ""
       For i As Integer = 0 To columns(6).Count - 1
       useThisTextBox.Text &= columns(6)(i) & ControlChars.NewLine
      Next
       ' Hide the ones.
       useThisTextBox.Text = Me.TextBox1.Text.Replace("1", " ")
       ' Replace 0 with # for higher contrast 
      useThisTextBox.Text = Me.TextBox1.Text.Replace("0", "#")
      End Sub
      Private Function STR_ROR(ByVal RotateThisString As String, Optional ByVal RotateToTheRight As Boolean = True) As String 
      ' A function to do the rotation either 1 place to the right, or to the left.
       If RotateToTheRight Then
       Return RotateThisString(RotateThisString.Length - 1) & RotateThisString.Substring(0, RotateThisString.Length - 1)
       Else
       Return RotateThisString.Substring(1, RotateThisString.Length - 1) & RotateThisString.Substring(0, 1)
       End If
       End Function 
       
      Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       ShowSolution(Me.TextBox1)
       End Sub
      End Class 

    • User profile image
      Adam​Speight2008

      LINQ-ified Shorter Version.

       

      Public Class Form1
      
       Private Sub ShowSolution(ByRef useThisTextBox As TextBox)
        ' Initialise and array of string lists.
        Dim columns(6) As List(Of String)
        For i As Integer = 0 To 6 : columns(i) = New List(Of String) : Next
        ' Get Digits of PI
        Dim piStr As String = My.Resources.pi.Replace(Environment.NewLine, "")
        ' Get PDC Image text representation.
        Dim tfp As New FileIO.TextFieldParser("Resources/PDC2008.txt")
        Dim del() As String = {" "}
        tfp.Delimiters = del
        While tfp.EndOfData = False
         Dim f() = tfp.ReadFields
         ' Place field into correct column.
         For i As Integer = 0 To f.Count - 1 : columns(i).Add(f(i)) : Next
        End While
        tfp.Close()
        ' Collate the columns into a single column.
        For i As Integer = 0 To 5 : columns(6).AddRange(columns(i).ToArray) : Next
        ' Rotate Left by corrisponding PI digit minus one to rotate right
        For i As Integer = 0 To columns(6).Count - 1 : columns(6)(i) = STR_ROR(columns(6)(i), False, Integer.Parse(piStr(i))- 1) : Next
       ' Build the output string. Hide the ones. Replace 0 with # for higher contrast
        useThisTextBox.Text = ((From T As String In columns(6) Select T).Aggregate( _
                               Function(current As String, nexta As String) current + ControlChars.NewLine + nexta)) _
                               .Replace("1", " ").Replace("0", "#")
       End Sub
      
      Private Function STR_ROR(ByVal RotateThisString As String, _
                                Optional ByVal RotateToTheRight As Boolean = True, _
                                Optional ByVal repeats As Integer = 0) As String
        ' A function to do the rotation either 1 place to the right, or to the left.  While repeats >= 0
         If RotateToTheRight Then
          RotateThisString = RotateThisString(RotateThisString.Length - 1) & RotateThisString.Substring(0, RotateThisString.Length - 1)
         Else
          RotateThisString = RotateThisString.Substring(1, RotateThisString.Length - 1) & RotateThisString.Substring(0, 1)
         End If
         repeats -= 1
        End While
        Return RotateThisString
       End Function
      
       Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ShowSolution(Me.TextBox1)
       End Sub
      End Class
      

    • User profile image
      Adam​Speight2008

       

      Get Byte values Directly From image

      Using the image found via link in a previous post.

      Public Class Form1
      
       Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim bmp As New Bitmap(My.Resources.PDC2008_Hard_Hat_Challenge_8)
        Dim Bytes As New List(Of Byte)
        Dim XPos As Single = 73
        Dim XStep As Single = 21
        Dim YPos As Single = 74
        Dim YStep As Single = 46
        Dim XGap As Single = 63
        Dim PixelBits As Byte = 0
        Dim Base As Single = 0
        For col As Integer = 0 To 5
         YPos = 74
         Dim RowStart = XPos + Base
         For row As Integer = 0 To 19
          PixelBits = 0
          XPos = RowStart
          For octetBit As Integer = 7 To 0 Step -1
           Dim pc = bmp.GetPixel(XPos, YPos)
           If pc.A = 255 AndAlso pc.R = 255 AndAlso pc.B = 255 AndAlso pc.G = 255 Then PixelBits += (2 ^ octetBit)
           bmp.SetPixel(XPos, YPos, Color.YellowGreen)
           XPos += XStep
          Next
          Bytes.Add(PixelBits)
          YPos += YStep
         Next
         Base = XGap - XStep
        Next
        Me.Pic_Image.Image = bmp
        Bytes.RemoveAt(119)
        Dim FinalStr As New System.Text.StringBuilder
        Dim PiDigit As String = My.Resources.pi.Replace(ControlChars.NewLine, "")
        For i As Integer = 0 To Bytes.Count - 1
         Bytes(i) = ROR(Bytes(i), Integer.Parse(PiDigit(i)) - 1)
         FinalStr.AppendLine(ByteToStr(Bytes(i)))
        Next
        Me.Output.Text = FinalStr.ToString.Replace("1", " ").Replace("0", "#")
       End Sub
      
       Private Function ByteToStr(ByVal x As Byte) As String
        Dim r As String = ""
        For i As Integer = 7 To 0 Step -1
         r &= If(((2 ^ i) And x) > 0, "1", "0")
        Next
        Return r
       End Function
      
       Private Function ROR(ByVal x As Byte, ByVal r As Integer) As Byte
        While r >= 0
         x = ((x And &H80) >> 7) + ((x And &H7F) << 1)
         r -= 1
        End While
        Return x
       End Function
      End Class

    • User profile image
      mswanson

      Great job and congratulations, Adam! That puzzle had gone unsolved for quite a long time. Drop us an e-mail at pdc09@microsoft.com with your name and mailing address, and we'll get one of our internal PDC09 posters sent to you. Thanks for sharing the method you used to solve the puzzle.

       

      I'm working on a new Hard Hat Challenge, and I hope I can finish it for this week's episode.

    • User profile image
      Adam​Speight2008

      Thank you, I've sent the email and if you want to "ruin" the poster it upto you.

      Sadly I won't be attending PDC2009 in body but I'll be there in spirit and vicariously through the sessions webcasts.

       Maybe I'll go sometime in the future.

      Have a great PDC2009.

       

      Edit: Topic Posting as </Dream.In.Code> containing

      A description of the effort.

    • User profile image
      wisnia

      Yes, congratulations! Smiley

      I'm just wondering, how this could be solved on paper as you mentioned in last years PDC video comment Wink

    • User profile image
      amyrc

      Whoops!  Typo in the video for INETA url for Code Challenge.  The correct url is: ineta.org/codechallenge

    • User profile image
      TheWoogy​Chuck

      I'm dissapointed.  I think Tommy needs more camera time!

    • User profile image
      Adam​Speight2008

      To do it manually. You need sheets of Paper, Scissors, Pen and Glue.

      Follow this method.

      1. Print out the image
      2. Label the columns Left to Right Rotate (Their positions rotated anticlockwise) A B C D E F
      3. Cut out the columns. (Ask a responsiable adult to do this for you.)
      4. Write on the righthand side of each, column row the corrisponding digit of PI (What they ate.)
      5. So the first few are 3, 1, 4, 1. 5, 9 etc
      6. Cut out row 1 of column A.
      7. Cut out the first 3 digits (Take One if doing on computer (Off by one))
      8.  Note: 1 -> 1 digits etc, 0 & 8 -> 0 digts, 9 ->1digit. (Eg Row A1 = [001] [10000] )
      9. Glue the two peices to another peice of paper. First part last. (Eg Row A1 = [10000] [001] )
      10. Repeat step 6 - 9 for the other rows and columns.
      11. Stand back about from it & squint.
      12. On the answer is spelt out vertically.

      Simples.

       

      The bold are the clues from the video.

       

      Here a the first 8 row with cut corrispoding cut points.

      [001][10000] [10000][001] [.####][##.]
      [0][0011110] [0011110][0] [##....#][#]
      [1111][0011] [0011][1111] [##..][....]
      [1][1000000] [1000000][1] [.######][ ]
      [11100][111] [111][11100] [...][...##]
      [0][0011110] [0011110][0] [##.....][#]
      [01][100000] [100000][01] [.#####][#.]
      [000000][00] [00][000000] [..][......]
      
      


      If you interested in the full text with cut points, change the code so the output.text is this.

       Dim o As String = ""
        For q As Integer = 0 To Bytes.Count - 1
         Dim rr = Integer.Parse(PiDigit(q)) Mod 8
         Dim bs = Convert.ToString(Bytes(q), 2).PadLeft(8, "0")
         o &= String.Format("[{1}][{0}]{2}", bs.Substring(0, rr), bs.Substring(rr), ControlChars.NewLine)
        Next
        Me.Output.Text = o


      I think this section of code maybe possible to compact this down single line of code. (using LINQ)

      It is. (So if you exclude the image extraction code, or you use the manual text file)

      Solve in a single line of vb.net (LINQ) code.


      Me.Output.Text = ((Bytes.Select(Of String) _
                           (New System.Func(Of Byte, Integer, String) _
                            (Function(lb As Byte, li As Integer) _
                               String.Format("[{1}][{0}]", _
                                             Convert.ToString(Bytes(li), 2).PadLeft(8, "0"). _
                                             Substring(0, Integer.Parse(PiDigit(li)) Mod 8), _
                                             Convert.ToString(Bytes(li), 2).PadLeft(8, "0"). _
                                             Substring(Integer.Parse(PiDigit(li)) Mod 8) _
                                             ) _
                            ) _
                           ) _
                          ).Aggregate( _
                           Function(current, nexta) current & ControlChars.NewLine & nexta) _
                         ).ToString.Replace("1", " ").Replace("0", "#")
      


      Now I've refactored the code to its limit. I'm stepping away.

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.