Snack Break Problems #15 & #16
Posted on May 13, 2016 by evaera
Hello! This week we have two Snack Break challenges.
Problem #15
ROBLOX games are organized in a hierarchy. The game
contains Workspace, Players, etc. Then, Workspace could contain Parts, and Parts could contain Decals, etc.
The challenge is to craft a script that can identify the "deepest" object in any game. That is, the object that has the most parents or ancestors.
Problem #16
Phone dial pads usually have letters on them, as you can see in the following image:
Many modern smartphones have a feature that allows you to type a contact's name with only these numbers, and the phone will use a smart fuzzy searching algorithm to find which contact you are meaning to type.
For example, to type "Anna", you would enter the numbers "2662". To type "Mom", you would search "666". To type "Harold", you would enter "427653".
The challenge is to create an algorithm which, given a list of names, can sort through and return a list of names which matches the user-entered number string, prioritizing matches which start from the beginning (e.g. "25" would sort "Alex" above "Sally", even though they both contain the sequence "al" which would match "25").
For reference, here is a list of letters which go with which number on the dial pad:
- 2 A B C
- 3 D E F
- 4 G H I
- 5 J K L
- 6 M N O
- 7 P Q R S
- 8 T U V
- 9 W X Y Z
For convenience, I have compiled a list of map of the letters in Lua table format, and a list of example contact names, also in Lua table format.
Completion
If you would like to get a shout-out in next week's Snack Break post, then please post a link to a place with a working demo of Problem #16 in the comments section below.
Good luck!
Commentary
Leave a Comment