Codex NG
Recurrent Flamer
- Joined
- Jul 24, 2015
- Messages
- 2,994
- Solutions
- 12
- Reaction score
- 1,659
I was surfing the web looking for a reputable school to get credentials for programming and came across this.
https://www.recurse.com
They have an application you fill out tell them about yourself, links to your work etc..
Then there was this general programming test
Any language? Nice!!.. So I cracked my knuckles and got to work.. to my surprise I am very rusty in quite a few languages but I thought I'd give it a shot, besides it was a lot fun
PHP
Lua
C++
Java
HTML / Javascript
Maybe you all would like to give it a shot and see if you can minimize the code or write your own in your language of choice of course
https://www.recurse.com
They have an application you fill out tell them about yourself, links to your work etc..
Then there was this general programming test
Code:
Code CracklePop
Write a program that prints out the numbers 1 to 100 (inclusive).
If the number is divisible by 3, print Crackle instead of the number.
If it's divisible by 5, print Pop.
If it's divisible by both 3 and 5, print CracklePop.
You can use any language.
Any language? Nice!!.. So I cracked my knuckles and got to work.. to my surprise I am very rusty in quite a few languages but I thought I'd give it a shot, besides it was a lot fun
PHP
Code:
<?php
$str = [
['word' => 'Crackle', 'value' => 3],
['word' => 'Pop', 'value' => 5]
];
function cracklePop($a, $b, $str){
for(; $a < $b; $a++){
if($a % $str[0]['value'] == 0 && $a % $str[1]['value'] == 0){
echo $str[0]['word'].$str[1]['word']."\n";
}elseif($a % $str[0]['value'] == 0){
echo $str[0]['word']."\n";
}elseif($a % $str[1]['value'] == 0){
echo $str[1]['word']."\n";
}else{
echo $a."\n";
}
}
}
cracklePop(1, 100, $str);
?>
Lua
Code:
local str = {
{ word = 'Crackle', value = 3 },
{ word = 'Pop', value = 5}
}
function cracklePop(a, b, str, c)
for n = a, b, (c and c or 1) do
if n % str[1].value == 0 and n % str[2].value == 0 then
print(str[1].word..str[2].word)
elseif n % str[1].value == 0 then
print(str[1].word)
elseif n % str[2].value == 0 then
print(str[2].word)
else
print(n)
end
end
end
cracklePop(1, 100, str)
C++
Code:
#include <iostream>
using namespace std;
void cracklePop(int a, int b, int v[], string str[]){
for(; a <= b; a++){
if((a % v[0]) == 0 && (a % v[1] == 0)){
cout << str[0] << str[1] << endl;
}else if(a % v[0] == 0){
cout << str[0] << endl;
}else if(a % v[1] == 0){
cout << str[1] << endl;
}else{
cout << a << endl;
}
}
}
int main()
{
string words[2] = {"Crackle", "Pop"};
int values[2] = {3, 5};
cracklePop(1, 100, values, words);
return 0;
}
Java
Code:
public class CP{
public static class CracklePop {
private Integer[] values = new Integer[2];
private String[] words = new String[2];
public CracklePop(Integer[] value, String[] word) {
for(int i = 0; i < value.length; i++){
this.values[i] = value[i];
this.words[i] = word[i];
}
}
public void printValues(int a, int b){
for(; a <= b; a++){
if(a % this.values[0] == 0 && a % this.values[1] == 0){
System.out.println(this.words[0] + this.words[1]);
}else if(a % this.values[0] == 0){
System.out.println(this.words[0]);
}else if(a % this.values[1] == 0){
System.out.println(this.words[1]);
}else{
System.out.println(a);
}
}
}
}
static String[] w = {"Crackle", "Pop"};
static Integer[] v = {3, 5};
static CracklePop cracklePop = new CracklePop(v, w);
public static void main(String []args){
cracklePop.printValues(1, 100);
}
}
HTML / Javascript
Code:
<!DOCTYPE html>
<html>
<head>
<title>Crackle Pop</title>
</head>
<body>
<p id="cracklePop"></p>
<script>
function CracklePop(a, b, three, five, c, p){
var t = ''
for(; a <= b; a++){
if(a % three === 0 && a % five === 0){
t += c + p + "<br />";
}else if(a % three === 0){
t += c + "<br />";
}else if(a % five === 0){
t += p + "<br />";
}else{
t += a + "<br />";
}
}
document.getElementById("cracklePop").innerHTML = t;
}
var a = 3, b = 5, w = "Crackle", v = "Pop";
CracklePop(1, 100, a, b, w, v);
</script>
</body>
</html>
Maybe you all would like to give it a shot and see if you can minimize the code or write your own in your language of choice of course