Odin SolutionsOdin Solutions

🔻

Inverse Word Pyramid

Week 41, 2026

All Solutions

Iterating until left and right meets | greenya | Odin Solutions

package main import "core:fmt" import "core:strings" main :: proc () { sentence := "The things you do every day matter more than the things you do once in a while" inverse_pyramid(sentence, 1, 2, 3, 4) inverse_pyramid(sentence, 0, 0, 1, 1) inverse_pyramid(sentence, 40, -5, 2, 0) inverse_pyramid(sentence, 10, 5, 1, 1) inverse_pyramid(sentence, 4, 4, 4, 4) inverse_pyramid(sentence, 0, 0, 0, 1) } inverse_pyramid :: proc ( sentence : string, initial_padding : int, padding_change : int, left_word_dec : int, right_word_dec : int, end_new_line := true, ) { assert(left_word_dec > 0 || right_word_dec > 0) list := strings.split(sentence, " ") defer delete(list) padding := initial_padding left_word := 0 right_word := len(list) - 1 for left_word <= right_word { for _ in 0..<padding do fmt.print(" ") for s in list[left_word:right_word+1] do fmt.print(s, "") fmt.println() padding += padding_change left_word += left_word_dec right_word -= right_word_dec } if end_new_line do fmt.println() }