This file contains 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
# Given an array of 0s and 1s that represent a garden, where 0 is a plot that | |
# hasn’t been planted on, and 1 is a plot that has been planted on, return true | |
# if n plants can be planted without touching another plant. | |
def can_plant(garden: list, position: int): | |
position = position - 1 | |
available = get_available_plots(garden) | |
available_count = len(available) | |
if available_count > position: |
This file contains 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
# Given a rowIndex, return an array of the values in that row of Pascal’s Triangle. | |
# Example: | |
# $ pascals(0) | |
# $ [1] | |
# $ pascals(3) | |
# $ [1,3,3,1] | |
def pascals(n): | |
list = [] | |
index_value = 1 |
This file contains 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
array = ['h','e','l','o',' ','w','r','d','!',','] | |
string = array[0].capitalize() + array[1] + array[2] + array[2] + array[3] +\ | |
array[9] + array[4] + array[5] + array[3] + array[6] + array[2] + array[7] + array[8] | |
print(string) |
This file contains 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
def factorial(number: int): | |
if number == 0: | |
r = 1 | |
else: | |
r = number * factorial(number - 1) | |
return r | |
def is_factorial(number: int) -> bool: | |
result = False |
This file contains 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
struct Element { | |
var name: String | |
var weakness: String | |
var beat: String | |
init(name: String, weakness: String, beat: String) { | |
self.name = name | |
self.weakness = weakness | |
self.beat = beat | |
} |