This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set windowWidth to 1280 | |
| set currentApplication to (path to frontmost application as Unicode text) | |
| tell application currentApplication | |
| set windowBounds to bounds of the front window | |
| set upperLeftX to item 1 of windowBounds | |
| set upperLeftY to item 2 of windowBounds | |
| set lowerRightY to item 4 of windowBounds | |
| set bounds of the first window to {upperLeftX, upperLeftY, upperLeftX + windowWidth, lowerRightY} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # longest_ladder([1,2,1,2,3,5,6,7,8,9,10,7,5,5,6]) | |
| # => [5,6,7,8,9,10] | |
| def longest_ladder(arr) | |
| arr.chunk_while { _2 == _1 + 1 }.max_by(&:length) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Option 1 | |
| def square_digits(num): | |
| return int(''.join(str(int(d)**2) for d in str(num))) | |
| # Option 2 | |
| def square_digits(num): | |
| ret = "" | |
| for x in str(num): | |
| ret += str(int(x)**2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Option 1 | |
| def name_shuffler(s): | |
| return ' '.join(s.split(' ')[::-1]) | |
| # Option 2 | |
| def name_shuffler(s): | |
| return ' '.join(reversed(s.split())) |