Code Monkey home page Code Monkey logo

code-challenges-java's People

Contributors

divinedragon avatar

Watchers

 avatar

code-challenges-java's Issues

CodingBat - Warmup1 - endUp

Write code and JUnit test cases for CodingBat - Warmup1 - endUp

Problem Statement:

The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return true if we sleep in.

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

public String endUp(String str) {
}

CodingBat - Warmup1 - or35

Write code and JUnit test cases for CodingBat - Warmup1 - or35

Problem Statement:

Return true if the given non-negative number is a multiple of 3 or a multiple of 5. Use the % "mod" operator -- see Introduction to Mod

or35(3) → true
or35(10) → true
or35(8) → false

Expected method declaration

public boolean or35(int n) {
}

CodingBat - Warmup2 - frontTimes

Write code and JUnit test cases for CodingBat - Warmup2 - frontTimes

Problem Statement:

The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return true if we sleep in.

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

public String frontTimes(String str, int n) {
}

CodingBat - Warmup2 - stringSplosion

Write code and JUnit test cases for CodingBat - Warmup2 - stringSplosion

Problem Statement:

Given a non-empty string like "Code" return a string like "CCoCodCode".

stringSplosion("Code") → "CCoCodCode"
stringSplosion("abc") → "aababc"
stringSplosion("ab") → "aab"

Expected method declaration

public String stringSplosion(String str) {
}

CodingBat - Warmup1 - sumDouble

Write code and JUnit test cases for CodingBat - Warmup1 - sumDouble

Problem Statement:

Given two int values, return their sum. Unless the two values are the same, then return double their sum.

sumDouble(1, 2) → 3
sumDouble(3, 2) → 5
sumDouble(2, 2) → 8

Expected method declaration

public int sumDouble(int a, int b) {
}

CodingBat - Warmup2

Tasklist

### Tasks
- [x] https://github.com/divinedragon/code-challenges-java/issues/45
- [x] https://github.com/divinedragon/code-challenges-java/issues/46
- [x] https://github.com/divinedragon/code-challenges-java/issues/47
- [x] https://github.com/divinedragon/code-challenges-java/issues/48
- [x] https://github.com/divinedragon/code-challenges-java/issues/49
- [x] https://github.com/divinedragon/code-challenges-java/issues/50
- [x] https://github.com/divinedragon/code-challenges-java/issues/51
- [x] https://github.com/divinedragon/code-challenges-java/issues/52
- [x] https://github.com/divinedragon/code-challenges-java/issues/53
- [x] https://github.com/divinedragon/code-challenges-java/issues/54
- [x] https://github.com/divinedragon/code-challenges-java/issues/55
- [x] https://github.com/divinedragon/code-challenges-java/issues/56
- [x] https://github.com/divinedragon/code-challenges-java/issues/57
- [x] https://github.com/divinedragon/code-challenges-java/issues/58
- [x] https://github.com/divinedragon/code-challenges-java/issues/59
- [x] https://github.com/divinedragon/code-challenges-java/issues/60
- [x] https://github.com/divinedragon/code-challenges-java/issues/61

Issues in the Epic

CodingBat - Warmup1 - startHi

Write code and JUnit test cases for CodingBat - Warmup1 - startHi

Problem Statement:

Given a string, return true if the string starts with "hi" and false otherwise.

startHi("hi there") → true
startHi("hi") → true
startHi("hello hi") → false

Expected method declaration

public boolean startHi(String str) {
}

CodingBat - Warmup1 - everyNth

Write code and JUnit test cases for CodingBat - Warmup1 - everyNth

Problem Statement:

The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return true if we sleep in.

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

public String everyNth(String str, int n) {
}

CodingBat - Warmup1 - frontBack

Write code and JUnit test cases for CodingBat - Warmup1 - frontBack

Problem Statement:

The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return true if we sleep in.

frontBack("code") → "eodc"
frontBack("a") → "a"
frontBack("ab") → "ba"

Expected method declaration

public String frontBack(String str) {
}

CodingBat - Warmup1 - parrotTrouble

Write code and JUnit test cases for CodingBat - Warmup1 - parrotTrouble

Problem Statement:

We have a loud talking parrot. The "hour" parameter is the current hour time in the range 0..23. We are in trouble if the parrot is talking and the hour is before 7 or after 20. Return true if we are in trouble.

parrotTrouble(true, 6) → true
parrotTrouble(true, 7) → false
parrotTrouble(false, 6) → false

Expected method declaration

public boolean parrotTrouble(boolean talking, int hour) {
}

CodingBat - Warmup1 - makes10

Write code and JUnit test cases for CodingBat - Warmup1 - makes10

Problem Statement:

Given 2 ints, a and b, return true if one if them is 10 or if their sum is 10.

makes10(9, 10) → true
makes10(9, 9) → false
makes10(1, 9) → true

Expected method declaration

public boolean sleepIn(boolean weekday, boolean vacation) {
}

CodingBat - Warmup1 - in1020

Write code and JUnit test cases for CodingBat - Warmup1 - in1020

Problem Statement:

Given 2 int values, return true if either of them is in the range 10..20 inclusive.

in1020(12, 99) → true
in1020(21, 12) → true
in1020(8, 99) → false

Expected method declaration

public boolean in1020(int a, int b) {
}

CodingBat - Warmup1 - stringE

Write code and JUnit test cases for CodingBat - Warmup1 - stringE

Problem Statement:

The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return true if we sleep in.

stringE("Hello") → true
stringE("Heelle") → true
stringE("Heelele") → false

Expected method declaration

public boolean sleepIn(boolean weekday, boolean vacation) {
}

CodingBat - Warmup1 - startOz

Write code and JUnit test cases for CodingBat - Warmup1 - startOz

Problem Statement:

Given a string, return a string made of the first 2 chars (if present), however include first char only if it is 'o' and include the second only if it is 'z', so "ozymandias" yields "oz".

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

public String startOz(String str) {
}

CodingBat - Warmup2 - stringBits

Write code and JUnit test cases for CodingBat - Warmup2 - stringBits

Problem Statement:

Given a string, return a new string made of every other char starting with the first, so "Hello" yields "Hlo".

stringBits("Hello") → "Hlo"
stringBits("Hi") → "H"
stringBits("Heeololeo") → "Hello"

Expected method declaration

public String stringBits(String str) {
}

CodingBat - Warmup1 - sleepIn

Write code and JUnit test cases for CodingBat - Warmup1 - sleepIn

Problem Statement:

The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return true if we sleep in.

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

public boolean sleepIn(boolean weekday, boolean vacation) {
}

CodingBat - Warmup1 - delDel

Write code and JUnit test cases for CodingBat - Warmup1 - delDel

Problem Statement:

Given a string, if the string "del" appears starting at index 1, return a string where that "del" has been deleted. Otherwise, return the string unchanged.

delDel("adelbc") → "abc"
delDel("adelHello") → "aHello"
delDel("adedbc") → "adedbc"

Expected method declaration

public String delDel(String str) {
}

CodingBat - Warmup2 - stringMatch

Write code and JUnit test cases for CodingBat - Warmup2 - stringMatch

Problem Statement:

Given 2 strings, a and b, return the number of the positions where they contain the same length 2 substring. So "xxcaazz" and "xxbaaz" yields 3, since the "xx", "aa", and "az" substrings appear in the same place in both strings.

stringMatch("xxcaazz", "xxbaaz") → 3
stringMatch("abc", "abc") → 2
stringMatch("abc", "axc") → 0

Expected method declaration

public int stringMatch(String a, String b) {
}

CodingBat - Warmup1 - notString

Write code and JUnit test cases for CodingBat - Warmup1 - notString

Problem Statement:

Given a string, return a new string where "not " has been added to the front. However, if the string already begins with "not", return the string unchanged. Note: use .equals() to compare 2 strings.

notString("candy") → "not candy"
notString("x") → "not x"
notString("not bad") → "not bad"

Expected method declaration

public String notString(String str) {
}

CodingBat - Warmup1 - front3

Write code and JUnit test cases for CodingBat - Warmup1 - front3

Problem Statement:

The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return true if we sleep in.

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

public boolean sleepIn(boolean weekday, boolean vacation) {
}

CodingBat - Warmup1 - icyHot

Write code and JUnit test cases for CodingBat - Warmup1 - icyHot

Problem Statement:

Given two temperatures, return true if one is less than 0 and the other is greater than 100.

icyHot(120, -1) → true
icyHot(-1, 120) → true
icyHot(2, 120) → false

Expected method declaration

public boolean icyHot(int temp1, int temp2) {
}

CodingBat - Warmup1 - close10

Write code and JUnit test cases for CodingBat - Warmup1 - close10

Problem Statement:

Given 2 int values, return whichever value is nearest to the value 10, or return 0 in the event of a tie. Note that Math.abs(n) returns the absolute value of a number.

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

public int close10(int a, int b) {
}

CodingBat - Warmup1 - monkeyTrouble

Write code and JUnit test cases for CodingBat - Warmup1 - monkeyTrouble

Problem Statement:

We have two monkeys, a and b, and the parameters aSmile and bSmile indicate if each is smiling. We are in trouble if they are both smiling or if neither of them is smiling. Return true if we are in trouble.

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

public boolean monkeyTrouble(boolean aSmile, boolean bSmile) {
}

CodingBat - Warmup1 - front22

Write code and JUnit test cases for CodingBat - Warmup1 - front22

Problem Statement:

The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return true if we sleep in.

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

public boolean sleepIn(boolean weekday, boolean vacation) {
}

CodingBat - Warmup1 - loneTeen

Write code and JUnit test cases for CodingBat - Warmup1 - loneTeen

Problem Statement:

We'll say that a number is "teen" if it is in the range 13..19 inclusive. Given 2 int values, return true if one or the other is teen, but not both.

loneTeen(13, 99) → true
loneTeen(21, 19) → true
loneTeen(13, 13) → false

Expected method declaration

public boolean loneTeen(int a, int b) {
}

CodingBat - Warmup2 - countXX

Write code and JUnit test cases for CodingBat - Warmup2 - countXX

Problem Statement:

Count the number of "xx" in the given string. We'll say that overlapping is allowed, so "xxx" contains 2 "xx".

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

public String everyNth(String str, int n) {
}

CodingBat - Warmup1 - posNeg

Write code and JUnit test cases for CodingBat - Warmup1 - posNeg

Problem Statement:

Given 2 int values, return true if one is negative and one is positive. Except if the parameter "negative" is true, then return true only if both are negative.

posNeg(1, -1, false) → true
posNeg(-1, 1, false) → true
posNeg(-4, -5, true) → true

Expected method declaration

public boolean posNeg(int a, int b, boolean negative) {
}

CodingBat - Warmup1 - backAround

Write code and JUnit test cases for CodingBat - Warmup1 - backAround

Problem Statement:

Given a string, take the last char and return a new string with the last char added at the front and back, so "cat" yields "tcatt". The original string will be length 1 or more.

backAround("cat") → "tcatt"
backAround("Hello") → "oHelloo"
backAround("a") → "aaa"

Expected method declaration

public String backAround(String str) {
}

CodingBat - Warmup1 - missingChar

Write code and JUnit test cases for CodingBat - Warmup1 - missingChar

Problem Statement:

Given a non-empty string and an int n, return a new string where the char at index n has been removed. The value of n will be a valid index of a char in the original string (i.e. n will be in the range 0..str.length()-1 inclusive).

missingChar("kitten", 1) → "ktten"
missingChar("kitten", 0) → "itten"
missingChar("kitten", 4) → "kittn"

Expected method declaration

public String missingChar(String str, int n) {
}

CodingBat - Warmup1 - hasTeen

Write code and JUnit test cases for CodingBat - Warmup1 - hasTeen

Problem Statement:

We'll say that a number is "teen" if it is in the range 13..19 inclusive. Given 3 int values, return true if 1 or more of them are teen.

hasTeen(13, 20, 10) → true
hasTeen(20, 19, 10) → true
hasTeen(20, 10, 13) → true

Expected method declaration

public boolean hasTeen(int a, int b, int c) {
}

CodingBat - Warmup1 - intMax

Write code and JUnit test cases for CodingBat - Warmup1 - intMax

Problem Statement:

Given three int values, a b c, return the largest.

intMax(1, 2, 3) → 3
intMax(1, 3, 2) → 3
intMax(3, 2, 1) → 3

Expected method declaration

public int intMax(int a, int b, int c) {
}

CodingBat - Warmup1 - in3050

Write code and JUnit test cases for CodingBat - Warmup1 - in3050

Problem Statement:

Given 2 int values, return true if they are both in the range 30..40 inclusive, or they are both in the range 40..50 inclusive.

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

public boolean in3050(int a, int b) {
}

CodingBat - Warmup1 - lastDigit

Write code and JUnit test cases for CodingBat - Warmup1 - lastDigit

Problem Statement:

Given two non-negative int values, return true if they have the same last digit, such as with 27 and 57. Note that the % "mod" operator computes remainders, so 17 % 10 is 7.

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

public boolean sleepIn(boolean weekday, boolean vacation) {
}

CodingBat - Warmup1 - max1020

Write code and JUnit test cases for CodingBat - Warmup1 - max1020

Problem Statement:

Given 2 positive int values, return the larger value that is in the range 10..20 inclusive, or return 0 if neither is in that range.

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

public int max1020(int a, int b) {
}

CodingBat - Warmup2 - arrayFront9

Write code and JUnit test cases for CodingBat - Warmup2 - arrayFront9

Problem Statement:

Given an array of ints, return true if one of the first 4 elements in the array is a 9. The array length may be less than 4.


arrayFront9([1, 2, 9, 3, 4]) → true
arrayFront9([1, 2, 3, 4, 9]) → false
arrayFront9([1, 2, 3, 4, 5]) → false

Expected method declaration

public String everyNth(String str, int n) {
}

CodingBat - Warmup1 - mixStart

Write code and JUnit test cases for CodingBat - Warmup1 - mixStart

Problem Statement:

Return true if the given string begins with "mix", except the 'm' can be anything, so "pix", "9ix" .. all count.

mixStart("mix snacks") → true
mixStart("pix snacks") → true
mixStart("piz snacks") → false

Expected method declaration

public boolean mixStart(String str) {
}

CodingBat - Warmup2 - arrayCount9

Write code and JUnit test cases for CodingBat - Warmup2 - arrayCount9

Problem Statement:

Given an array of ints, return the number of 9's in the array.

arrayCount9([1, 2, 9]) → 1
arrayCount9([1, 9, 9]) → 2
arrayCount9([1, 9, 9, 3, 9]) → 3

Expected method declaration

public int arrayCount9(int[] nums) {
}

CodingBat - Warmup2 - array123

Write code and JUnit test cases for CodingBat - Warmup2 - array123

Problem Statement:

Given an array of ints, return true if the sequence of numbers 1, 2, 3 appears in the array somewhere.

array123([1, 1, 2, 3, 1]) → true
array123([1, 1, 2, 4, 1]) → false
array123([1, 1, 2, 1, 2, 3]) → true

Expected method declaration

public boolean array123(int[] nums) {
}

CodingBat - Warmup2 - doubleX

Write code and JUnit test cases for CodingBat - Warmup2 - doubleX

Problem Statement:

Given a string, return true if the first instance of "x" in the string is immediately followed by another "x".

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

boolean doubleX(String str) {
}

CodingBat - Warmup2 - stringX

Write code and JUnit test cases for CodingBat - Warmup2 - stringX

Problem Statement:

The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return true if we sleep in.

stringX("xxHxix") → "xHix"
stringX("abxxxcd") → "abcd"
stringX("xabxxxcdx") → "xabcdx"

Expected method declaration

public String stringX(String str) {
}

CodingBat - Warmup2 - last2

Write code and JUnit test cases for CodingBat - Warmup2 - last2

Problem Statement:

Given a string, return the count of the number of times that a substring length 2 appears in the string and also as the last 2 chars of the string, so "hixxxhi" yields 1 (we won't count the end substring).

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

public int last2(String str) {
}

CodingBat - Warmup1 - nearHundred

Write code and JUnit test cases for CodingBat - Warmup1 - nearHundred

Problem Statement:

The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return true if we sleep in.

nearHundred(93) → true
nearHundred(90) → true
nearHundred(89) → false

Expected method declaration

public boolean sleepIn(boolean weekday, boolean vacation) {
}

CodingBat - Warmup1

Tasklist

### Tasks
- [x] https://github.com/divinedragon/code-challenges-java/issues/12
- [x] https://github.com/divinedragon/code-challenges-java/issues/13
- [x] https://github.com/divinedragon/code-challenges-java/issues/14
- [x] https://github.com/divinedragon/code-challenges-java/issues/15
- [x] https://github.com/divinedragon/code-challenges-java/issues/16
- [x] https://github.com/divinedragon/code-challenges-java/issues/17
- [x] https://github.com/divinedragon/code-challenges-java/issues/18
- [x] https://github.com/divinedragon/code-challenges-java/issues/19
- [x] https://github.com/divinedragon/code-challenges-java/issues/20
- [x] https://github.com/divinedragon/code-challenges-java/issues/21
- [x] https://github.com/divinedragon/code-challenges-java/issues/22
- [x] https://github.com/divinedragon/code-challenges-java/issues/23
- [x] https://github.com/divinedragon/code-challenges-java/issues/24
- [x] https://github.com/divinedragon/code-challenges-java/issues/25
- [x] https://github.com/divinedragon/code-challenges-java/issues/26
- [x] https://github.com/divinedragon/code-challenges-java/issues/27
- [x] https://github.com/divinedragon/code-challenges-java/issues/28
- [x] https://github.com/divinedragon/code-challenges-java/issues/29
- [x] https://github.com/divinedragon/code-challenges-java/issues/30
- [x] https://github.com/divinedragon/code-challenges-java/issues/31
- [x] https://github.com/divinedragon/code-challenges-java/issues/32
- [x] https://github.com/divinedragon/code-challenges-java/issues/33
- [x] https://github.com/divinedragon/code-challenges-java/issues/34
- [x] https://github.com/divinedragon/code-challenges-java/issues/35
- [x] https://github.com/divinedragon/code-challenges-java/issues/36
- [x] https://github.com/divinedragon/code-challenges-java/issues/37
- [x] https://github.com/divinedragon/code-challenges-java/issues/38
- [x] https://github.com/divinedragon/code-challenges-java/issues/39
- [x] https://github.com/divinedragon/code-challenges-java/issues/40
- [x] https://github.com/divinedragon/code-challenges-java/issues/41
- [x] https://github.com/divinedragon/code-challenges-java/issues/42

Issues in the Epic

CodingBat - Warmup1 - diff21

Write code and JUnit test cases for CodingBat - Warmup1 - diff21

Problem Statement:

Given an int n, return the absolute difference between n and 21, except return double the absolute difference if n is over 21.

diff21(19) → 2
diff21(10) → 11
diff21(21) → 0

Expected method declaration

public int diff21(int n) {
}

CodingBat - Warmup2 - stringTimes

Write code and JUnit test cases for CodingBat - Warmup2 - stringTimes

Problem Statement:

Given a string and a non-negative int n, return a larger string that is n copies of the original string.

stringTimes("Hi", 2) → "HiHi"
stringTimes("Hi", 3) → "HiHiHi"
stringTimes("Hi", 1) → "Hi"

Expected method declaration

public String stringTimes(String str, int n) {
}

CodingBat - Warmup2 - altPairs

Write code and JUnit test cases for CodingBat - Warmup2 - altPairs

Problem Statement:

Given a string, return a string made of the chars at indexes 0,1, 4,5, 8,9 ... so "kittens" yields "kien".

sleepIn(false, false) → true
sleepIn(true, false) → false
sleepIn(false, true) → true

Expected method declaration

public String altPairs(String str) {
}

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.