Use DrRacket. Define the procedures below. Write a procedure reverse-digits (n) which returns a number with the digits of n in reverse order. For example, (reverse-digits 397164) → 461793.   Define a predicate same-digits? (a b) which returns #t if the integers a and b contain the same digits. If a digit occurs n times in a, it must also occur n times in b. For example, (same-digits? 133042 420313) → #t, but (same-digits? 133042 42013) → #f.   To solve the problem, one technique would be to add some extra procedures for manipulating digits inside a number. Here are some hints: To find the number of digits in a number, count how many times you need to divide it by 10 until you reach 0. To extract the second digit of 5784: floor( 5784/102 ) mod 10=7. Note that mod in racket is modulo or remainder To assemble the digits 3, 4, and 5 into a number: 3×102+4×101+5×100 = 345 The standard Scheme procedures modulo and floor may prove useful. The solution only needs to consider non-negative integers. Or..... you could "cheat" and convert each number to a list, sort, and check for equality.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Use DrRacket.

Define the procedures below.

  1. Write a procedure reverse-digits (n) which returns a number with the digits of n in reverse order. For example, (reverse-digits 397164) → 461793.

     

  2. Define a predicate same-digits? (a b) which returns #t if the integers a and b contain the same digits. If a digit occurs n times in a, it must also occur n times in b. For example, (same-digits? 133042 420313) → #t, but (same-digits? 133042 42013) → #f.

     

To solve the problem, one technique would be to add some extra procedures for manipulating digits inside a number. Here are some hints:

  • To find the number of digits in a number, count how many times you need to divide it by 10 until you reach 0.
  • To extract the second digit of 5784: floor( 5784/102 ) mod 10=7. Note that mod in racket is modulo or remainder
  • To assemble the digits 3, 4, and 5 into a number: 3×102+4×101+5×10= 345

The standard Scheme procedures modulo and floor may prove useful. The solution only needs to consider non-negative integers.

Or..... you could "cheat" and convert each number to a list, sort, and check for equality.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY