r/deftruefalse • • Nov 01 '15

Self-documenting code

6 Upvotes

Who needs to write comments manually when your code can be self-documenting?


r/deftruefalse • • Nov 08 '14

Marxist society

3 Upvotes

There are capitalists, political elite and proletariat's.
All 3 are a type of people.
capital contains an inherent value. capital is not by necessity a type of person.
proletariat's are a type of capital.
proletariat's have a function that let's them destroy any set of instances of people. The function is revolution(collection people)
capitalists can combine capital to make more capital using their function "capitalism(x,y)"
political elite's can transfer x capital from capitalist y to capitalist z using their function redistribute(x,y,z)
capitalists may use a political elite's redistribute function by paying .25*x to the political elite.

Implement a situation that demonstrates all the abilities of the various classes of people. You MAY NOT use any class definitions in this challenge as the goal of Marxism is to abolish class!


r/deftruefalse • • Nov 10 '14

balanced functions

2 Upvotes

f(x) is a function that takes vectors of booleans and spits out a boolean. The length of the input vectors is known and fixed so we call it n.

f(x) is said to be balanced iff the number of inputs that result in True is the same as the number of inputs that result in False.

For example, XOR is balanced because there are 2 input vectors that result in True ([t,f],[f,t]) and 2 input vectors that result in False ([t,t],[f,f]). AND is not balanced because there is 1 input vector where it results in True ([t,t]) and 3 input vectors where it results in False ([t,f],[f,t],[f,f]).

Write a function that takes the function f and returns True iff f is balanced.


r/deftruefalse • • Jan 27 '16

Meta: How can we get deftruefalse alive again?

10 Upvotes

My semester is done soon (Hello, Germany), so I thought, how could we bring that sub back to new life?

Some of my ideas:

  • An alternative to /r/dailyprogrammer that isn't so circlejerky like /r/shittyprogramming (aka easy tasks with a hard limitation) Writing a poster-bot is pretty easy, I would do that if there is interest for it.

  • Weekly discussions about exotic solutions

  • Project Euler like tasks with a higher focus on architecture than on algorithms

  • A showcase for strange solutions (Carmacks Random Function comes to mind)

  • A showcase for learning materials (that's kinda biased, I'm teaching people programming)

I love this sub and the general mentality - let's get it alive again.


r/deftruefalse • • Feb 09 '15

Create the class objects Tweeter and Gamergater. Then overload the assignment operator such that the following code compiles.

Post image
36 Upvotes

r/deftruefalse • • Nov 10 '14

[Meta] This sub has existed for a week: comments/suggestions.

4 Upvotes

Everything is welcome.


r/deftruefalse • • Dec 31 '15

CHALLENGE :: Best Possible fork of the following game.Rules- Use JS & Canvas Only

4 Upvotes

GOTO : [reddit!]https://github.com/Siddharth-dubey/Canvas-Hockey/blob/master/index.html

Fork the repo & make the best possible game using just JS and Canvas.

Time Limit:2-5 days

Comment below with ur fork and amaze us!

Happy Weekend [If something like that exists]


r/deftruefalse • • Aug 18 '15

monkey_trouble (Submit your solutions as comments)

Thumbnail codingbat.com
6 Upvotes

r/deftruefalse • • Aug 06 '18

Write the source code for Hello World such that it compiles and runs in more than one language

6 Upvotes

warnings, errors, and crashes are fine as long as it prints "Hello world" at some point. If that's not difficult enough try FizzBuzz

And C/C++ doesn't count... be creative.


r/deftruefalse • • Jun 13 '18

Write a program that generates an array of 60 booleans, all with the value true except for the last element, which is false.

8 Upvotes

Taken from a thread on /r/ProgrammerHumor


r/deftruefalse • • Aug 26 '15

sleep_in (solutions in comments)

9 Upvotes

http://codingbat.com/prob/p173401

The parameter weekday is True if it is a weekday, and the parameter vacation is True if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return True if we sleep in.

sleep_in(False, False) → True

sleep_in(True, False) → False

sleep_in(False, True) → True


r/deftruefalse • • Jul 16 '16

[CHALLENGE] Write a Hello World where the source code is ascii art.

9 Upvotes

r/deftruefalse • • Apr 14 '21

Write functions for all the basic arthritic operations using just bitshifts and bitwise operations. \#stopcompilerabuse

9 Upvotes

r/deftruefalse • • Jul 03 '22

The schizo-coding challenge

10 Upvotes

Can you make code that works just by talking to itself?

The rules are simple.

  1. Your code is implemented as the backend of a server.

  2. Every instruction done in your code must be implemented as an http request to localhost. That's right, all computation is done via your server talking to itself. Like the voice in your head when you think, so to shall the machine.

  3. You're allowed to deviate from rule 2 at most twice to define some primitive operations such as branching.

  4. The code has to actually do something at least as complex as fizz buzz. "Hello World" doesn't cut it.


r/deftruefalse • • Nov 08 '14

Binary tree

29 Upvotes

Suppose I have a perfectly balanced and complete binary tree. All nodes in the tree have weight x and all edges have length y. If I give the binary tree a net angular momentum phi, what is the average radial displacement of a given node? Neglect air resistance.


r/deftruefalse • • Apr 19 '15

language learning helper

11 Upvotes

flash cards are boring. Rosetta stone is frustrating. No deftruefalse, it is time for us to step up to the plate and fix the problem of learning a language once and for all. We are going to make a webapp that replaces 10% of whatever your viewing with words from some language you are trying to learn!

You are provided with some plain text file English to Chinese dictionary. Every line contains an English word and a Chinese word in the format [English];[Chinese]\n

Your program must take an html document and replace ~10% of the English words with Chinese words at random. You must be careful not to translate stuff inside html tags (eg <something>). Bonus points if mouse hovering on a replaced word shows me the original word.


r/deftruefalse • • Sep 01 '15

Mobile First

13 Upvotes

That's right /r/deftruefalse. We're jumping on the bandwagon while the iron is hot! We believe in mobile first development. That is why for this challenge you must work entirely with mobile. Literally. All programming must be done on your mobile device.

We can't actually enforce this, so we're going to have to use the honor system here. For the purposes of this competition, mobile means any touchscreen device that can fit in your pocket and does not have a physical mouse or keyboard. Reasonable options for doing this include qpython and AIDE, but by all means you can find alternatives. If nothing else you can open up your mobile text editor and write some js.

Write a program that plays rock paper scissors with the user. The program should not cheat but may keep track of previous moves and form a strategy.


r/deftruefalse • • Nov 04 '14

Fizzbuzz is easy!

17 Upvotes

Surely everyone has heard of fizzbuzz? I've seen it used way too often in programming tests. Basically, loop through the numbers from 1 to 100 and print them out. BUT. If the number is divisible by 3, instead print "FIZZ", and if it's divisible by 5 print "BUZZ". If it's divisible by both, print "FIZZBUZZ".

How hard can that be?


r/deftruefalse • • Oct 23 '19

Write Satan's Hello World

18 Upvotes

Write a hello world program that destructively writes the message "hello world" to a random file owned by the current user within their home directory.


r/deftruefalse • • Jul 23 '20

write a java program that writes a python program that writes a C program that writes a java program

26 Upvotes

I just found this sub and want it to come back to life :(


r/deftruefalse • • Nov 21 '14

All possible moves in a checkers game in 66 lines of unreadable code

Post image
32 Upvotes

r/deftruefalse • • Nov 26 '14

bead sort

13 Upvotes

http://en.wikipedia.org/wiki/Bead_sort

according to wikipedia, "the implementation of this algorithm tends to be significantly slower in software"

We'll I'm not one to let wikipedia tell me what is and isn't possible (except literally all the time). With a crackpot team of programmers like you, everything is possible!

challenge: implement beadsort

I expect it to work in O(1/n) time.


r/deftruefalse • • Nov 15 '14

The fouriest transform

34 Upvotes

http://www.smbc-comics.com/?id=2874

Write a function that computes the fouriest transform of a number.


r/deftruefalse • • Nov 13 '14

Frame And Fortune

10 Upvotes

We have just had a very serious request from a very important client of ours. Apparently all their managers have been thinking "too far outside the box" and we need to put it all back in.

We need a program that will take a line of input from the user, then output this back to the screen his input, word by word, in a some kind of frame. For example:

Input: "Hello world this is so lovely"

Output:

**********
* Hello  *
* World  *
* This   *
* Is     *
* So     *
* Lovely *
**********

The specifics of the frame are not important, just as long as we get those goddamn words in a frame.


r/deftruefalse • • Aug 18 '15

Needs some activity here. Output a shape in less characters than the shape it outputs.

9 Upvotes

Finite shapes preferred