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
global min_diff, ans_for_mindiff | |
def permute(start, end, hole_depth, column_height, colors, col_index_params): | |
if start == end: | |
global min_diff, ans_for_mindiff | |
N = len(col_index_params) | |
new_height = [column_height[col_index_params[i]] - hole_depth[i] for i in range(N)] | |
new_color = [colors[col_index_params[i]] for i in range(N)] | |
diff, max_diff = 0, 0 | |
# diff in consecutive columns |
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
class WaveSort | |
def initialize(ary) | |
@input_ary = ary | |
end | |
# OPTIMIZED, checking current value against the next/prev element | |
def wave_sort_optimized | |
ary_len = @input_ary.length | |
(0...@input_ary.length).step(2) do |i| | |
if (i > 0) && (@input_ary[i] > @input_ary[i-1]) |