Navigation : 
        
          
    
   AP CS 
    
   Artificial Intelligence 
    
   Intermediate CS  
    
  - 
   3. Images 
    
  - 
   7. Numbers 
    
  - 
   8. Number Models 
    
  - 
   13. Booleans 
    
  - 
   15. Conditionals 
    
  - 
   20. Using Structures 
    
  - 
   Sem.I Review 
    
  - 
   21. Structures 
    
  - 
   22a. Recursion  
      -- 22a. Fibonacci 
      -- 22a. Digits 
      -- 22a. Sum Digits 
      -- 22a. Fibsum 
      -- 22a. More Recursion 
      -- 22a. Harmonic 
      -- 22a. Practice++ 
      -- 22a. ss3 
      -- 22a. Recursive Helpers 
      -- 22a. Recursion Quiz Practice 
      -- 22a. Recursion Quiz 2018 
      -- 22a. Recursion Practice I 2019 
      -- Roygbiv Code 
      -- 22a. Strings 
      -- 22a. Helpers 
      -- 22a. Helpers: Count Divisors 
      -- 22a. Recursion Practice 3 
      -- 22a. Recursion Self Quiz 
      -- 22a. Recursion Practice 4 
      -- 22a. Mini-Quiz 
      -- 22a. Recursion Quiz 2 
      -- 22a. Recursion Practice 5 
      -- 22a. Recursion Practice 6 
      -- Quiz 3 (Hard) 
      -- Quiz 4 (Medium) 
    
  -- 
   22a. Hangman Project 
  
    
  - 
   22b. Lists 
    
  - 
   Sem.II Review 
    
  - 
   Typed Racket 
    
  - 
   Resources 
    
  - 
   Pro Features 
      - Online Help 
  
    
   Robotics 
    
   WY Robotics 
    
   Exploring CS (Teachers) 
    
   Resources 
         
       
    
    
    Roygbiv Code 
    
    
    
    We are going to write an encoding function that makes an image like a
bar code, but using colored rectangles insteada of bars.
      
            Encoded phone number 
         
 
Each digit will map to a 30x70 rectangle. The colors of the digits 0
through 9 will be the usual rainbow: red, orange, yellow, green, blue, indigo, violet, and then three randomly chosen colors:
 (define rc7 (make-color 25 134 240))
 (define rc8 (make-color 121 143 37))
 (define rc9 (make-color 220 194 21))
 
For example, an input of 7510 to encode gives the code below.
      
            (encode 7510) 
         
 
Write a function to create a color-based bar code.
Answered questions 
You should ignore leading zeros. 
 
Got the encoder working? Write a decoder that takes in an image and
produces an integer.