Last active
September 28, 2016 10:35
-
-
Save stianeikeland/362b5da2e18daa58c149275c03e2980d to your computer and use it in GitHub Desktop.
Kata bitshift 28. sept.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write a function that returns true or false depending on whether its input integer is a leap year or not. | |
Begin on the top and work your way through the rules. | |
1. A leap year is divisible by 4. | |
Ex: 2001 is not a leap year. 1996 is a leap year. | |
2. .. but leap years are not divisible by 100. | |
Ex: 1900 is not a leap year. | |
3. .. unless it's also divisble by 400. | |
Ex: 2000 is a leap year. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write a function that takes two arguments, a string, and a column number. | |
The function returns the string, but with line breaks inserted at just the right places | |
to make sure that no line is longer than the column number. | |
- Try to break lines at word boundaries. | |
- Introduced new lines should not start by space. | |
- What about words that are longer than the column number? | |
================ | |
Advanced: | |
- Can you break the lines in a more pretty way (less raggy)? | |
wrap("aaa bb cc ddddd.", 6); | |
raggy pretty | |
------ ------ | |
aaa bb aaa | |
cc vs bb cc | |
ddddd. ddddd. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment