Haskell homework assignments do proxy programming, ghostwriting Haskell homework programming

Haskell作业任务代做代编程、代写Haskell作业编程Basically
use elem, head, tail, map, reverse, last, filter, concat, sum
and (++) to program the following list processing functions in Haskell –
The use of pattern matching is forbidden:
a) A function that receives a
string1 and is supposed to carry out the following replacements first
:
– If a character corresponds to a digit, it is to be mapped to the corresponding number
.
– If a character corresponds to the letter a, then this character should be mapped to the number 1
.
– All other characters are to be mapped to the number 0.
Then the sum of these numbers should be calculated.
For example, the value 14 should be calculated for ¨ "138aza" . (7 points)
b) Some people nowadays give a particularly friendly emphasis to a statement
by capitalizing everything? to write. Likewise, some people type what feels like 20,000 characters
per second with their smartphone, but have absolutely no time to pay attention to upper and lower case
letters. Give a function that takes a list of strings and converts
all lowercase letters in a string that ends with an exclamation mark to uppercase
. However, if a string does not end with an exclamation mark, all
uppercase letters should be converted to lowercase. For example, for ¨
["You're as smart as a banana peel and half as good looking!",
"I write every word in lower case, subordinate clauses and periods I don't know"]
the following result can be calculated:
["YOU ARE AS INTELLIGENT AS A BANANA PEEL AND HALF AS HANDSOME! ",
"I write every word in lowercase subordinate clauses and I don't know periods"]
(7 points)
c) A function that preserves a list of lists of numbers and first removes all innermost
lists that contain fewer than 4 elements . The remaining inner lists ¨
should be flipped over and, in addition, all elements except
the first three should be removed from each inner list. After that, all inner lists should be merged into one big one
will. For example, for ¨ [[1,2],[1..4],[6..8],[8..12]] the result
[4,3,2,12,11,10] should be calculated . (11 points)
1Strings in Haskell are nothing more than lists of characters, ie "Haskell" is just another representation
for the list ¨ ['H','a','s','k','e',' l','l'].
1
Note: The Data.Char library contains useful functions that you may use in your
solution.
You can include the library in your program with import Data.Char at the beginning of the source code . Library documentation can be found on the Internet
at http://www.haskell.org/ghc/docs/latest/html/libraries/.
Task 2 (30 points)
In Haskell, implement the following functions on lists, essentially using
pattern matching and recursion—that is, you may define and
use helper functions, but using list functions such as map, concat, replicate
, and so on is forbidden.
a) A function that expects a list and swaps any two adjacent elements.
If the list contains an odd number of elements, the position of the
last element remains unchanged.
For example, the result [2,1,4,3,6,5,8,7,9] should be calculated for the list ¨ [1..9] . (7 points)
b) A function that expects a list of lists of lists of numbers and the sum
calculated from the first elements of the innermost lists. For example, 44 is to be computed for the
list [[[1,2],[4,5],[7,8,9]],[[13,15],[19]]]. (10 points)
c) A function that expects a list and returns a list that contains the kth element
of the input list k times. The order should remain unchanged and
the list index extends from 1 to the length of the list. For example, for the list ¨
['a','b','c'] the result "abbccc" should be calculated. (13 points) Exercise
3 (45 points)
This exercise deals with darts.
The dart board is divided into 20 number segments. The fields each count as much as on the outside
is noted on the relevant segment. Exceptions are the narrow circles. The fields in the outer circle
count double (double fields) and in the middle circle triple (triple fields)
the corresponding number. The middle of the board, the bullseye, counts 50 points (double 25),
the ring around it (bull) counts 25 points. Variant 501 is played with a double-out:
Each player starts with 501 points. A shot consists
of (maximum) three consecutively thrown darts.
The points scored are deducted from the remaining points each time, with the respective opponent
taking a turn after each shot .
Only those
darts that get stuck in the board may be counted. won
has the player who first
reaches exactly 0 points, whereby the last dart must hit a double field or
the bullseye. If the player scores too many points
or so many that he can no longer finish with a double
(the player throws himself), then all
darts of this shot are not counted - the player stays
on the same rest as before Admission. In the last
shot, where the score is reduced to exactly 0
, fewer than 3 darts can be thrown.
If you overthrow, a shot can also consist of
less than 3 darts.
20 5 1
12 18
9 4
14 13
11 6
8 10
16 15
7 2
19 17 3
double
triple
Bullseye
Bull
single
A single game of this type is called a leg. Whoever wins a set number of legs first
wins the entire game. The players start the legs alternately.
2
A leg in the above mode is represented in Haskell as follows:
? A list of exactly two elements [m, p] represents the score of a single dart thrown
, where m is a 1, 2, or 3 corresponding to single, double, or triple
and p is the score of the number segment. That means the triple 20 corresponds to the representation
[3, 20], double 20 [2, 20] and single 20 [1, 20]. Because the bullseye counts as a double
it is represented as [2, 25]. Also, [0, 0] corresponds to a miss.
? A record is a list of such two-element lists, e.g.,
[[3, 20], [3, 19], [2, 25]] corresponds to a hit in the triple 20, followed by a hit in the triple
19, followed by a hit into the bullseye. If a player has already
completed his shot with fewer than 3 darts, i.e. thrown out or won the leg,
the list contains correspondingly fewer elements.
? A leg is represented by a list of shots (i.e. a list of lists with two-element
lists) in which every odd-numbered shot
is assigned to the player who started the leg and all even-numbered shots to the opponent.
Here are some example legs:
leg1 = [[[3,20],[3,20],[3,20]], [[3,20],[3,19],[2,25]], [ [3,19],[3,19],[3,19]],
[[3,20],[3,19],[2,25]], [[2,25],[2,25 ],[2,25]]]
leg2 = [[[3,20],[3,20],[3,20]],[[3,20],[3,19],[2,25] ],[[3,19],[3,19],[3,19]],
[[3,20],[3,19],[2,25]],[[2,25],[ 2,25],[1,25]],[[3,20],[3,19],[2,25]]]
leg3 = [[[3,20],[1,20],[1 ,20]], [[3,20],[1,20],[1,20]], [[3,20],[3,20],[3,20]],
[[3,20 ],[3,20],[3,20]], [[3,20],[1,1] ,[2,20]], [[3,20],[1,1] ,[2 ,20]],
[[3,20],[1,20],[2,20]]]
leg4 = [[[3,20],[1,20],[1,20]],[[ 3,20],[1,20],[1,20]], [[3,20],[3,20],[3,20]],
[[3,20],[3,20] ,[3,20]], [[3,20],[1,1] ,[2,20]], [[3,20],[1,1] ,[2,20]],
[[ 3,20],[1,20],[1,20]],[[3,20],[1,20],[2,20]]]
a) In Haskell, implement a function legWinner that takes a leg in the above representation
as input and returns 1 if the player who started the leg
wins, and 2 if the other player wins. Please consider
the rules presented above.
The function should return ¨ 0 for bad legs. For example, if no player
has reached exactly ¨ 0 points, the specified fields do not even exist (e.g. TripleBull
or Single-21) or if a player has already won and the opponent
still throws afterwards.
For the example legs, legWinner leg1 should return 1 as a result and legWinner leg2
should calculate 2.
Tip: Use helper functions to cover the rules systematically. How
to easily implement player rotation? (35 points)
b) The last maximum of 3 throws of a leg, which the winner of the leg needs to win,
is called the finish. Implement a function highOut in Haskell, which takes a list
of legs in the above representation and
calculates the highest finish over all legs for the player who starts the first leg. Note that this
information should be able to be calculated during the game, so the
last leg in the input list may not have been played to the end. If the player has not (yet)
won a leg, 0 should be returned. ¨
For example, highOut [leg3,leg2,leg3,leg4,leg3] should return the result 167,
while 0 should be returned for highOut [leg4,leg3]. (10 points) ¨

The core members of the team mainly include Silicon Valley engineers, BAT front-line engineers, top 5 master and doctoral students in China, and are proficient in German and English! Our main business scope is to do programming assignments, course design and so on.

 

Our field of direction: window programming, numerical algorithm, AI, artificial intelligence, financial statistics, econometric analysis, big data, network programming, WEB programming, communication programming, game programming, multimedia linux, plug-in programming program, API, image processing, embedded/MCU database programming, console process and thread, network security, assembly language hardware Programming software design engineering standards and regulations. The ghostwriting and ghostwriting programming languages ​​or tools include but are not limited to the following:

C/C++/C# ghostwriting

Java ghostwriting

IT ghostwriting

Python ghostwriting

Tutored programming assignments

Matlab ghostwriting

Haskell ghostwriting

Processing ghostwriting

Building a Linux environment

Rust ghostwriting

Data Structure Assginment

MIPS ghostwriting

Machine Learning homework ghostwriting

Oracle/SQL/PostgreSQL/Pig database ghostwriting/doing/coaching

web development, website development, website work

ASP.NET website development

Finance Insurance Statistics Statistics, Regression, Iteration

Prolog ghostwriting

Computer Computational method

 

Because professional, so trustworthy. If necessary, please add QQ: 99515681 or email: [email protected]

WeChat: codinghelp

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325162800&siteId=291194637