JavaScript, 225 221 212 bytes
-9 bytes thanks to Conor O'Brien
Please note that your text cases conflict with each other. Your first test case starts in the middle of the spiral. Your second test case starts in the top middle of the spiral. I went with your first test case, because it was the first one I saw. You haven't edited your question in over a year, so sorry for the presumption.
First Test Case:
9<-8<-7
| |
2<-1 6
| |
3->4->5
Second Test Case:
2<-1<-6
| |
3->4->5
| |
7->8->9
Without any further adieu, here is the golfed code. I am 100% sure that if the community chips it this could be cut significantly. This returns a multiline array.
s=>eval("s=[...s.replace(/ /g,'')];i=0;k=j=1;a=[[],[],[]];b='00122210';c=b*100+'';for(;;){for(l=0;l<8;l++){if(!s[i])break;if(a[k][j]==s[i])s[i]=s[i].toUpperCase();a[k][j]=s[i];k=b[l];j=c[l];i++}if(!s[i])break}a")
Prettification snippet (prints a multiline string to console). Please note the different in my test case #2 and OP's test case #2 (see above if you have not already):
(if someone with more experience with snippets wants to fix this into HTML input feel free to edit this, I need to go to bed).
f=
s=>eval("s=[...s.replace(/ /g,'')];i=0;k=j=1;a=[[],[],[]];b='00122210';c=b*100+'';for(;;){for(l=0;l<8;l++){if(!s[i])break;if(a[k][j]==s[i])s[i]=s[i].toUpperCase();a[k][j]=s[i];k=b[l];j=c[l];i++;g(a)}if(!s[i])break}a")
//replace argument here to change output
var arr = f("apples appeal");
function g(ar) {
var str = "";
for (x = 0; x < 3; x++) {
for (y = 0; y < 3; y++) {
str += ar[y][x] || " ";
}
str += "\n";
}
console.log(str);
}
Ungolfed and Explanation
f=(input)=>{
//remove spaces
input = input.replace(/ /g, "");
//convert to array (so I can uppercase individual letters)
input = input.split("");
//position in input
var pos = 0;
//positions inside output
var xPos = 1;
var yPos = 1;
//output container (3 rows, 3 columns)
var arr = [[],[],[]];
//counterclockwise indexes for x
var xOrder = "00122210";
//counterclockwise indexes for y
//var yOrder = "12221000"
var yOrder = xOrder * 100 + "";
//loop infinitely (breaks when input[pos] is undefined)
for (;;) {
//loop around circle
for (var i = 0; i < 8; i++) {
if (!input[pos]) {
break;
}
//if item already in array equal next item in input, set next item in input to caps before
if (arr[xPos][yPos] == input[pos]) {
input[pos] = input[pos].toUpperCase();
}
//write or overwrite in array with current from input
arr[xPos][yPos] = input[pos];
//increment last because we do not prime our loops
xPos = xOrder[i];
yPos = yOrder[i];
pos++;
}
if(!input[pos]) {
break;
}
}
return arr;
}
abcdefghab
? \$\endgroup\$