GithubHelp home page GithubHelp logo

codegolf's Introduction

Halifax Code Golf

Rules of Code Golf

  • Solve problem
  • Lowest character count wins*

Try

  • Make it work
  • Make is small
  • Make it really small
  • No smaller than than I can still read it

*Small print

  • File size in bytes is score.
  • Hint: Use linux line endings and ASCII text files
  • Adjudicator's decision on “solution good and in the spirit of the problem posed” is final.

Hole 1 - Ten Green Bottles

Print the following rhyme to the console

Ten green bottles standing on the wall
Ten green bottles standing on the wall
And if one green bottle should accidentally fall,
There'll be nine green bottles standing on the wall.

Note: Care must be taken to match case, line endings and punctuation

Hole 2 - FizzBuzz

Challenge

Write a program that prints the decimal numbers from 1 to 100 inclusive. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

Output

The output will be a list of numbers (and Fizzes, Buzzes and FizzBuzzes) separated by a newline (either \n or \r\n). A trailing newline is acceptable, but a leading newline is not. Apart from your choice of newline, the output should look like this:

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16

...

91
92
Fizz
94
Buzz
Fizz
97
98
Fizz
Buzz

Hole 3 - Collatz Sequence

Rules

Take any integer number n.

  • If n is even, divide it by 2 to get n/2
  • If n is odd multiply it by 3 and add 1 to obtain 3n+1 Repeat the process forming a sequence of numbers until you reach 1.

So the sequence starting with 13 is:

13, 40, 20, 10, 5, 16, 8, 4, 2, 1

With a length of 10

See https://en.wikipedia.org/wiki/Collatz_conjecture for further information.

Task

Read a number from the command line or user input and output the length of the Collatz sequence.

codegolf's People

Contributors

adampridmore avatar hermannlucas avatar foz1284 avatar

Watchers

James Cloos avatar  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.