Questions tagged [function]
For challenges that ask for a function or involve functions in some way. (Also known as methods or subroutines.)
6 questions
12
votes
6
answers
3k
views
Implement t9-like functionality
Your challenge today is to implement a t9-like functionality.
You will implement a function that will only have 2 parameters.
You will receive 1 phone number in a string and the content of a text ...
29
votes
13
answers
6k
views
Lifetime of a Worm
Terms
A worm is any list of nonnegative integers, and its rightmost (i.e., last) element is called the head. If the head is not 0, the worm has an active segment consisting of the longest contiguous ...
80
votes
78
answers
17k
views
Call a method without calling it [closed]
Inspired by a now deleted StackOverflow question. Can you come up with a way to get a particular method executed, without explicitly calling it? The more indirect it is, the better.
Here's what I ...
29
votes
13
answers
2k
views
Write a function that tells you which of its lines has been removed
Write a function that contains five lines.
If you run the function as-is, it should return 0.
If you remove any one of the five lines and run the function, it should tell you which of the lines has ...
19
votes
62
answers
6k
views
Write a function [closed]
I honestly can't believe this challenge does not already exist.
The challenge
Write a function.
The specifics
Your program must define some sort of callable function. This includes anything ...
18
votes
24
answers
8k
views
Old MacDonald function
Create a function in your chosen language that prints out the following:
...