5K
Solutions
6K
Contributors
Game programming is the software development of video games. Game programming requires substantial skill in software engineering as well as specialization in simulation, computer graphics, artificial intelligence, physics, audio programming, and input. Like other software, game development programs are generated from source code to the actual program by a compiler. Source code can be developed with almost any text editor, but most professional game programmers use a full integrated development environment (IDE).
Sign up to Post
Load Recent Content
using System;
using System.Threading;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace FaceNameGame
{
public partial class LevelOnePartTwo : Form
{
int point = 0, buttoncount = 0, i=0, h=3, hbuttoncount=0;
public LevelOnePartTwo()
{
InitializeComponent();
}
private void LevelOnePartTwo_Load(object sender, EventArgs e)
{
string[] files = Directory.GetFiles(@"C:\Users\Marina\Desktop\FaceNameGame\images\Level1\used", "*.jpg", SearchOption.AllDirectories);
PhotoPicBx.Load(files[i]);
NameTxtBx.Focus();
Pointlbl.Text = point.ToString();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void PhotoPicBx_Click(object sender, EventArgs e)
{
}
private void TemplatePicBx_Click(object sender, EventArgs e)
{
}
private void
…
Given a non-negative int n, compute recursively (no loops) the count of the occurrences of 8 as a digit, except that an 8 with another 8 immediately to its left counts double, so 8818 yields 4. Note that mod (%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/) by 10 removes the rightmost digit (126 / 10 is 12).
count8(8) → 1
count8(818) → 2
count8(8818) → 4
Given a non-negative int n, return the count of the occurrences of 7 as a digit, so for example 717 yields 2. (no loops). Note that mod (%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/) by 10 removes the rightmost digit (126 / 10 is 12).
count7(717) → 2
count7(7) → 1
count7(123) → 0
Recursion-1 > triangle
prev | next | chance
We have triangle made of blocks. The topmost row has 1 block, the next row down has 2 blocks, the next row has 3 blocks, and so on. Compute recursively (no loops or multiplication) the total number of blocks in such a triangle with the given number of rows.
triangle(0) → 0
triangle(1) → 1
triangle(2) → 3
So even bunnies has 2 ears and odd ones have 3 ears and we have to return total ears?
Recursion-1 > bunnyEars2
prev | next | chance
We have bunnies standing in a line, numbered 1, 2, ... The odd bunnies (1, 3, ..) have the normal 2 ears. The even bunnies (2, 4, ..) we'll say have 3 ears, because they each have a raised foot. Recursively return the number of "ears" in the bunny line 1, 2, ... n (without loops or multiplication).
bunnyEars2(0) → 0
bunnyEars2(1) → 2
bunnyEars2(2) → 5
public int fibonacci(int n) {
if ((n == 0) || (n == 1)) // base cases
return n;
else
// recursion step
return fibonacci(n - 1) + fibonacci(n - 2);
}
Expected Run
fibonacci(0) → 0 0 OK
fibonacci(1) → 1 1 OK
fibonacci(2) → 1 1 OK
fibonacci(3) → 2 2 OK
fibonacci(4) → 3 3 OK
fibonacci(5) → 5 5 OK
fibonacci(6) → 8 8 OK
fibonacci(7) → 13 13 OK
other tests
OK
I am not clear on above desription. what it mean by computing recursively?
We have a number of bunnies and each bunny has two big floppy ears. We want to compute the total number of ears across all the bunnies recursively (without loops or multiplication).
bunnyEars(0) → 0
bunnyEars(1) → 2
bunnyEars(2) → 4
public int factorial(int n) {
return n * factorial(n-1);
}
Expected Run
factorial(1) → 1 Exception:java.lang.StackOverflowErr or (line number:2) X
factorial(2) → 2 Exception:java.lang.StackOverflowErr or (line number:2) X
factorial(3) → 6 Exception:java.lang.StackOverflowErr or (line number:2) X
factorial(4) → 24 Exception:java.lang.StackOverflowErr or (line number:2) X
factorial(5) → 120 Exception:java.lang.StackOverflowErr or (line number:2) X
factorial(6) → 720 Exception:java.lang.StackOverflowErr or (line number:2) X
factorial(7) → 5040 Exception:java.lang.StackOverflowErr or (line number:2) X
factorial(8) → 40320 Exception:java.lang.StackOverflowErr or (line number:2) X
factorial(12) → 479001600 Exception:java.lang.StackOverflowErr or (line number:2) X
other tests
X
package com.solution;
class ContinueDemo {
public static void main(String[] args) {
String searchMe = "peter piper picked a " + "peck of pickled peppers";
int max = searchMe.length();
int numPs = 0;
for (int i = 0; i < max; i++) {
// interested only in p's
if (searchMe.charAt(i) != 'p')
continue;
// process p's
numPs++;
}
System.out.println("Found " + numPs + " p's in the string.");
}
}
Found 9 p's in the string.package com.solution;
class ContinueDemo {
public static void main(String[] args) {
String searchMe = "peter piper picked a " + "peck of pickled peppers";
int max = searchMe.length();
int numPs = 0;
for (int i = 0; i < max; i++) {
// interested only in p's
if (searchMe.charAt(i) != 'p')
// continue;
// process p's
numPs++;
}
System.out.println("Found " + numPs + " p's in the string.");
}
}
peter piper picked a " + "peck of pickled peppers
public int[] copyEvens(int[] nums, int count) {
int[] arr=new int[count];
for(int i=0;i<nums.length-1;i++){
if(nums[i]%2==0){
arr[i]=nums[i];
}
}
return arr;
}
xpected Run
copyEvens([3, 2, 4, 5, 8], 2) → [2, 4] Exception:java.lang.ArrayIndexOutOfB oundsExcep tion: 2 (line number:5) X
copyEvens([3, 2, 4, 5, 8], 3) → [2, 4, 8] [0, 2, 4] X
copyEvens([6, 1, 2, 4, 5, 8], 3) → [6, 2, 4] Exception:java.lang.ArrayIndexOutOfB oundsExcep tion: 3 (line number:5) X
copyEvens([6, 1, 2, 4, 5, 8], 4) → [6, 2, 4, 8] [6, 0, 2, 4] X
copyEvens([3, 1, 4, 1, 5], 1) → [4] Exception:java.lang.ArrayIndexOutOfB oundsExcep tion: 2 (line number:5) X
copyEvens([2], 1) → [2] [0] X
copyEvens([6, 2, 4, 8], 2) → [6, 2] Exception:java.lang.ArrayIndexOutOfB oundsExcep tion: 2 (line number:5) X
copyEvens([6, 2, 4, 8], 3) → [6, 2, 4] [6, 2, 4] OK
copyEvens([6, 2, 4, 8], 4) → [6, 2, 4, 8] [6, 2, 4, 0] X
copyEvens([1, 8, 4], 1) → [8] Exception:java.lang.ArrayIndexOutOfB oundsExcep tion: 1 (line number:5) X
copyEvens([1, 8, 4], 2) → [8, 4] [0, 8] X
copyEvens([2, 8, 4], 2) → [2, 8] [2, 8] OK
other tests
X
Your progress graph for this problem
public boolean hasOne(int n) {
if(n%10==1){
// if(n/10==1){
return true;
// }
}
return false;
}
Expected Run
hasOne(10) → true false X
hasOne(22) → false false OK
hasOne(220) → false false OK
hasOne(212) → true false X
hasOne(1) → true true OK
hasOne(9) → false false OK
hasOne(211112) → true false X
hasOne(121121) → true true OK
hasOne(222222) → false false OK
hasOne(56156) → true false X
hasOne(56556) → false false OK
other tests
X
public int scoresAverage(int[] scores) {
int result=0;
int len=scores.length;
int lenHalf=len/2;
int sumEven=0;
int sumOdd=0;
for(int i=0;i<lenHalf;i++){
sumEven=(scores[i]+scores[i+1])/2;
//result=sumeEven;
//return result;
}
for(int i=lenHalf;i<len;i++){
sumOdd=(scores[i]+scores[i+1])/2;
// result=sumeOdd;
//return result;
}
if(sumOdd>sumEven){
return sumOdd;
}
else{
return sumEven;
}
}
return result;
}
}
Expected Run
scoresClump([3, 4, 5]) → true false X
scoresClump([3, 4, 6]) → false false OK
scoresClump([1, 3, 5, 5]) → true false X
scoresClump([2, 4, 5, 6]) → true false X
scoresClump([2, 4, 5, 7]) → false false OK
scoresClump([2, 4, 4, 7]) → true false X
scoresClump([3, 3, 6, 7, 9]) → false false OK
scoresClump([3, 3, 7, 7, 9]) → true false X
scoresClump([4, 5, 8]) → false false OK
other tests
X
Your progress graph for this problem
public boolean scores100(int[] scores) {
boolean result=true;
int len=scores.length;
for(int i=0;i<len-1;i++){
if(scores[i]!=100&&scores[i+1]!=100){
// i=i+1;
result=false;
return result;
}
}
return result;
}
Expected Run
scores100([1, 100, 100]) → true true OK
scores100([1, 100, 99, 100]) → false true X
scores100([100, 1, 100, 100]) → true true OK
scores100([100, 1, 100, 1]) → false true X
scores100([1, 2, 3, 4, 5]) → false false OK
scores100([1, 2, 100, 4, 5]) → false false OK
other tests
OK
5K
Solutions
6K
Contributors
Game programming is the software development of video games. Game programming requires substantial skill in software engineering as well as specialization in simulation, computer graphics, artificial intelligence, physics, audio programming, and input. Like other software, game development programs are generated from source code to the actual program by a compiler. Source code can be developed with almost any text editor, but most professional game programmers use a full integrated development environment (IDE).