Created
December 3, 2019 13:08
-
-
Save barmic/9f2100c46391ca7182569250fa1911d5 to your computer and use it in GitHub Desktop.
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
sub MAIN ($length){say (1...$length).map({("*" x $length).comb.join("_").subst(/\*_/," ", :x($length-$_))}).join("\n")} |
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
sub step($line) { | |
say $line; | |
$line ~~ /\s/ && step($line.subst(/\s(\S)/,{"*_$0"})); | |
} | |
step(" " x 10 ~ "*"); |
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
func arbreDeNoel(n: UInt, indentation: String = "") -> String { | |
switch n { | |
case 1: | |
return printArbre(branche: "*", indentation: indentation) | |
default: | |
return printArbre(branche: arbreDeNoel(n: n - 1, indentation: indentation + " ") + "_*", indentation: indentation) | |
} | |
} | |
func printArbre(branche: String, indentation: String) -> String { | |
print(indentation + branche) | |
return branche | |
} | |
arbreDeNoel(n: 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment