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년 전

돈을 좀 벌 생각이십니까?

프리랜서 입찰의 이점

예산 및 기간 설정
작업 결과에 대한 급여 수급
제안의 개요를 자세히 쓰세요
무료로 프로젝트에 신청하고 입찰할 수 있습니다

고객에 대한 정보

국기 (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)
미리 보기 화면을 준비 중...
위치 정보 관련 접근권이 허용되었습니다.
고객님의 로그인 세션이 만료되어, 자동으로 로그아웃 처리가 되었습니다. 다시 로그인하여 주십시오.