Showing posts with label problem solving. Show all posts
Showing posts with label problem solving. Show all posts

Saturday, February 14, 2015

[PHP] Jack n' Poy

Problem: Create a Jack n' Poy game.

Input:
scissor-paper
paper-rock
scissor-rock
paper-paper
rock-rock

Output:
player one wins
player one wins
player two wins
draw
draw

[PHP] Triangle Asterisk

Problem: Let the user enter a number then use that number to determine the size of the triangle.

Input:
5

Output:
    *
   ***
  *****
 *******
*********

Sunday, January 22, 2012

Nested Parentheses

Problem: Write a program to determine if a string consists of properly nested parentheses

Input:
()()
(()())
(()
())(
((()))

Output:
YES
YES
NO
NO
YES

Saturday, January 21, 2012

Modulus 11

Problem: create a program which will ask for an input number and determine whether it is a multiple of 11. Range: 1-100 digits (not one to one hundred, but 100 digits)

CLUE: use string for the input for even the long long int cannot hold a 100-digit number

Input:
132
1452
5431
23191344
537838436526336
1451999999998548
123454865432545321
33673831487966326168512

Output:
YES
YES
NO
YES
YES
YES
NO
YES

Count Without Loops

Problem: write a program to display number from 1-10 without using any looping statements (for, while, do) and only using one parameter.

Input:
10

Output:
1
2
3
4
5
6
7
8
9
10

Tuesday, April 19, 2011

Multiplication Table in Drought Season

The challenge is to add code statements in a given function named “renderMultiplicationTable” which has a single parameter “$dimension” and create a Multiplication Table without the use of any looping statements (e.g. for, while, do…while, and foreach).

Sample Code:


Sample Output:

Like-A-Text-Twist Game

This is similar to a text-twist game. Given a string, create a program that will generate the matches found on the DictionaryWords.txt file

Example:

String: abacas

Matches:

1. aba
2. abaca
3. aa
4. ab
5. abacas
etc..


download DictionaryWords.txt here
Related Posts Plugin for WordPress, Blogger...