1 / 47

How I won the APL Problem Solving Competition

How I won the APL Problem Solving Competition. Emil Bremer Orloff Dyalog’14 Eastbourne , UK. What will this be about. ” Emil will describe his experiences of Dyalog and tell us how he managed to master enough of it to win the competition .”. What will this be about. About me

omer
Download Presentation

How I won the APL Problem Solving Competition

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. HowI won the APL Problem SolvingCompetition Emil Bremer Orloff Dyalog’14 Eastbourne, UK

  2. Whatwillthisbeabout ”Emil will describe his experiences of Dyalog and tell us how he managed to master enough of it to win the competition.”

  3. Whatwillthisbeabout • Aboutme • Relation to APL • The competition

  4. Aboutme • Studying Computer Science at Aarhus University

  5. Aboutme • Studying Computer Science at Aarhus University

  6. Aboutme • Studying Computer Science at Aarhus University • 4 yearsintomymaster’sdegree

  7. Aboutme • Studying Computer Science at Aarhus University • 4 yearsintomymaster’sdegree • Specialized in Cryptography and programminglanguages • Programmingexperience in: Java, Ocaml, SML, C, Coq, (Matlab)

  8. My firstencounterwith APL

  9. My firstencounterwith APL • 2011: mydepartmentshared a link to the DyalogCompetition

  10. My firstencounterwith APL • 2011: mydepartmentshared a link to the DyalogCompetition • A horrible mess of funnycharacters!

  11. My firstencounterwith APL • 2011: mydepartmentshared a link to the DyalogCompetition • A horrible mess of funnycharacters! • Becameinteressted due to the nature of the language – had to useanother approach • Didn’t have time to learn

  12. Fastforward  2014 • Last chance to compete as a student

  13. Fastforward  2014 • Last chance to compete as a student • Legrand’s book

  14. The Competition • Phase 1 • 10 problems solvedusingdfns • Herefollows a couple of my solutions

  15. Problem 5 - MirrorMirror • Tellif a given strings is a palidrome

  16. Problem 5 - MirrorMirror • Tellif a given strings is a palidrome • Naïve: {⍵≡⌽⍵}

  17. Problem 5 - MirrorMirror • Tellif a given strings is a palidrome • Naïve: {⍵≡⌽⍵} • Unfortunatelyonly letters are relevant

  18. Problem 5 - MirrorMirror • Tellif a given strings is a palidrome • Naïve: {⍵≡⌽⍵} • Unfortunatelyonly letters arerelevant • {{⍵≡⌽⍵}(⍵∊'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')/⍵}

  19. Problem 8 - Go the distance • Find the distance betweentwo points in n-dimensional space

  20. Problem 8 - Go the distance • Find the distance betweentwo points in n-dimensional space • {(+/(⍵-⍺)*2)*0.5}

  21. Part II • Consisted of 3 problem sets • Eachcontaining 3 parts (easy, medium, hard)

  22. Part II • Consisted of 3 problem sets • Eachcontaining 3 parts (easy, medium, hard) • Bioinformatics • Cryptography • Recreation and games

  23. Part II • Consisted of 3 problem sets • Eachcontaining 3 parts (easy, medium, hard) • Bioinformatics(easy, medium, hard) • Cryptography(easy, hard) • Recreation and Games (hard)

  24. Bioinformatics • K-mercounting • Most frequentk-mers • Clumpfinding • Approximatepatternmatching • Sharedk-mers • Longestsharedsubstring • Shortestnon-sharedsubstring • Edit distance

  25. Bioinformatics • K-mercounting • Most frequentk-mers • Clumpfinding • Approximatepatternmatching • Sharedk-mers • Longestsharedsubstring • Shortestnon-sharedsubstring • Edit distance

  26. Bioinformatics • K-mercounting • Most frequentk-mers • Clumpfinding • Approximatepatternmatching • Sharedk-mers • Longestsharedsubstring • Shortestnon-sharedsubstring • Edit distance Substrings and ⍷

  27. Substring • Created a helperfunctionthatcouldcreate all substrings of a given length

  28. Substring • Created a helperfunctionthatcouldcreate all substrings of a given length • Create all relevant indexes

  29. Substring • Created a helperfunctionthatcouldcreate all substrings of a given length • Creating all relevant indexes

  30. Substring • Created a helperfunctionthatcouldcreate all substrings of a given length • Creating all relevant indexes • UseN-Wisereduce! {⍵>⍴⍺:'' ⍵,/⍺} • Changedshortlybefore deadline

  31. Bioinformatics • K-mercounting • Most frequentk-mers • Clumpfinding • Approximatepatternmatching • Sharedk-mers • Longestsharedsubstring • Shortestnon-sharedsubstring • Edit distance Substrings And ⍷

  32. Edit distance • Given twostrings find the minimal editsthatbrings the first to the second • An edit: • Insert a character • Delete a character

  33. Edit distance • Generate a matrix that gives the editdistancebetween the substrings

  34. Edit distance • Generate a matrix that gives the editdistancebetween the substrings

  35. Edit distance • Generate a matrix that gives the editdistancebetween the substrings Firstrow and first column arealways the same

  36. Edit distance • Each element in table is given by • 0+value to NW if the characters match • 1+the minimum value to the W, NW or N if the characters does not match

  37. Edit distance • Each element in table is given by • 0+value to NW if the characters match • 1+the minimum value to the W, NW or N if the characters does not match • Which is min(cost+NW, 1+W, 1+N)

  38. Edit distance firstRow←(⍳1+⍴t)-1

  39. Edit distance firstRow←(⍳1+⍴t)-1 nextRow←{ {(⍺+1)⌊⍵}\(1+⍵)⌊(1+⊃⍵),(¯1↓⍵)+⍺≠t }

  40. Edit distance firstRow←(⍳1+⍴t)-1 nextRow←{ {(⍺+1)⌊⍵}\(1+⍵)⌊(1+⊃⍵),(¯1↓⍵)+⍺≠t } lastRow←⊃nextRow/(⌽s),⊂firstRow ed←⊃⌽lastRow

  41. Edit distance firstRow←(⍳1+⍴t)-1 nextRow←{ {(⍺+1)⌊⍵}\(1+⍵)⌊(1+⊃⍵),(¯1↓⍵)+⍺≠t } lastRow←⊃nextRow/(⌽s),⊂firstRow ed←⊃⌽lastRow

  42. Whatwasactuallydelivered

  43. Cryptography • Viginèrecipher • Book cipher variation • Playfaircipher

  44. Cryptography • Viginèrecipher • Book cipher variation • Playfaircipher

  45. Recreation and Games • Word search • Scrabble • Bridge

  46. Recreation and Games • Word search • Scrabble • Bridge

  47. Questions?

More Related