19
Winner: Chilemagic, a massive 21 bytes!
You may continue to submit your answer, however you can no longer win. Original post kept:
Your goal is to find all numbers in a string, and multiply each one individually by a value input by the user
- You will not need to worry about decimals
- The user will input a number and a string
- The user must type the number and string at some point, however the method the program reads it does not matter. It can be with stdin, reading a text file, etc, however the user must press the 9 button on their keyboard (for example) at some point
- Anything that can compile and run is acceptable
Example:
Sentence input: This 1 is22a 3352sentence 50
Number input: 3
Output: This 3 is66a 10056sentence 150
- This contest ends on September 6th, 2014 (7 days from posting).
- This is a code-golf, so the shortest code wins
Any number is to be multiplied. I updated my example. – Jon – 2014-08-31T04:59:18.023
I don't understand the significance or use of "press the 9 button" in your challenge. How or where does it apply in the example given? – Darren Stone – 2014-08-31T05:01:57.217
If the number to be multiplied by is 9, the user must press the 9 key at some point. – Jon – 2014-08-31T05:08:25.260
3@Darren He's basically saying that you can't hardcode the number. – Beta Decay – 2014-08-31T08:59:36.903
2Can we make assumptions about the size of the numbers involved, particularly the possibility of overflow? Depending on the results of the above, do we treat "-1234" as "-" followed by 1234 or as -1234? – Alchymist – 2014-09-01T11:30:55.437
Is it acceptable to output the number 0 as an empty string? I assume not, but I figured I should make sure. – Ilmari Karonen – 2014-09-01T19:59:15.947
@Alchymist There isn't any difference between these two cases if the factor is positive. – FUZxxl – 2014-09-01T22:42:06.310
What are the restrictions if any on what programming language can be used? – x-code – 2014-09-02T00:29:20.157
@x-code Any language. – Jon – 2014-09-02T04:23:08.693
1To add to @IlmariKaronen's question: What to do with leading zeroes as in "Bond is agent 007" -> "Bond is agent 21" or "Bond is agent 0021" or "Bond is agent 021" or ...? – Hagen von Eitzen – 2014-09-02T11:35:39.447
agent 007 should give agent 025, because, you see, 007 is octal. :-) – Florian F – 2014-09-04T12:58:35.053
@FUZxxl There is a difference if there can be numeric overflow – Alchymist – 2014-09-08T12:33:30.303
@Alchymist That's a point. We can assume by common code-golf rules that the input data will only contain numbers of reasonable size. – FUZxxl – 2014-09-09T08:36:03.987