Skip to content
This repository was archived by the owner on Jul 5, 2022. It is now read-only.

Commit e3695c0

Browse files
committed
Final working CC_037_diastic
1 parent 2f57ae7 commit e3695c0

File tree

1 file changed

+14
-0
lines changed
  • CodingChallenges/CC_037_diastic/Processing/CC_037_diastic/CC_037_diastic

1 file changed

+14
-0
lines changed

CodingChallenges/CC_037_diastic/Processing/CC_037_diastic/CC_037_diastic/CC_037_diastic.pde

+14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,20 @@
88

99
String diastic(String seed, String[] words) {
1010
String phrase = "";
11+
int currentWord = 0;
1112

13+
for (int i = currentWord; i < seed.length(); i++) {
14+
char c = seed.charAt(i);
15+
16+
for (int j = 0; j < words.length; j++) {
17+
if (words[j].length() >= i + 1 && words[j].charAt(i) == c) {
18+
phrase += words[j];
19+
phrase += " ";
20+
currentWord = j + 1;
21+
break;
22+
}
23+
}
24+
}
1225
return phrase;
1326
}
1427

@@ -39,6 +52,7 @@ void draw() {
3952
void keyPressed() {
4053
if (key == '\n') {
4154
String phrase = diastic(seed, words);
55+
println(phrase);
4256
} else {
4357
seed += key;
4458
}

0 commit comments

Comments
 (0)