කැමති ඕනෙම ප්රෝග්රමින්ග් ලන්වේජ් එකක් තෝරා ගන්න. අලුත් ලන්වේජ් වලින් කරලා දාපල්ලා අනින් උනුත් ඉන්ස්පයර් ද මොකක්ද එක වෙන්න. තේරෙන්නේ නැති උන් අහපල්ලා ඕක සිංහලෙන් කියල දෙයි කව්රු හරි
public static class Program {
static void Main(string[] args) {
int B = 1, A = 1, L = 2, O = 2, N = 1, count = 0;
//var s = "BAOOLLNNOLOLGBAX";
var s = "BAONXXOLL";
while (s.Count(x => x == 'B') >= B && s.Count(x => x == 'A') >= A && s.Count(x => x == 'L') >= L && s.Count(x => x == 'O') >= O && s.Count(x => x == 'N') >= N) {
++count;
s = s.ReplaceChar('B', B);
s = s.ReplaceChar('A', A);
s = s.ReplaceChar('L', L);
s = s.ReplaceChar('O', O);
s = s.ReplaceChar('N', N);
}
Console.WriteLine("Number of moves: " + count.ToString());
}
public static string ReplaceChar(this string s, char c, int i) {
var regex = new Regex(Regex.Escape(c.ToString()));
return regex.Replace(s, string.Empty, i);
}
}

public static void generateAlphabiticalDict(string input)
{
Dictionary<Char, int> alphabets = new Dictionary<Char, int>();
for (int i = 0; i < input.Length; i++)
{
char character = input[i];
if (Char.IsLetter(character))
{
if (alphabets.ContainsKey(character))
alphabets[character] = alphabets[character] + 1;
else
alphabets.Add(character, 1);
}
}
}
Thant's the spiritpsudocode eka nam liwwa.
bagayak liyaddi interesting wage.
code ekama gahala dannam
dana eka poddak advance vidiyata dapan. Balloon valata characters one by one check karanne nethuwapsudocode eka nam liwwa.
bagayak liyaddi interesting wage.
code ekama gahala dannam
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class EKTest {
public int getMaxMoves(String string) {
Map<String, Long> occurrences = Arrays.stream(string.split("")).collect(
Collectors.groupingBy(s -> s, LinkedHashMap::new, Collectors.counting()));
return Collections.min(List.of(
(occurrences.get("B") != null ? occurrences.get("B").intValue() : 0),
(occurrences.get("A") != null ? occurrences.get("A").intValue() : 0),
(occurrences.get("L") != null ? (occurrences.get("L").intValue())/2: 0),
(occurrences.get("O") != null ? (occurrences.get("O").intValue())/2: 0),
(occurrences.get("N") != null ? (occurrences.get("N").intValue()) : 0)
));
}
public static void main(String [] args) {
EKTest ek = new EKTest();
System.out.println("Max Moves: " + ek.getMaxMoves("QAWABAWNL"));
System.out.println("Max Moves: " + ek.getMaxMoves("BAONXXOLL"));
System.out.println("Max Moves: " + ek.getMaxMoves("BAOOLLNNOLOLGBAXBBOOALLNN"));
}
}
Code ekath dapan machan study karana unta help ekak weyi
MAchan explain how you approached this as it will help to othersJava 8+, without any 3rd party libraries.
Meeta wada optimized widi godak ethi. eka paratama oluwata aawe meka.
Java:import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; public class EKTest { public int getMaxMoves(String string) { Map<String, Long> occurrences = Arrays.stream(string.split("")).collect( Collectors.groupingBy(s -> s, LinkedHashMap::new, Collectors.counting())); return Collections.min(List.of( (occurrences.get("B") != null ? occurrences.get("B").intValue() : 0), (occurrences.get("A") != null ? occurrences.get("A").intValue() : 0), (occurrences.get("L") != null ? (occurrences.get("L").intValue())/2: 0), (occurrences.get("O") != null ? (occurrences.get("O").intValue())/2: 0), (occurrences.get("N") != null ? (occurrences.get("N").intValue()) : 0) )); } public static void main(String [] args) { EKTest ek = new EKTest(); System.out.println("Max Moves: " + ek.getMaxMoves("QAWABAWNL")); System.out.println("Max Moves: " + ek.getMaxMoves("BAONXXOLL")); System.out.println("Max Moves: " + ek.getMaxMoves("BAOOLLNNOLOLGBAXBBOOALLNN")); } }
Kisima kenekta oka mulin therenne na machan. ayi kiyawala balapan.![]()
melo deyak terune na


They use words like balloon to trick you. Just understanding the real requirement will leads you to the right direction. This is what happens in the real world too. Business centric people use buzz words while explaining the requirements which is confusing. But as develpors we should able to filter the real thing from what they telling.Code ekath dapan machan study karana unta help ekak weyi
And pls explain how you approached this. it's a learning curve
MAchan explain how you approached this as it will help to others
------ Post added on Jul 30, 2022 at 9:07 PM
letters=[]
x=input("word: ")
letters=list(x)
word=list("BALLOON")
round=0
number=0
set_no=1
n=1
while len(letters)!=n:
while n<len(letters):
if word[round] ==letters[n-1]:
number=number+1
if number==7:
set_no=set_no+1
round=0
n=n+1
else:
n=n+1
round=round+1
else:
n=n+1
print(set_no)
)Hurray we have a python one.Python:letters=[] x=input("word: ") letters=list(x) word=list("BALLOON") round=0 number=0 set_no=1 n=1 while len(letters)!=n: while n<len(letters): if word[round] ==letters[n-1]: number=number+1 if number==7: set_no=set_no+1 round=0 n=n+1 else: n=n+1 round=round+1 else: n=n+1 print(set_no)
(samaharawita waradi athi.baninna epa hode. api thaama aadunikai programming walata)

මේකද approach ඒකThey use words like balloon to trick you. Just understanding the real requirement will leads you to the right direction. This is what happens in the real world too. Business centric people use buzz words while explaining the requirements which is confusing. But as develpors we should able to filter the real thing from what they telling.
