Skip to content

Commit

Permalink
Reto#36 en java
Browse files Browse the repository at this point in the history
  • Loading branch information
AnNavNicolas committed Sep 26, 2023
1 parent d5d151a commit b497ff6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Retos/Reto #36 - PERMUTACIONES [Media]/java/AnNavNicolas.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
public class AnNavNicolas {
public static void main(String[] args) {

String text = "sol";
permutar(text, "");

}

public static void permutar(String text, String response) {

if (text.isBlank() || text.length() < 1) {
System.out.println(response);
return;
}

for (int i = 0; i < text.length(); i++) {
String current_letter = String.valueOf(text.charAt(i));
String left = text.substring(0, i);
String rigth = text.substring(i + 1);
permutar(left + rigth, response + current_letter);
}
}
}

0 comments on commit b497ff6

Please sign in to comment.