Created
February 10, 2015 22:39
-
-
Save Craigson/22e0cd9097528cc47ff2 to your computer and use it in GitHub Desktop.
Code snippet for HackerSchool application - Written in Processing
This file contains hidden or 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
| /* | |
| Written by Craig Pickard for HackerSchool Application for Summer Batch 1, 2015 | |
| Language: Processing | |
| This code prints out integers 1-100 (inclusive), replacing every integer value that's divisible by 3 with the string "Crackle", | |
| every integer that's divisible by 5 with the word "Pop", and every integer that's divisible by both 3 and 5 with | |
| the string "CracklePop". | |
| */ | |
| void setup() { | |
| ArrayList list = new ArrayList(); | |
| int size = 100; | |
| for (int i = 1; i < size+1; i++) { | |
| if (i % 3 == 0 && i % 5 == 0) { | |
| list.add("CracklePop"); | |
| } else if (i % 3 == 0) { | |
| list.add("Crackle"); | |
| } else if (i % 5 == 0) { | |
| list.add("Pop"); | |
| } else { | |
| list.add(i); | |
| } | |
| } | |
| for (int i = 0; i < size; i++) { | |
| println(list.get(i)); | |
| } | |
| } | |
| void draw(){ | |
| exit(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment