No.3529
>you roll it
>you code it
>you post it
Time to get fit. Any language you prefer. No re-rolls boys.
No.3530
>>3529
#include <iostream>
double calc_factorial(int n);
int main()
{
int n;
std::cout << "enter a number >= 0 to calculate factorial: \n";
std::cin >> n;
while(n < 0){
std::cin.clear();
std::cout << "enter a number >= 0 to calculate factorial: \n";
std::cin >> n;
}
std::cout << calc_factorial(n) << std::endl;
return 0;
}
double calc_factorial(int n)
{
if(n == 0){
return 1;
}else{
return n * calc_factorial(n - 1);
}
}
No.3531
No.3532
>>3531
>31
ah hell nah
On a sidenote, I hope someone gets 23. We need one for 8chan.
No.3548
I don't even know what some of the things actually refer to but let's see. Hopefully it's not too hard ;_;
No.3583
No.3584
>>3583
that one looks fun anon.
I need to write a list container today, but I will roll for a new exercise. Fully expect 84 on account of /g/ being slow.
No.3595
No.3596
No.3598
No.3600
No.3601
>>3600
<button onclick="namesFunction()">click</button>
<p id="output"></p>
<script>
document.write("<style>b{color:green}</style>");
function namesFunction() {
var x = document.getElementById("output");
var y = [
"<b>Bob</b> \
<br>Specialty: master fapper \
<br>Education: high school dropout",
"<b>Jil</b> \
<br>Specialty: huge cunt \
<br>Education: college paper",
"<b>Jak</b> \
<br>Specialty: can put large dildos into his anus \
<br>Education: middle school",
"Rob text text text...",
"Tom text text text...",
"Bil text text text...",
"Kim text text text...",
"Joe text text text...",
"Mel text text text...",
"Meg text text text..."
];
x.innerHTML = y[Math.floor(Math.random() * 10)];
}
</script>
No.3602
>>3601
Cool anon. I don't do web stuff but lately I've been picking up javascript for firefox extensions.
<button> is html tag and namesFunction() is the callback when clicked?
Here is my shitty paint program from >>3584
It's not yet fully implemented and has some errors (not a 1-to-1 correspondence between what is shown and what is saved, keeping track of all those points is slow eventually and isn't the best approach. Group paint isn't functional yet. Also, not the best OOP...)
http://pastebin.com/mcTWSZjZ
No.3623
>>3583
I'm back, /g/. I got it mostly working, pending some UI improvements and additional testing.
Eventually I plan to implement multiplayer over TCP and maybe also do a gui.
https://bitbucket.org/snickerbockers/battleship
No.3624
>>3623
Looking through it now, cool anon.
Also, I'm rollin' for a new exercise.
No.3628
No.3629
>>3628
>[object Object]
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
long current = 0;
long previous = 0;
int numCases;
printf("Enter number of test cases for the fibonacci sequence: ");
scanf("%d", &numCases);
long *numbers = (long*)malloc(sizeof(long)*numCases);
int i;
for(i = 0; i < numCases; i++){
if(i == 0)
numbers[i] = current;
if(i == 1){
numbers[i] = 1;
current = 1;
}
else{
numbers[i] = current + previous;
previous = current;
current = numbers[i];
}
printf("\n");
printf("%d", numbers[i]);
}
free(numbers);
}
No.3630
>>3629
>[object Object]
I just realized how much extraneous shit i put in there. Welp.
No.3635
>>3629
Rolling for another project.
No.3637
No.3639
No.3656
No.3669
No.3680
No.3682
No.3789
No.3800
No.3801
rerolling since i don't understand what a name generator does
No.3851
No.3857
No.3858
No.3859
No.3860
No.3861
No.3862
>>3861
gotta reroll, actually just did this earlier
No.3870
No.3871
>>3529
>No re-rolls
yeah, fuck 70 for right now.
No.3873
No.3877
No.3878
>>3877
I don't know what this means
No.3888
No.3889
>>3878
Brainfuck is an esoteric programming language.
An interpreter is a program which will take commands in a programming language and run them.
No.3890
File: 1449266512594.png (27.59 KB, 577x771, 577:771, a8708752493cdde2d512974fa7….png)

No.3891
>>3890
used pastebin for syntax coloring, after mailing it to myself from another pc.
Kinda goofy.
No.3922
No.3923
>>3922
I pass. This list is shit.
No.3954
No.3955
No.3959
No.3964
No.3976
No.3982
I know I didn't roll it, but I'm new to Java and this thread inspired me to write a program that counts the number of letters, words, and sentences in your input.
Tell me if I'm doing something dumb or unneeded in doing this
package countwordsinastring;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("(Type 'EXIT' to exit)");
System.out.println("Enter complete sentences:");
boolean stillRunning = true;
while(stillRunning){
Scanner input = new Scanner(System.in);
String userInput = input.nextLine();
if(!userInput.equals("EXIT")){
int sentences = 0 ;
int words = 1 ;
int letters = 0;
System.out.println();
int i = 0;
char[] inputArr = new char[userInput.length() + 2];
for (i = 0; i < userInput.length(); i++) {
inputArr[i] = userInput.charAt(i);
if(!Character.isLetter(inputArr[i])){
switch (inputArr[i]) {
case ' ':
words++;
break;
case '.':
sentences++;
break;
case '!':
sentences++;
break;
default:
}
}else{
letters++;
}
}
if (sentences == 0) {
sentences = 1;
} else if(sentences > 0 && inputArr[userInput.length() - 1] != '.'
&& inputArr[userInput.length() - 1] != '!') {
sentences++;
}
System.out.println("Number of letters: " + letters);
System.out.println("Number of words: " + words);
System.out.println("Number of sentences: " + sentences);
System.out.println();
}else{
stillRunning = false;
}
}
}
}
No.3983
>>3982
Focking shit
Ignore the fact that I initialize inputArr as having 2 more than userInput.length();
That was a mistake made in seeing if I could make it so that it doesn't add a sentence when it picks up on a "..." but that didn't work out so I removed it from the code
No.3984
>>3982
Sorry to put so much on this thread but reading this after I posted it made me notice some formatting issues that were bugging me.
Made it more readable.
package countwordsinastring;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("(Type 'EXIT' to exit)");
System.out.println("Enter complete sentences:");
boolean stillRunning = true;
while (stillRunning) {
Scanner input = new Scanner(System.in);
String userInput = input.nextLine();
if (!userInput.equals("EXIT")) {
int sentences = 0;
int words = 1;
int letters = 0;
int i = 0;
System.out.println();
char[] inputArr = new char[userInput.length()];
for (i = 0; i < userInput.length(); i++) {
inputArr[i] = userInput.charAt(i);
if (!Character.isLetter(inputArr[i])) {
switch (inputArr[i]) {
case ' ':
words++;
break;
case '.':
sentences++;
break;
case '!':
sentences++;
break;
default:
}
} else {
letters++;
}
}
if (sentences == 0) {
sentences = 1;
} else if (sentences > 0 &&
inputArr[userInput.length() - 1] != '.' &&
inputArr[userInput.length() - 1] != '!') {
sentences++;
}
System.out.println("Number of letters: " + letters);
System.out.println("Number of words: " + words);
System.out.println("Number of sentences: " + sentences);
System.out.println();
} else {
stillRunning = false;
}
}
}
}
No.3989
I'm gonna print this image out and use it as a means of inspiration for projects in Java and C++, seeing as I'm simultaneously learning those languages. I'll take these on (not necessarily in order) and learn whatever I don't know that I need to in order to complete them in my free time when I'm not learning by other means.
Wish me luck fam
No.3996
No.3997
No.4042
No.4043
No.4045
No.4049
im gonna have to do this in swift fuck me
No.4057
No.4070
>>4047
Nobody wins in TTT.
No.4087
No.4089
No.4091
No.4092
No.4094
No.4098
No.4100
No.4110
No.4120
No.4123
No.4124
>>4123
require 'json'
require 'open-uri'
if ARGV.length != 2
puts "[-] Usage: 8chan-dl <board> <threadnum>"
end
board = ARGV[0]
threadnum = ARGV[1].to_i
threadurl = "http://8ch.net/#{board}/res/#{threadnum}.json"
thread = JSON.parse(open(threadurl).read)
title = thread['posts'][0]['sub'].gsub /[ |\/]/, '_'
puts "[+] Thread title: #{title}"
dir = "./#{title}/".gsub ' ', '_'
Dir.mkdir dir if not Dir.exists? dir
for post in thread['posts'].select{|p| p.has_key? 'ext'}
filename = "#{post['tim']}#{post['ext']}"
img_url = "http://media.8ch.net/#{board}/src/#{filename}"
puts "[+] Downloading #{img_url}"
File.open("#{dir}#{filename}", 'wb') do |file|
file.write(open(img_url).read)
end
end
Not the best. Has no error handling and shit but it seems to work. Also wrote a 4chan one that is very similar if you guys want that.
No.4129
Yay, a rollotto that isn't a jizzfest!
No.4130
Roooooooolll in the dungeon
No.4131
No.4140
No.4144
No.4222
No.4223
>>4222
Rerolling for too easy
No.4224
No.4225
No.4232
No.4233
i cant program but ill roll anyway
No.4254
>tfw can't code for shit
>rolling anyway
Come on, FizzBuzz.
No.4260
>>3529
rolling for easy task-
No.4261
>>4260
what the hell is that ?
No.4333
No.4362
No.4376