Programming Theory

Programming theory deals with the design, implementation, analysis, characterization, and classification of programming languages and their individual features, along with introductory programming concepts like program structure, variable declaration and conditional and looping constructs. Sub-disciplines include the formal semantics of programming languages, type theory, program analysis and transformation, comparative programming language analysis, metaprogramming, domain-specific languages, compiler construction and run-time systems.

Share tech news, updates, or what's on your mind.

Sign up to Post

http://codingbat.com/prob/p117630
public Map<String, Integer> wordCount(String[] strings) {
  Map<String, Integer> map=new HashMap<String, Integer>();
  for(String str: strings){
    int i=0;
    if(str.equals(str)){
      i++;
    }
    map.put(str,i);
  }
  return map;
}

Open in new window

Expected      Run            
wordCount(["a", "b", "a", "c", "b"]) → {"a": 2, "b": 2, "c": 1}      {"a": 1, "b": 1, "c": 1}      X      
wordCount(["c", "b", "a"]) → {"a": 1, "b": 1, "c": 1}      {"a": 1, "b": 1, "c": 1}      OK      
wordCount(["c", "c", "c", "c"]) → {"c": 4}      {"c": 1}      X      
wordCount([]) → {}      {}      OK      
wordCount(["this", "and", "this", ""]) → {"": 1, "and": 1, "this": 2}      {"": 1, "and": 1, "this": 1}      X      
wordCount(["x", "y", "x", "Y", "X"]) → {"x": 2, "X": 1, "y": 1, "Y": 1}      {"x": 1, "X": 1, "y": 1, "Y": 1}      X      
wordCount(["123", "0", "123", "1"]) → {"0": 1, "1": 1, "123": 2}      {"0": 1, "1": 1, "123": 1}      X      
wordCount(["d", "a", "e", "d", "a", "d", "b", "b", "z", "a", "a", "b", "z", "x", "b", "f", "x", "two", "b", "one", "two"]) → {"a": 4, "b": 5, "d": 3, "e": 1, "f": 1, "one": 1, "x": 2, "z": 2, "two": 2}      {"a": 1, "b": 1, "d": 1, "e": 1, "f": 1, "one": 1, "x": 1, "z": 1, "two": 1}      X      
wordCount(["apple", "banana", "apple", "apple", "tea", "coffee", "banana"]) → {"banana": 2, "apple": 3, "tea": 1, "coffee": 1}      {"banana": 1, "apple": 1, "tea": 1, "coffee": 1}      X      
other tests
X      

how to fix and improve my code for above challenge?
please advise
0
Free Tool: Path Explorer
LVL 9
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

when i am trying below challenge
http://codingbat.com/prob/p115012

as below
public Map<String, String> mapAB3(Map<String, String> map) {
  if(map.get("a")!=null ){
    
    map.put("b",map.get("a"));
  }
  
   if(map.get("b")!=null){
     map.put("a",map.get("b"));
   }
   return map;
}

Open in new window


public Map<String, String> mapAB3(Map<String, String> map) {
  if(map.get("a")!=null ){
   
    map.put("b",map.get("a"));
  }
 
   if(map.get("b")!=null){
     map.put("a",map.get("b"));
   }
   return map;
}
I am failing one edge case. how to improve my code and fix it. please advise
0
Hi,

I like to see some .class files generated in EAR file. Is there any java free decompiler to do this within eclipse and outside eclipse as well. please advise
0
I have been reading about the Turing machine lately.  My question for you does the average laptop meet criteria for being a turing machine?  It works different, but I think it can do everything a turning machine can do.

Would you agree or disagree?

Thanks.
0
Hi All, I am creating a simple module using API.AI where API will ask set of 10 questions and retrieve answers.I In between of these question set i.e. after question 3, i want to handle in between user queries using other intent also but after handling those queries, I want to return back to the original question set i.e. question 4. Can we do this ? if not what is the suitable way of handling such scenario?
0
In API.AI, @system.given-name can recognize English names. I want to create a module for india. Do we have any method by which we can use such kind of concept for indian names?
0
What is counting semaphore?
0
I would like to know the approach one has to take to architect software product/solution. How to device a high level architecture for a product being built from scratch? Requirements: service oriented, scalable data integration (interoperability) solution.

Please share references that may help learn software architecture/design basics. I have very broad (not deep) technical background including software engineering with basic coding skills as well.

I am not trying to become an expert architect but want to know key factors, pitfalls etc  of 'modern' software architecture.
0
How to count input numbers in a little man computer program
e.g 25 45 63
that means 3 numbers...the output should be 3
i need the coding
thanks
0
Hello

I am trying to generate java files from WSDL using Apache CXF plugin in my maven, but when I do maven generate sources I neither get any error in the console nor there are any files generated
pom.xml
0

Programming Theory

Programming theory deals with the design, implementation, analysis, characterization, and classification of programming languages and their individual features, along with introductory programming concepts like program structure, variable declaration and conditional and looping constructs. Sub-disciplines include the formal semantics of programming languages, type theory, program analysis and transformation, comparative programming language analysis, metaprogramming, domain-specific languages, compiler construction and run-time systems.