Question

FOR RUBY DEBUG ASSIGNMENT ============================== Each program contains bugs please solve until answer is correct: >...

FOR RUBY

DEBUG ASSIGNMENT

==============================

Each program contains bugs please solve until answer is correct:

> |1, 2, 3|length

answer => 3

> [3, 1, 2,].sorta

answer => [1, 2, 3]

> %w[1, nill, 2, 3, nil].compact

answer => [1, 2, 3]

> {1 2 3}.index(5)

answer => 2

> [1, 2, 3, 4].rotat(2)

answer => [3, 4, 1, 2]

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please refer below the program and output screenshot

Code

# provided "square bracket"

[1, 2, 3].length

# removed "a" from "sorta"
[3, 1, 2,].sort

# removed %w and replaced "nill" with "nil"
[1, nil, 2, 3, nil].compact

# instead of "5" gave "3" in index and replace curly bracket { } with square brackets [ ]

[1, 2, 3].index(3)

# instead of "rotat", gave "rotate"
[1, 2, 3, 4].rotate(2)

Output

3                                                                                                                       

[1, 2, 3]                                                                                                               

[1, 2, 3]                                                                                                               

2                                                                                                                       

[3, 4, 1, 2]

Code Screenshot and output

> (1, 2, 3].length => 3 > (3, 1, 2,].sort => [1, 2, 3] 3 [1, nil, 2, 3, nil].compact => [1, 2, 3] > (1, 2, 3].index(3) => 2 [

Add a comment
Know the answer?
Add Answer to:
FOR RUBY DEBUG ASSIGNMENT ============================== Each program contains bugs please solve until answer is correct: >...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Wk 4 - Write a Ruby Program (due Mon] Assignment Content The college IT department manager...

    Wk 4 - Write a Ruby Program (due Mon] Assignment Content The college IT department manager no longer wants to use spreadsheets to calculate grades. Instead, the manager has asked you to create a program that will input the teachers' files and output the students' grades. Write a Ruby program named format file.rb, which can be run by typing ruby widgets.rb. In your Ruby environment, the program must read an input file formatted in CSV format, named input.csv. Each record...

  • Please answer in excel with an explanation of each step -Ruby purchased a 10-year 4.2% p.a....

    Please answer in excel with an explanation of each step -Ruby purchased a 10-year 4.2% p.a. Treasury bond with a face value of $100 at a price of 98.545 10 years ago. The bond was redeemable at par. Immediately following the receipt of each coupon, Ruby deposited the coupon into a bank account earning a particular reinvestment rate. Over the 10 years the reinvestment rates Ruby earns are shown in table 1. At the time of purchase. Ruby used her...

  • Ruby Assignment - Text file format conversion: Write a program that will take a text file...

    Ruby Assignment - Text file format conversion: Write a program that will take a text file with lines in this format: Last_name:First_name:Number_of_cats:Number_of_dogs:Number_of_fish:Number_of_other_pets and produce a text file with lines in this format: First_name Last_name:Total_number_of_pets For example, if the original text file looks like this: Chawla:Kalpana:0:0:3:0 Davis:Jo Ann:0:0:5:2 de Vries:Gustav:3:1:0:1 Goldberg:Adele:2:1:1:0 Noriega:Carlos:2:2:0:0 Ride:Sally:0:1:0:2 Turing:Alan:0:0:0:0 the new text file should look like this: Kalpana Chawla:3 Jo Ann Davis:7 Gustav de Vries:5 Adele Goldberg:4 Carlos Noriega:4 Sally Ride:3 Alan Turing:0 Note that first...

  • Python Assignment: Write a program that uses stacks to solve postfix equations.Read the below in a...

    Python Assignment: Write a program that uses stacks to solve postfix equations.Read the below in a strings, character by character, into a stack and solve them. 3 2 + 4 * 5 1 - /

  • Could someone please solve it? its java - The average of each integer array is stored...

    Could someone please solve it? its java - The average of each integer array is stored in another array coedum Answer the three questions below using this program public class averageMultidin 2 public static void main(String[] args) { int(01) tablet (1,2,3), (0,57,101) },{ (38,-80,95),(-10,13,34) ) ); 5 3 double[] sumar - new double 4); int sum = 0; int index = 0; 9 11 System.out.println("Sizesi "table.length-table().length. table[ejto).length); 12 for (int i = 0; i < table.length; i++) for (int j...

  • ASSIGNMENT: Create a program to do the following: BONUS: A bonus of 20 points if you create the p...

    ASSIGNMENT: Create a program to do the following: BONUS: A bonus of 20 points if you create the program in such a way that there is no limit on the number of names to be handled. 1) Read in names to sort until the user types the “enter” key as the first character of a “C-type” string (the maximum number of names is 20, there is not a maximum length to a name), using a two dimensional array of characters....

  • THE ATTACHED PICTURES ARE THE ALGORITHMS of link list IN C PLEASE write the programs of...

    THE ATTACHED PICTURES ARE THE ALGORITHMS of link list IN C PLEASE write the programs of these pictures in C++ while writing the programs make sure that your programs are correct and please do them separately and while doing them comment the EACH STEP I AM posting my question third time please do them PROPERLY and do them separately and comment EACH STEP Please do it properly label EACH STEP in EACH program of C++ please do not do it...

  • Linear Algebra: Please Solve and provide answer in correct format. Thank You Answer Preview Messayes Entered...

    Linear Algebra: Please Solve and provide answer in correct format. Thank You Answer Preview Messayes Entered 0.447213595499958,-0.4 0.894427190999916 4.8 0.894427190999916-5.8 Result incorrect You have entered vector(s) which are not of unit length The answer above is NOT correct (1 pt) [1-15 Let A = 2-66 2-75 Find an orthonormal basis of the column space of A 1/sqrt(5) -215 2/sqrt(5) -24/5 2/sqrt(5)

  • I need help solving this assignment, you are given a full piece of code that does not run correctly. Some of the bugs ca...

    I need help solving this assignment, you are given a full piece of code that does not run correctly. Some of the bugs can be found at compile time, while others are found at run time. Access the UserMenu.cpp code file (in the zip file in Start Here) and use debugging practices and the debugger in Visual Studio to find each bug. Fix the bug and write a comment in the code giving a description of how you found the...

  • please use the c language Assignment 12 The program to write in this assignment is a...

    please use the c language Assignment 12 The program to write in this assignment is a program that calculates score statistics and manages the grades of the students. First, the student list and are given in a file named "student.dat" as in the following: 이성우 77 홍길동 88 scores 201 1710086 2012700091 This program reads the input file "student.dat" and keeps this data in a linear linked list. Each node must be a struct which contains the following: student id...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT