This challenge is intended to utilize the Python language as a means of solving a problem. However, language-specific challenges are generally discouraged on CG.
1
vote
4answers
346 views
secret language hackerrank.com
I tried this contest: https://www.hackerrank.com/challenges/secret-language
Well, the score in this contest said I made 30 out of 30 points. As the score is calculated with the formula ...
3
votes
1answer
221 views
shortest possible python pascal triangle code [duplicate]
the contest is already finished, so I don't think it's cheating to ask:
I am trying to optimize this small contest: pascal triangle
I started with 4.72 and worked myself up to 7.48.
The best made a ...
-3
votes
1answer
130 views
Collect all even numbers from a list [closed]
I start with a list
L = [1,2,3,4,5,6,7,8,9,10]
I'm collecting all even numbers like this
new = []
for n in L:
if n % 2 == 0:
new.append(n)
I am not sure how I would specify the condition ...
3
votes
1answer
328 views
Solve the CodeSprint4 Leibniz code golf challenge in Python in 66 characters
Check out this challenge:
https://www.hackerrank.com/codesprint4/challenges/leibniz
(The competition has already ended, so I'm just curious about the Python solution, which the organizers refused to ...
2
votes
2answers
488 views
Generate N number of “Go First” dice
Background
As described here http://www.ericharshbarger.org/dice/#gofirst_4d12, "Go First" Dice is a set of four dice, each with unique numbering, so that:
There will never be a tie. Each die has ...
0
votes
1answer
270 views
How can I make this program smaller? [closed]
I am trying my hand at writing super small programs. I wrote a simple "tree" display program for showing a graphical representation of a folder hierarchy. I have made it small in all the ways I can ...
-1
votes
2answers
130 views
Python Golfing - Narrow function calling on array down [closed]
Say i have a function named J and an array named f.
now i call this code:
result = []
for n in f:
results.append(J(n))
is there any more efficient way of doing this? I was thinking something ...
7
votes
1answer
423 views
What is the minimum set of characters with which you can write any valid python program?
The proof of the set of characters is that there is a translator which takes any ascii python program as input and produces a limited character set version of the program. The limited character set ...
2
votes
3answers
711 views
List of paths to nested dictionary
Given a list of nested menu items,
items = [
'3D/Axis',
'3D/CameraTracker',
'Color/Invert',
'Color/Log2Lin',
'Color/Math/Add',
'Color/Math/Multiply',
'Other/Group',
...
0
votes
1answer
737 views
Shortest Way of creating a basic Space Invaders Game in Python
Hello all code golfers:
Your challenge is to create a basic version of Space Invaders in Python
Rules
Program must be not written in Py3K
All levels must be randomly generated
There must be a HUD ...
0
votes
0answers
123 views
Python - Reverse Polish Notation [duplicate]
Possible Duplicate:
Reverse Polish notation
Create a function named rpn in python to evaluate a string written in Reverse Polish notation
Numbers must be separated by one or more spaces; ...
2
votes
3answers
535 views
Fastest python implementation of multiplication table
I'd be interested to see who can come up with the fastest function to produce multiplication tables, in the following format:
1 2 3 4 5 6 7 8 9 10 11 12
2 4 6 8 10 12 ...
-1
votes
2answers
887 views
Find and replace characters in a string to translate code using Python [closed]
I have an unintelligible string of characters with a simple key: every letter's true value is the letter +2 in the alphabet. Example: A --> C ; M --> O.
I wrote a simple python function that accepts ...
11
votes
2answers
640 views
Fastest python code to find a set of winning words in this game
This is a word game from a set of activity cards for children. Below the rules is code to find the best triplet using /usr/share/dict/words. I thought it was an interesting optimization problem, and ...
0
votes
1answer
892 views
Displaying a pyramid of asterisks with Python [closed]
Propose the shortest Python code to display a pyramid of asterisks.
5
votes
28answers
2k views
Sum of positive integers. (Spoj - SIZECON)
Problem:
Given a set of integers, find the sum of all positive integers in it.
Input:
t – number of test cases [t < 1000]
On each of next t lines, an integer N [-1000 ≤ N ≤ 1000]
Output
...
30
votes
26answers
4k views
Tips for golfing in Python
What general tips do you have for golfing in Python? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Python (e.g. "remove comments" is ...