Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alphamirror: fix newline #91

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f8f51c7
fix format paramrange_test
Hamzaelkhatri Jul 7, 2022
0e1fa90
fixing the solution of rotatevowels
MSilva95 Jul 12, 2022
827834a
Fix format
Hamzaelkhatri Jul 13, 2022
a295790
add(test):arg-rot1
Hamzaelkhatri Jun 13, 2022
a32e87b
Update main.go
Hamzaelkhatri Jul 6, 2022
e51ae79
fix format
Hamzaelkhatri Jul 6, 2022
786fbb2
feat: Add solution for oddlength
eslopfer Jun 23, 2022
d1a7bb0
test: Add test for oddlength
eslopfer Jun 23, 2022
fdb00ec
correct format
zainabdnaya Jul 7, 2022
1a60bab
feat: add solution for prinevenarguments subject
eslopfer Jun 29, 2022
e23ac5d
test: add test for printevenarguments subject
eslopfer Jun 29, 2022
bc55941
Correct wrong program name
eslopfer Jun 29, 2022
766b00e
fix: Fix solution as per review
eslopfer Jul 11, 2022
3c394c3
test: Add test case suggested in review
eslopfer Jul 11, 2022
08e4316
add(Test): add solution and test for rev args
Hamzaelkhatri Jun 13, 2022
26b1ed8
Update main.go
Hamzaelkhatri Jun 22, 2022
c46e63f
Update main.go
Hamzaelkhatri Jun 22, 2022
c5ec42f
Update main.go
Hamzaelkhatri Jun 28, 2022
a181bc5
add empty
MSilva95 Jul 8, 2022
24bc641
add(test): printmiddle
Hamzaelkhatri Jun 13, 2022
004f0f8
Update main.go
Hamzaelkhatri Jun 23, 2022
815a83c
Update main.go
Hamzaelkhatri Jun 24, 2022
39f6b81
fix format
Hamzaelkhatri Jul 7, 2022
4ceeb0b
add empty case
MSilva95 Jul 8, 2022
8484524
feat: Add solution for popint subject
eslopfer Jun 24, 2022
1c0e9ba
test: Add test for popint subject
eslopfer Jun 24, 2022
0b5cfdf
add(test):add test & solution
Hamzaelkhatri Jun 8, 2022
631befe
fix(test):fix func name & test
Hamzaelkhatri Jun 9, 2022
cef29cc
fix(prototype):fix name
Hamzaelkhatri Jun 9, 2022
389cc1b
Update main.go
Hamzaelkhatri Jun 17, 2022
240e52e
fix:format & remove unsed library
Hamzaelkhatri Jun 24, 2022
f73cb9b
Update main.go
Hamzaelkhatri Jun 28, 2022
c05deee
test(swap-args):add test & solution
Hamzaelkhatri Jun 16, 2022
3e9cfde
fix:name of program
Hamzaelkhatri Jun 24, 2022
054b6fe
fix: space between args
Hamzaelkhatri Jun 27, 2022
668304c
Add solution for concatenate subject
eslopfer Jun 29, 2022
05ee99f
test: Add tests for concatenate subject
eslopfer Jun 29, 2022
6e8c5b1
Add missing test
eslopfer Jun 29, 2022
2892f22
test: Add test cases as per review
eslopfer Jul 1, 2022
98df52d
feat: Add solution for sum subject
eslopfer Jun 29, 2022
30896bc
test: Add test for sum subject
eslopfer Jun 29, 2022
b4a1255
test: add missing test cases
eslopfer Jun 29, 2022
465d701
feat: Implement solution for evenlength subject
eslopfer Jun 30, 2022
a22ea61
test: Implement test for evenlength subject
eslopfer Jun 30, 2022
b52f9a0
feat: Add solution for delete subject
eslopfer Jun 30, 2022
44c263e
test: Write test for delete subject
eslopfer Jun 30, 2022
8ce3d00
feat: Add solution to pingpong subject
eslopfer Jun 22, 2022
d713202
test: Add test for pingpong subject
eslopfer Jun 22, 2022
67e08e3
test: add one more test case
eslopfer Jun 22, 2022
c894836
fix: Add extra line at the end of file as by the review
eslopfer Jun 24, 2022
9ce4d8e
test: Add random tests as per review
eslopfer Jun 28, 2022
d851014
fix: Remove random tests
eslopfer Jun 28, 2022
57db84b
squareroot
zainabdnaya Jun 20, 2022
699a0f8
squareroot
zainabdnaya Jun 20, 2022
283c241
corrected
zainabdnaya Jul 7, 2022
83ec195
Merge pull request #81 from 01-edu/80-fix-format-for-new-exam-exercices
Hamzaelkhatri Jul 16, 2022
6c8cec9
Merge pull request #79 from 01-edu/rotatevowels-solution-fix
MSilva95 Jul 20, 2022
81f2b7e
alphamirror: fix newline
rcatini Jul 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions solutions/alphamirror/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ func main() {
arg[i] = 'Z' - ch + 'A'
}
}
fmt.Print(string(arg))
fmt.Println(string(arg))
}

fmt.Println()
}
2 changes: 1 addition & 1 deletion solutions/alphaposition.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package solutions

func AlphaPosition(c rune) int{
func AlphaPosition(c rune) int {
if c >= 'a' && c <= 'z' {
return int(c - 'a' + 1)
} else if c >= 'A' && c <= 'Z' {
Expand Down
22 changes: 22 additions & 0 deletions solutions/argrot1/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"fmt"
"os"
)

func main() {
if len(os.Args) < 3 {
fmt.Println()
return
}
for i := 1; i < len(os.Args); i++ {
if i != len(os.Args)-1 {
fmt.Print(os.Args[i+1])
fmt.Print(" ")
} else {
fmt.Print(os.Args[1])
}
}
fmt.Println()
}
2 changes: 1 addition & 1 deletion solutions/argrotn/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func main() {

for i := 0; i < len(args); i++ {
fmt.Print(string(args[(i+n)%len(args)]))
if i < len(args)-1 {
if i < len(args)-1 {
fmt.Print(" ")
}
}
Expand Down
18 changes: 18 additions & 0 deletions solutions/concatenate/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"fmt"
"os"
)

func main() {
if len(os.Args) < 2 {
fmt.Println()
return
}
result := ""
for _, arg := range os.Args[1:] {
result += arg
}
fmt.Println(result)
}
15 changes: 15 additions & 0 deletions solutions/delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package solutions

func Delete(ints []int, position int) []int {
if position > len(ints)-1 {
return ints
}
result := []int{}
for i, integer := range ints {
if i == position-1 {
continue
}
result = append(result, integer)
}
return result
}
11 changes: 11 additions & 0 deletions solutions/evenlength.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package solutions

func EvenLength(strings []string) []string {
var newSlice []string
for _, str := range strings {
if len(str)%2 == 0 {
newSlice = append(newSlice, str)
}
}
return newSlice
}
11 changes: 11 additions & 0 deletions solutions/oddlength.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package solutions

func Oddlength(strings []string) []string {
var newSlice []string
for _, str := range strings {
if len(str)%2 == 1 {
newSlice = append(newSlice, str)
}
}
return newSlice
}
2 changes: 1 addition & 1 deletion solutions/paramrange/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ func main() {
}
}
fmt.Println(min, max)
}
}
26 changes: 26 additions & 0 deletions solutions/pingpong/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"fmt"
"os"
"strconv"
)

func main() {
if len(os.Args) != 2 {
return
}
num, err := strconv.Atoi(os.Args[1])
if err != nil {
fmt.Println(err.Error())
return
}

for i := 0; i < num; i++ {
if i%2 == 0 {
fmt.Println(strconv.Itoa(i) + " ping")
continue
}
fmt.Println(strconv.Itoa(i) + " pong")
}
}
8 changes: 8 additions & 0 deletions solutions/popint.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package solutions

func PopInt(ints []int) []int {
if len(ints) == 0 {
return ints
}
return ints[:len(ints)-1]
}
18 changes: 18 additions & 0 deletions solutions/printevenarguments/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"fmt"
"os"
)

func main() {
if len(os.Args) <= 2 {
fmt.Println()
return
}
for i, arg := range os.Args[1:] {
if i%2 != 0 {
fmt.Println(arg)
}
}
}
20 changes: 20 additions & 0 deletions solutions/printmiddle/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

import (
"fmt"
"os"
)

func main() {
if len(os.Args) < 2 {
fmt.Println()
return
}
args := os.Args[1:]

if len(args)%2 == 0 {
fmt.Println(args[len(args)/2-1] + " " + args[len(args)/2])
} else {
fmt.Println(args[len(args)/2])
}
}
36 changes: 36 additions & 0 deletions solutions/printrange.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package solutions

import "github.com/01-edu/z01"

func PrintRange(n, m int) {
if n < 0 && m < 0 || n > 9 && m > 9 {
z01.PrintRune('\n')
return
}
if n < 0 {
n = 0
} else if n > 9 {
n = 9
}
if m < 0 {
m = 0
} else if m > 9 {
m = 9
}
if n > m {
for i := n; i >= m; i-- {
z01.PrintRune(rune(i) + '0')
if i != m {
z01.PrintRune(' ')
}
}
} else {
for i := n; i <= m; i++ {
z01.PrintRune(rune(i) + '0')
if i != m {
z01.PrintRune(' ')
}
}
}
z01.PrintRune('\n')
}
20 changes: 20 additions & 0 deletions solutions/revargs/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

import (
"fmt"
"os"
)

func main() {
if len(os.Args) < 2 {
fmt.Println()
return
}
for i := len(os.Args) - 1; i >= 1; i-- {
fmt.Print(os.Args[i])
if i != 1 {
fmt.Print(" ")
}
}
fmt.Println()
}
48 changes: 28 additions & 20 deletions solutions/rotatevowels/main.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
package main

import (
"fmt"
"os"
"strings"

"github.com/01-edu/z01"
)

func main() {
var a1, a2, rev []rune
for _, arg := range os.Args[1:] {
for _, k := range arg {
if strings.ContainsRune("aeiouAEIOU", k) {
a1 = append(a1, k)
var vowels []rune

arguments := os.Args[1:]

for _, i := range arguments {
for j := 0; j < len(i); j++ {
if IsVowel(i[j]) {
vowels = append(vowels, rune(i[j]))
}
}
}
for i := len(a1) - 1; i >= 0; i-- {
rev = append(rev, a1[i])
}

m := 0
for i, arg := range os.Args[1:] {
for _, j := range arg {
if strings.ContainsRune("aeiouAEIOU", j) {
a2 = append(a2, rev[m])
m++
counter := len(vowels) - 1

for s, i := range arguments {
for j := 0; j < len(i); j++ {
if IsVowel(i[j]) {
z01.PrintRune(rune(vowels[counter]))
counter--
} else {
a2 = append(a2, j)
z01.PrintRune(rune(i[j]))
}
}
if i != len(os.Args)-1 {
a2 = append(a2, ' ')
if s != len(arguments)-1 {
z01.PrintRune(' ')
}
}
fmt.Println(string(a2))
z01.PrintRune('\n')
}

func IsVowel(s byte) bool {
if s == 65 || s == 69 || s == 73 || s == 79 || s == 85 || s == 97 || s == 101 || s == 105 || s == 111 || s == 117 {
return true
}
return false
}
17 changes: 17 additions & 0 deletions solutions/squareroot.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package solutions

func SquareRoot(number int) int {
if number == 1 {
return 1
}
if number >= 0 {
var sqrt float32 = float32(number / 2)
var temp float32 = 0.0
for sqrt != temp {
temp = sqrt
sqrt = float32((float32(number)/temp + temp) / 2)
}
return int(sqrt)
}
return -1
}
14 changes: 14 additions & 0 deletions solutions/sum.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package solutions

import (
"strconv"
)

func Sum(a, b string) int {
numA, _ := strconv.Atoi(a)
numB, _ := strconv.Atoi(b)
if numA > 9 || numA < -9 || numB > 9 || numB < -9 {
return 0
}
return numA + numB
}
14 changes: 14 additions & 0 deletions solutions/swapargs/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import (
"fmt"
"os"
)

func main() {
if len(os.Args) != 3 {
fmt.Println("")
return
}
fmt.Println(os.Args[2] + " " + os.Args[1])
}
1 change: 0 additions & 1 deletion tests/alphaposition_test/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

package main

import (
Expand Down
23 changes: 23 additions & 0 deletions tests/argrot1_test/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"github.com/01-edu/go-tests/lib/challenge"
)

func main() {
args := [][]string{
{"Hello"},
{""},
{"Hello World", "world"},
{"Hello World", "world", "Hello World"},
{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"},
{"30", "20", "10", "40", "50", "60", "70", "80", "90", "100"},
{"A B C D E"}, {"4 3 2 1 0"}, {"13 233 4 23"},
{"4 3 2 1 0"}, {"A B C D E"},
{"13 233 4 23"},
{"1"}, {"2"}, {"3"}, {"4"}, {"5"}, {"6"}, {"7"}, {"8"}, {"9"}, {"10"},
}
for _, s := range args {
challenge.Program("argrot1", s...)
}
}
Loading