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
<?php | |
$red = 100; | |
$blue = 150; | |
$green = 200; | |
$my_img = imagecreate( 1000, 1000 ); | |
$background = imagecolorallocate( $my_img, $red, $green, $blue ); | |
header( "Content-type: image/png" ); | |
imagepng( $my_img ); | |
imagecolordeallocate( $my_img, $background ); | |
imagedestroy( $my_img ); |
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
public static int arraySum( int[] arr ) { | |
int s = 0; | |
for (int n: arr) | |
s += n; | |
return s; | |
} | |
public static int arraySum( int[] arr ) { | |
int s = 0; | |
for (int i=; i<arr.length; i++) { |
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
public void test_MeetAtMidnight() throws Exception { | |
RouteCipher rc = new RouteCipher( 3, 5 ); | |
setField( rc, "numRows", 3 ); | |
setField( rc, "numCols", 5 ); | |
Method m = RouteCipher.class.getDeclaredMethod( "fillBlock", new Class[]{ String.class } ); | |
m.setAccessible( true ); | |
// This is the problem line | |
m.invoke( rc, "Meet at midnight" ); |
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
public LogMessage( String message ) { | |
int pos = message.indexOf(":"); | |
machineId = message.substring(0, pos); | |
description = message.substring(pos + 1); | |
} |
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
public static int leftoverSpaces( List<String> wordList, int formattedLen ) { | |
/* Implementation not shown */ | |
return formattedLen - totalLetters( wordList ) - ( basicGapWidth( wordList, formattedLen ) * wordList.size() - 1 ); | |
} |
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
public class Crossword { | |
private Square[][] puzzle; | |
private boolean toBeLabeled( int r, int c, boolean[][] blackSquares ) { | |
return (!(blackSquares[r][c]) && | |
( r == 0 || c == 0 || blackSquares[r-1][c] || blackSquares[r][c-1] ); | |
} | |
public Crossword(boolean[][] blackSquares) { |
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
String[] wordArray = {"wheels", "on", "the", "bus"}; | |
RandomStringChooser sChooser = new RandomStringChooser(wordArray); | |
for (int k = 0; k < 6; k++) { | |
System.out.print(sChooser.getNext() + " "); | |
} | |
// Possible output | |
// bus the wheels on NONE NONE |
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
public class MultPractice implements StudyPractice { | |
private int numOne; | |
private int numTwo; | |
public MultPractice(int a, int b) { | |
numOne = a; | |
numTwo = b; | |
} | |
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
public Digits( int num ) { | |
digitList = new ArrayList<>(); | |
int n = num; | |
do { | |
digitList.add(0, n % 10); | |
n /= 10; | |
} while (n > 0); | |
} |
NewerOlder