Find Jobs
Hire Freelancers

Scheme code needed

$2-8 USD / hour

クローズ
投稿日: 5年以上前

$2-8 USD / hour

files: ​1.)​The source code must be in R5RS. Any other scheme or lisp dialect will be an automatic 0. ​2.)​1 - 2 page description of your algorithm and its complexity as an ACII text document, MS Word document, or a PDF file. Since the program you must write is short, the description of the algorithm and complexity analysis carry significant weight on your grade. Pack all your files in a zip file. Use the following naming conventions. If your name is John Smith, then your file name must be jsmith.zip. Zip files which are not properly named or packed will receive 0 points. Write a function has-subtarget? that takes a list of three or more positive integers, duplicates are possible and 0 is not included, and returns true (#t) if there are two non-empty sublists whose sums are both equal to a value in the list that is not part of either sublist. False (#f), if no two such sublists exist. The values of the sublist do not need to be contiguous in the original list. Not all values need to be used. In other words, values can belong to either sublist or neither sublist. They cannot, however, belong to both sublists at the same time. The list passed to has-target-num? is flat, i.e., it does not itself contain sublists. It is up to you to choose the auxiliary parameters that has-target-num? takes. Auxiliary parameters are parameters used to help find the solution and are scalar. In other words, they hold single values not a collection of values. The list parameter is mandatory is not an auxiliary parameter. All auxiliary parameters must be numeric and must be initialized to zero when the function is called. There may be more than two values that have two sublists or more than two sublists that equal some value. In both cases a single true (#t) should be returned. Example Calls: If the list is ‘(1 2 3) and you decide to use two additional auxiliary parameters, has-subtarget? should be called as follows. (has-subtarget? ‘(1 2 3) 0 0) If three auxiliary parameters are used then the call should be: (has-subtarget? ‘(1 2 3) 0 0 0) Test Calls: ‘ (2 1 3 9 4 8) returns true because {2 4 3} and {1 8} both sum to 9. ‘(1 1 2 2) returns true because {1 1} and {2} both sum to 2, however… ‘(1 1 2) returns false because there are no two sublists have sums that are a target in the list. ‘(5 6 7) returns false because no two sublists have sums that are a target in the list. '(17 35 1 26 24 12 25 40 33 31) returns false. ‘(6 21 84 66 100 53 73 38 29 81 66 69 54 8 94) returns true. The Code The whole code solution must be packed into one recursive function, has-subtarget?, which must look as follows (define has-subtarget? (lambda (<list L followed by your auxiliary ​​​​​​​​​parameters of your choice>) ​​​​​(cond ​​​​​​… ))) In other words, your function must take as its first argument a list followed by as many auxiliary parameters of your choice that will be initialized to 0 when called. You may only have a single cond statement in your entire function. Inside cond you can only use the following scheme constructs: - null? - car - cdr - else - + - = - > - if - and - or - has-subtarget? - user defined names (for the names of your parameters) - integer literals - parentheses You may not use a construct if it is not listed. The use of user-defined functions, except for has-subtarget?, is not allowed. You cannot define or call any other function except for what is listed above. This means you must write only a single function. If your program uses a construct not on the list, then it is not a solution to this homework. Points will be drastically removed for any construct used not in the list above. If you have a question about a construct you want to use you may ask. This will not guarantee you will be allowed to use it. NOTE: Make sure before you submit to remove any debug code. If you leave any code that writes to stdout or have extra lists outside the main list, it will be counted against your score.
プロジェクト ID: 18126746

プロジェクトについて

リモートプロジェクト
アクティブ 5年前

お金を稼ぎたいですか?

Freelancerで入札する利点

予算と期間を設定してください
仕事で報酬を得る
提案をご説明ください
登録して仕事に入札するのは無料です

クライアントについて

OMANのフラグ
Mutrah, Oman
4.9
381
お支払い方法確認済み
メンバー登録日:11月 17, 2009

クライアント確認

ありがとうございます!無料クレジットを受け取るリンクをメールしました。
メールを送信中に問題が発生しました。もう一度お試しください。
登録ユーザー 投稿された仕事の合計
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
プレビューを読み込み中
位置情報へのアクセスが許可されました。
あなたのログインセッションの有効期限がきれ、ログアウトされました。もう一度ログインしてください。