Hello guys,
i have a solution for this task and it works, but i think its not very elegant. I add at every second, so uneven, position the word "ham". If the last position is even, i manually add "ham" again.
It works but as i said i dont like it very much.
How were your solutions?
As my code is working i cannot post it here.
Thanks already for discussion
Other solutions
In der Diskussion
Kommentare (5)
- Beliebt
- Neu
- Alt
Du musst angemeldet sein, um einen Kommentar schreiben zu können
Thomas
11 Mai 2020, 14:14
I have two solutions
1st.. not very elegant:
this one I like much more
+4
niobe92
11 Mai 2020, 15:14
ah yeah the second one looks good. But shouldnt i be i = i-2;
But anyway, thats the solution i was searching for.
Thanks :)
0
Thomas
11 Mai 2020, 17:07
Just try it and you'll see that it's i-- ;)
Just think about it. If you'd just add elements it'll be like a loop -1. With the additional i-- you match every second entry.
0
niobe92
13 Mai 2020, 09:30
Yes, youre right. The already existing word at the position goes to the next one and it fits. Perfect. THanks!
0
Ashish RajAnand
11 Mai 2020, 13:31
same problem bro we can't post solution.
another method is just go help section and search resolve question or many comments question .
You must look what mistake there and how different they coded from your.
+1