Coder Social home page Coder Social logo

find-lucky-number's Introduction

Find lucky number

A "lucky number" is one where the digits add up to 7 in successive additions (7 itself also counts as a lucky number). For example, 62431 is a lucky number because 6 + 2 + 4 + 3 + 1 = 16, 1 + 6 = 7. Your task will be to write a program that finds all lucky numbers between arg1 and arg2 (both inclusive). Both arguments are required and will be positive integers. Assume that arg1 < arg2.

You will submit two files: a RSpec file and a Ruby file. Your RSpec tests should ensure that the program functions properly for any arguments meeting the above criteria. Don't worry about testing for invalid arguments - the focus should be on the lucky number logic. Please add tests at the minimum for the following cases: 100 to 200, 62,400 to 62,500, and 999,999,999,900 to 1,000,000,000,000. Feel free to add additional test cases as desired.

Your program should work as follows (arg1 = 100, arg2 = 200):

ruby lucky.rb 100 200

With resulting output:

106
115
124
133
142
151
160
169
178
187
196

How to run ruby program

$ ruby find_lucky_number.rb

How to run Test Case (RSpec) reference link

gem install rspec

$ rspec specs_lucky_number.rb

find-lucky-number's People

Contributors

nikhilthombare avatar nikhilthombare-cuelogic avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.