Browse Source

Merge pull request #808 from 01-edu/tranferOfAlemGoExercices

removal of alem written subject, tranfered to their gitea
content-update
xpetit 3 years ago committed by GitHub
parent
commit
638311878e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      subjects/costumeprofit/README.md
  2. 38
      subjects/doppelganger/README.md
  3. 46
      subjects/fib/README.md
  4. 44
      subjects/game23/README.md
  5. 49
      subjects/halfcontest/README.md
  6. 46
      subjects/interestingnumber/README.md
  7. 56
      subjects/isanagram/README.md
  8. 50
      subjects/nauuo/README.md
  9. 22
      subjects/nenokku/README.md
  10. 21
      subjects/printchessboard/README.md
  11. 39
      subjects/priorprime/README.md
  12. 43
      subjects/reachablenumber/README.md
  13. 44
      subjects/revivethreenums/README.md
  14. 29
      subjects/robottoorigin/README.md
  15. 44
      subjects/sweetproblem/README.md
  16. 22
      subjects/uniqueoccurences/README.md
  17. 46
      subjects/volumechanger/README.md

25
subjects/costumeprofit/README.md

@ -1,25 +0,0 @@
## costumeprofit
### Instructions
Shop is selling **a** ties, **b** scarfs, **c** waistcoats, **d** jackets.
- You want to make a costume. There are 2 types of costumes :
- 1 - costume composed of tie and jacket.
- 2 - costume composed of scarf, waistcoat, and jacket.
Costumes of first type cost **e** dollars, of second type cost **f** dollars.
What is the maximum amount of dollars that shop can earn by selling costumes?
Input will be given as 6 arguments, your output should be displayed as standard output.
In the output put '\n' at the end.
Input: `go run . **a** **b** **c** **d** **e** **f**`
```console
$ go run . 12 11 13 20 4 6
102
$
```

38
subjects/doppelganger/README.md

@ -1,38 +0,0 @@
## doppelganger
### Instructions
You are given 2 strings. Find out if first string contains second string. If it does, return index of the first string where second string occurs last time. If it does not contain, return "-1"
### Expected function
```go
package main
func DoppelGanger(s, substr string) int {
}
```
```go
package main
import (
"fmt"
"piscine"
)
func main() {
var result int
result = piscine.DoppelGanger("aaaaaaa", "a")
fmt.Println(result) // 6
result = piscine.DoppelGanger("qwerty", "t")
fmt.Println(result) // 4
result = piscine.DoppelGanger("a", "b")
fmt.Println(result) // -1
}
```

46
subjects/fib/README.md

@ -1,46 +0,0 @@
## fib
### Instructions
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
You are given a non-negative integer n, please find nth element of fibonacci sequence.
Fib(0) = 0,
Fib(1) = 1, otherwise, nth element is the sum of the 2 previous elements of the series.
### Expected function
```go
func Fib(n int) int {
}
```
### Usage
Here is a possible program to test your function :
```go
package main
import "fmt"
func main() {
fmt.Println(Fib(0))
fmt.Println(Fib(1))
fmt.Println(Fib(2))
}
```
And its output :
```console
$ go run .
0
1
1
$
```

44
subjects/game23/README.md

@ -1,44 +0,0 @@
## game23
### Instructions
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
You are given 2 positive integers 'a' and 'b'. Your task is to perform some operations in 'a' so that it becomes 'b'. You can only multiply 'a' by 2, and multiply 'a' by 3. If you can get to 'b', return minimal number of operations required to get from 'a' to 'b'. If you cannot get to 'b' return -1.
### Expected function
```go
func Game23(a, b int) int {
}
```
### Usage
Here is a possible program to test your function :
```go
package main
import "fmt"
func main() {
fmt.Println(Game23(1, 3))
fmt.Println(Game23(2, 3))
fmt.Println(Game23(10, 60))
}
```
And its output :
```console
$ go run .
1
-1
2
$
```

49
subjects/halfcontest/README.md

@ -1,49 +0,0 @@
## halfcontest
### Instructions
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
You are given 4 non-negative integers 'h1', 'm1', 'h2', and 'm2'. The contest starts at h1:m1 minutes and finishes at h2:m2 minutes. Your task is to find out when half of the contest will be over and return it in the format decribed in the example.
Contest cannot finish before it was started.
### Expected function
```go
func HalfContest(h1, m1, h2, m2 int) int {
}
```
### Usage
Here is a possible program to test your function :
```go
package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.HalfContest(1, 15, 3, 33))
fmt.Println(piscine.HalfContest(10, 3, 11, 55))
fmt.Println(piscine.HalfContest(9, 2, 11, 3))
}
```
And its output :
```console
$ go run .
224
1059
1002
$
```

46
subjects/interestingnumber/README.md

@ -1,46 +0,0 @@
## interesting_number
### Instructions
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Saken thinks that number is interesting if sum of its digits is divisible by 7. You are given a positive integer 'n', return the next interesting number (could be itself).
### Expected function
```go
func InterestingNumber(n int) int {
}
```
### Usage
Here is a possible program to test your function :
```go
package main
import (
"fmt"
)
func main() {
fmt.Println(Interesting_number(1))
fmt.Println(Interesting_number(2))
fmt.Println(Interesting_number(8))
}
```
And its output :
```console
$ go run .
7
7
16
$
```

56
subjects/isanagram/README.md

@ -1,56 +0,0 @@
## isanagram
### Instructions
Write a function that returns `true` if two strings are anagrams, otherwise returns `false`.
An anagram is a string made by using the letters of another string in a different order.
Only lower case characters will be given.
### Expected function
```go
package piscine
func IsAnagram(str1, str2 string) bool {
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import (
"piscine"
"fmt"
)
func main() {
test1 := piscine.IsAnagram("listen", "silent")
fmt.Println(test1)
test2 := piscine.IsAnagram("alem", "school")
fmt.Println(test2)
test3 := piscine.IsAnagram("neat", "a net")
fmt.Println(test3)
test4 := piscine.IsAnagram("anna madrigal", "a man and a girl")
fmt.Println(test4)
}
```
Its output:
```console
$ go run .
true
false
true
true
$
```

50
subjects/nauuo/README.md

@ -1,50 +0,0 @@
## nauuo
### Instructions
There was a vote. There are people who voted positively, negatively, and randomly.
Figure out if the final answer depends on random people or not.
If it does, return '?', otherwise the result must be either '+', '-', or '0'
Previous characters stand for outcome of the vote: positive/negative/draw.
Input is always positive.
Write a function, `Nauuo`, that returns final result of voting.
### Expected function
```go
func Nauuo(plus, minus, rand int) string {
}
```
### Usage
Here is a possible program to test your function :
```go
package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.Nauuo(50, 43, 20))
fmt.Println(piscine.Nauuo(13, 13, 0))
fmt.Println(piscine.Nauuo(10, 9, 0))
fmt.Println(piscine.Nauuo(5, 9, 2))
}
```
And its output :
```console
$ go run .
?
0
+
-
$
```

22
subjects/nenokku/README.md

@ -1,22 +0,0 @@
## nenokku
### Instructions
You are given unknown amount of operations. There are 3 types of operations, you should handle each appropriately:
1. "A word" - add the "word" into your "dictionary" of words.
2. "? word" - check if the "word" is in your "dictionary".
3. "x word" - end of operations.
Intersection of words is counted as if it is in your dictionary (see example).
Write a program that takes as arguments operations.
```console
$ go run . "? love" "? is" "A loveis" "? love" "? Who" "A Whoareyou" "? is"
NO
NO
YES
NO
YES
$
```

21
subjects/printchessboard/README.md

@ -1,21 +0,0 @@
## printchessboard
### Instructions
Write a program that takes two integers as arguments and displays the chess desk, in which white cells are represented by `' '` and black cells by `'#'`.
- If the number of arguments is different from 2, or if the argument is not a positive number, the program displays `Error` followed by a newline (`'\n'`).
### Usage
```console
$ go run . 4 3 | cat -e
# # $
# #$
# # $
$ go run . 7 | cat -e
Error$
$ go run . 0 0 | cat -e
Error$
$
```

39
subjects/priorprime/README.md

@ -1,39 +0,0 @@
## priorprime
### Instructions
You are given an integer.
Your function must return sum of all prime numbers prior to the number exclusively. The number is not included.
### Expected function and structure
```go
package main
func PriorPrime(x int) int {
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import "fmt"
func main() {
fmt.Println(PriorPrime(14))
}
```
Its output:
```console
$ go run .
41
$
```

43
subjects/reachablenumber/README.md

@ -1,43 +0,0 @@
## reachablenumber
### Instructions
Let us define a function f(x) by the following: first we add 1 to x, and then while the last digit of the number equals 0, we shall be deleting 0. Let us call 'y' reachable if we can apply **f** to **x** (zero or more times), and get **y**. 102 is reachable from 10098: f(f(f(10098))) = f(f(10099)) = f(101) = f(102). Any number is reachable from itself. You are given a positive number **n**, count how many integers are reachable from **n**.
### Expected function
```go
func ReachableNumber(n int) int {
}
```
### Usage
Here is a possible program to test your function :
```go
package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.ReachableNumber(1))
fmt.Println(piscine.ReachableNumber(10))
fmt.Println(piscine.ReachableNumber(1001))
}
```
And its output :
```console
$ go run .
9
19
36
$
```

44
subjects/revivethreenums/README.md

@ -1,44 +0,0 @@
## revivethreenums
### Instructions
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
There are basically three integers: **a**, **b**, **c**. You are given 4 integers: **b+c**, **a+b**, **c+a**, **a+b+c** (not necessarily in this order). Return maximum of a, b, c.
### Expected function
```go
func ReviveThreeNums(a, b, c, d int) int {
}
```
### Usage
Here is a possible program to test your function :
```go
package main
import "fmt"
func main() {
fmt.Println(ReviveThreeNums(3, 6, 5, 4))
fmt.Println(ReviveThreeNums(40, 40, 40, 60))
fmt.Println(ReviveThreeNums(201, 101, 101, 200))
}
```
And its output :
```console
$ go run .
3
20
100
$
```

29
subjects/robottoorigin/README.md

@ -1,29 +0,0 @@
## robottoorigin
### Instructions
There is a robot at position (0, 0) at 2D map.
Write a program, that outputs `true` if robot ends up at the origin (0, 0) after a sequence of moves, otherwise `false`. `\n` should be in the end of line.
Sequence of moves is a string, which characters state for movement direction:
- U - up
- D - down
- R - right
- L - left
If the number of arguments is not 1, output nothing.
### Usage
```console
$ go run . "UD"
true
$ go run . "LL"
false
```
In first case, the robot moves up and the down. So, it returned back to its origin position.
In second example, the robot moves twice to the left. It is 2 positions left from its origin, so the program outputs false.

44
subjects/sweetproblem/README.md

@ -1,44 +0,0 @@
## sweet_problem
### Instructions
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Madina loves sweets, but she only has 3 types of sweets: red, green, blue. Her diet has some restrictions, she must not eat more than 2 sweets per day, and they must be of different color. Help her eat as many sweets as possible, return the maximum number of days she can keep eating 2 different sweets.
### Expected function
```go
func Sweetproblem(red, green, blue int) int {
}
```
### Usage
Here is a possible program to test your function :
```go
package main
import "fmt"
func main() {
fmt.Println(Sweetproblem(1, 1, 1))
fmt.Println(Sweetproblem(7, 4, 10))
fmt.Println(Sweetproblem(8, 2, 8))
}
```
And its output :
```console
$ go run .
1
10
9
$
```

22
subjects/uniqueoccurences/README.md

@ -1,22 +0,0 @@
## uniqueoccurences
### Instructions
Write a program that outputs `true` if the number of occurrences of each character is unique, otherwise `false`. `\n` should be at the end of the line.
If number of arguments is not 1 output nothing.
Only lower case characters will be given.
### Usage
```console
$ go run . abbaac
true
$ go run . ab
false
$ go run . abcacccazb
true
```
In first example, character 'a' has 3 occurrences, 'b' has 2 and 'c' has 1. No two characters have the same number of occurrences.

46
subjects/volumechanger/README.md

@ -1,46 +0,0 @@
## volumechanger
### Instructions
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
Dagar loves watching TV. He always makes the volume to be **b**. Today he is angry, because he found out that someone changed the volume, and now, the volume is **a**.
His remote controller can change the volume by: -5, -2, -1, +1, +2, +5.
Please help Dagar, to minimize number of button presses, and calculate how many times he should press buttons of remote controller so that it changes from **a** to **b**.
There are **t** requests in total.
Input and output should be displayed in standard input and output respectively.
### Expected function
```go
func Volumechanger(a, b int) int {
}
```
### Usage
Here is a possible program to test your function :
```go
package main
import "fmt"
func main() {
fmt.Println(Volumechanger(4, 0))
fmt.Println(Volumechanger(5, 14))
fmt.Println(Volumechanger(3, 9))
}
```
And its output :
```console
$ go run .
2
3
2
$
```
Loading…
Cancel
Save