Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cec5af4

Browse filesBrowse files
feat: exercícios dia 1
0 parents  commit cec5af4
Copy full SHA for cec5af4

File tree

Expand file treeCollapse file tree

10 files changed

+244
-0
lines changed
Filter options
Expand file treeCollapse file tree

10 files changed

+244
-0
lines changed

‎.gitignore

Copy file name to clipboard
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
### IntelliJ IDEA ###
2+
out/
3+
!**/src/main/**/out/
4+
!**/src/test/**/out/
5+
6+
### Eclipse ###
7+
.apt_generated
8+
.classpath
9+
.factorypath
10+
.project
11+
.settings
12+
.springBeans
13+
.sts4-cache
14+
bin/
15+
!**/src/main/**/bin/
16+
!**/src/test/**/bin/
17+
18+
### NetBeans ###
19+
/nbproject/private/
20+
/nbbuild/
21+
/dist/
22+
/nbdist/
23+
/.nb-gradle/
24+
25+
### VS Code ###
26+
.vscode/
27+
28+
### Mac OS ###
29+
.DS_Store

‎.idea/.gitignore

Copy file name to clipboardExpand all lines: .idea/.gitignore
+3Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/misc.xml

Copy file name to clipboardExpand all lines: .idea/misc.xml
+6Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/modules.xml

Copy file name to clipboardExpand all lines: .idea/modules.xml
+8Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/uiDesigner.xml

Copy file name to clipboardExpand all lines: .idea/uiDesigner.xml
+124Lines changed: 124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎codeWarsJava.iml

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

‎src/Main.java

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import dayOne.contagemBits.detectarPangram.Exercicio;
2+
3+
public class Main {
4+
public static void main(String[] args) {
5+
// System.out.println( Exercicio.countBits(2));
6+
System.out.println(Exercicio.check("bab klzx"));
7+
}
8+
}
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package dayOne.contagemBits;
2+
3+
import java.util.Objects;
4+
5+
public class Exercicio {
6+
public static int countBits(int n){
7+
Integer manyOnes = 0;
8+
// Show me the code!
9+
if(n >= 0){
10+
String repBinaria = Integer.toBinaryString(n);
11+
String[] numerosBits = repBinaria.split("");
12+
13+
for(String numeroBit : numerosBits){
14+
if(Objects.equals(numeroBit, "1")){
15+
manyOnes++;
16+
}
17+
}
18+
}
19+
20+
return manyOnes;
21+
// ou
22+
//Integer.bitCount(n);
23+
}
24+
}
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package dayOne.contagemBits.detectarPangram;
2+
3+
4+
import java.util.Arrays;
5+
import java.util.Objects;
6+
7+
public class Exercicio {
8+
9+
10+
public static Boolean check(String string){
11+
String[] arrayLetters = string.split("");
12+
13+
for(int i = 0; i <= arrayLetters.length; i++){
14+
for(int j= 0; j <= arrayLetters.length; i++){
15+
if(Objects.equals(arrayLetters[i], arrayLetters[j]) && i != j) {
16+
Arrays.toString(arrayLetters).replaceAll(arrayLetters[i], "duplicata");
17+
}
18+
}
19+
}
20+
21+
Boolean isPangrama = Arrays.stream(arrayLetters).filter(i -> !i.equalsIgnoreCase("duplicata")).distinct().count() == 26;
22+
return isPangrama;
23+
24+
}
25+
}
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Um pangrama é uma frase que contém cada letra do alfabeto pelo menos uma vez.
2+
Por exemplo, a frase "The quick brown fox jumps over the lazy dog" é um pangrama,
3+
porque usa as letras AZ pelo menos uma vez (caso seja irrelevante).
4+
5+
Dada uma string, detecta se é ou não um pangrama. Retorna True se for, False se não for.
6+
Ignora números e pontuação.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.