Pro/gramming Challenge

RULES:

Pick a challenge between 0-99, and do it as quickly as possible and make your code as small and efficient as you can in the language of your choosing. Post code when you're done
Have fun!

Other urls found in this thread:

pastebin.com/raw/BUT7mz5G
subnet-calculator.com/
twitter.com/SFWRedditGifs

This is neo Sup Forums. Nothing but video cards and Apple vs. Microsoft threads on Sup Forums these days. I miss the old Sup Forums.

I have a short memory, please remind me what old Sup Forums was about

guro

Posting my text-to-morse code from last time


#include
#include
#include
#include
//#include

std::string charsToMorse(std::string inputString, char characterArray[26], std::string morseArray[26]);
std::string morseToChars(std::string inputString, char characterArray[26], std::string morseArray[26]);

int main(int argc, const char * argv[]) {
std::ifstream lettersToMorse("/Users/ricardoiglesias/Desktop/Programming/MorseCode/LettersToMorse.txt");

char characterArray[26];
std::string morseArray[26]; //Two parallel arrays. ie... If a letter is found at the n'th index,
//return the morse code at the n'th index
for(int i = 0; i < 26; i++)
{
lettersToMorse >> characterArray[i] >> morseArray[i]; //actually puts in information into the parallel arrays
}

std::cout

rolling for trips

Quick fizzbuzz in c++

#include
#include

using namespace std;

int main() {

for (int i = 1; i

Come one..., don't keep us waiting

Why u do dis to an EE
Easy one get pls

Not going to do it anyway

but but im first year cs student dont know advanced shit like this just some basic c++

wait nvm some are easy af palindrome checker reverse number and other shit I can do

Rell

55 Sierpinski
triangles :: [[Bool]]
triangles = [True] : map next triangles where
next [] = [True]
next [x] = [x, True]
next (x:y:ys) = (x || y) : next (y:ys)

sierpinski n = zipWith (++) (spaces n) $ map printBools $ take n next where
spaces 1 = [[]]
spaces n = replicate (n - 1) ' ' : spaces (n - 1)
printBools = map printBool
printBool True = '*'
printBool False = ' '

rolling

roll

looks like absolute dogshit m8ey

just fuck me up senpai

rollan

rolling desu senpai

ROll

Sure

Pretty sure you don't need math.h to use the modulus operator.

Morse converter with quick Tkinter interface

pastebin.com/raw/BUT7mz5G

Huh, guess you're right, still teaching myself, and just learned to use the modulus operator after just now finding out about it

Roll

rollan

Claiming the problem 85.

Dear Princess Celestia: Fibonacci Numbers!

Today I learned something advanced.
I said “0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914296, 433494437, 701408733, 1134903170, 1836311903, 2971215073, 4807526976, 7778742049, 12586269025, 20365011074, 32951280099, 53316291173, 86267571272, 139583862445, 225851433717, 365435296162, 591286729879, 956722026041, 1548008755920, 2504730781961, 4052739537881, 6557470319842, 10610209857723, 17167680177565, 27777890035288, 44945570212853, 72723460248141, 117669030460994, 190392490709135, 308061521170129
498454011879264, 806515533049393, 1304969544928657, 2111485077978050, 3416454622906707, 5527939700884757, 8944394323791464, 14472334024676221, 23416728348467685, 37889062373143906, 61305790721611591, 99194853094755497, 160500643816367088, 259695496911122585, 420196140727489673, 679891637638612258, 1100087778366101931, 1779979416004714189, 2880067194370816120, 4660046610375530309, 7540113804746346429, 12200160415121876738, 19740274219868223167, 31940434634990099905, 51680708854858323072, 83621143489848422977, 135301852344706746049, 218922995834555169026”.
That's all about something advanced.

Your faithful student, Twilight Sparkle.

This might be just what I need

What options are there other than pool?

I don't know, senpai.

Posting the Ulam Spiral Code I made in Processing (I have less than zero idea how to do graphics in C++)

//ULAM

void setup()
{
size(1200, 1200);
background(#28616a);
translate(width/2, height/2);
int turnArray [] = {1, 2, 3, 5};
String turningDeliniation[] = {"RIGHT", "UP", "LEFT", "DOWN"};

int xCoord = 0, yCoord = 0, squareRad = 3;
color primeColor = color(#ce2840);
color squareColor = color(#51c7da);

int MAX = (height/squareRad)*(height/squareRad);
boolean isAPrime[] = sieve(MAX);
isAPrime[0] = true;
isAPrime[1] = true;

int k = 0, kCounter = 0, arrayChange = 0;

rectMode(CENTER);
noStroke();

for (int i = 1; i < MAX; i++)
{
if (i == turnArray[kCounter])
{
if (kCounter == 0 && k == 0)
{
arrayChange += 6;
} else
{
arrayChange += 2;
}
turnArray[kCounter] += arrayChange;
kCounter++;
}

if (kCounter == 4)
{
k++;
kCounter = 0;
println();
}
switch(kCounter)
{
case 0: //TURN RIGHT
xCoord += squareRad;
break;
case 1: // TURN UP
yCoord -= squareRad;
break;
case 2: //TURN LEFT
xCoord -= squareRad;
break;
case 3: //LIFT IT DOWN!
yCoord += squareRad;
break;
}

if (!isAPrime[i])
{
fill(primeColor);
} else
{
fill(squareColor);
}
rect(xCoord, yCoord, squareRad, squareRad);
fill(0);

println("AT " +i+ "TURN " +turningDeliniation[kCounter]);
}
}
boolean [] sieve(int MAX)
{
boolean outputArray [] = new boolean[MAX];
for (int i = 2; i < sqrt(MAX); i++)
{
if (outputArray[i] == false)
{
for (int j = i*i; j < MAX; j+=i)
{
outputArray[j] = true;
}
}
}
return outputArray;
}

Fuck you Sup Forums I need to start with programming soon

Having trouble using sockets to get information from online and implement them into a program... Any tips or places where I can learn to use sockets?

Mkay

...

Roll get

No.

Honestly, I would just implement Google's Search API to do the conversion and output the result.

rll

Reversing a number mathematically (presumably without conversion to a string) in Algol 68:

PROC reverse = (INT x) INT: BEGIN
INT n := x;

INT r := 0;

WHILE n /= 0 DO
r := r * 10 + (n %* 10);

n := n % 10
OD;

r
END;

roll let's hope I don't get something retarded this thread that I cbf doing

rollin'
should post my embarrassing hangman program. The preprocessor directives alone...

Lua is bae

local file = io.open(arg[1], "r")

local text = file:read("*a")

file:close()

local dict = {}

for word in text:gmatch("%a+") do
local lowercase = word:lower()
dict[lowercase] = (dict[lowercase] or 0) + 1
end

for word, count in pairs(dict) do
print(word, count)
end

what is this shit?

>fizzbuzz
>easy

Its not like we all work at google here.

Something not stupid hard pls

Guess it's time to duel fucktards. Yugioh the king of games

Challenge me Sup Forums

R8 my code

import requests
import json

api = "api.fixer.io/latest?"
source ="base="
source_input = input('Enter source: \n')
source_input = source_input.upper()
source += source_input

currencies = "&symbols="
currencies_input = input('Enter currency: \n')
currencies_input = currencies_input.upper()
currencies += currencies_input

r = requests.get(api + source + currencies)

json_file = r.json()
print("1 "+source_input+" = "+str(json_file['rates'][currencies_input])+" "+currencies_input)

70:

function reverse(x::Int)
while (x!=0)
print(x%10)
x = x÷10
end
end

Roll

roll desu

Roll

rolling

7 sounds really cool to me, has anyone ever done it or a similar project? Any pointers you can give?

im trying to make the pascal triangle
should I store all the values on a list or calculate them recursively?

Rell

I did Pascal's Triangle using a two-dimensional array

roller

k den

What is 06 tornado (g's specialty)

I don't understand the last phrase of 00 challenge, specifically, this part : "and first/last adresses ?"

rolling.

Like this subnet-calculator.com/

Thank you ! I get it. So we need to show the first and last address of the given ip/mask.

Thanks mate

You find fuzz buzz difficult?

Roll it, smoke it, pass it to a friend

Designated roll

>Split a string into tokens delimited by one or more separators
wut is meant by tokens here? Individual words?

I think (keyword "think") that it's just removing spaces in a String and inserting them where there's a specified token.

Sort of like this:
"THE QUI||CK BRO||WN FOX JUMPE||D"
would be
"THEQUI CKBRO WNFOXJUMPE D"

rol

Nice code ricardo

roll the grass

Beautiful

aaaaaa
roll

...

can I do this in JS

void Main(string[] args)
{
decimal num = 1;

while(true)
{
TryConjecture(num++);
Thread.Sleep(500);
}
}

static void TryConjecture(decimal val)
{
Console.Write(val);

int steps = 0;

while(val > 1)
{
if(val % 2 == 0)
{
val /= 2;
Console.Write(" / 2 = {0}", val);
}
else
{
val = (3 * val) + 1;
Console.Write(" * 3 + 1 = {0}", val);
}
steps++;
}
Console.WriteLine("Took {0} steps.", steps);
}

another one

Of course.
You can do everything is JS.

rolling

Wait a minute i can't do this
I don't know how to program

Röllinsgen

llor

I'm not mexican. Nothing wrong with mexicans, except the border.

no I don't like that
another one

Shortest i could think of, but no graphics
#include
#include
int main()
{
std::cout

Another date program? Fine...
#include
#include
int GetDate()
{
int months[] = {31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
int month, day, result;
std::cout

roll

le roll amirite

Roll. Currently learning python, I hope my current knowledge is sufficient for the challenge. Will try to make it with an emphasis on readability and conciseness.

VB is just too superior.

Imports System.Drawing

Module Module1
Private ReadOnly SourceImagePath = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\\image.png"
Private ReadOnly DestImagePath = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\\image2.png"

Sub Main()
Dim sourceImage = Image.FromFile(SourceImagePath)
Dim randomInt = New Random().Next([Enum].GetValues(GetType(RotateFlipType)).Cast(Of Integer).Last + 1)
sourceImage.RotateFlip(CType(randomInt, RotateFlipType))
sourceImage.Save(DestImagePath)
End Sub
End Module

function fuckMeUpInside() {
this.head.insert(train);
}

r0llando

lmfao that's what i've been working on for the past hour or so in my personal project

so roll again i guess

rolling.
please give me an easy one.

Well I got what I asked for.
iex(5)> (fn(x) -> x * (x + 1) / 2 end).(5)
15.0

Some variation :)
#include
#include
#include
#include
void Analyze(char fname[])
{
double total = 0, one = 0, two = 0, three = 0;
std::string line;
std::ifstream data (fname);
if (data.is_open())
{
while (getline(data, line))
{
++total;
if (line[0] == '1') ++one;
if (line[0] == '2') ++two;
if (line[0] == '3') ++three;
}
data.close();
}
std::cout

already done that the other day. reroll

no me gusta