Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Befunge Golfing Tips

+5
−0

Post tips for Befunge code golf here!

This is based on a type of question I used to see on CGCC, where people would post tips for golfing in various languages. They happened to be quite helpful, so I thought it'd be nice to bring them back.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

General comments (1 comment)

3 answers

You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.

+3
−0

Exploiting layout

Make it thin

Newlines and indentation are expensive, so remove them when possible. Some examples:

&v factorial
v<   >
>:1-:| v* <
     >$>\:|
          >$.@

Can be golfed significantly by removing |, which requires at least 3 lines

&>:1-:#v_$>\:#v_$.@
 ^     <  ^*  <

It could probably be golfed further by using unefunge-98 and the j command to remove the second line.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+3
−0

Golfing numbers

Numbers above 15 and below zero take more than one byte to create. Here's a table of numbers up to 100 (Not including negatives yet)

Table for '98

NOTE: For numbers that are also valid ASCII characters, it can be smaller to use " " to insert them. This isn't included in the table, as you can easily work this out yourself. 0..31 and 127 a hex editor to insert this way.

Number Solution
16 f1+
17 f2+
18 f3+
19 f4+
20 f5+
21 f6+
22 f7+
23 f8+
24 f9+
25 fa+
26 fb+
27 fc+
28 fd+
29 fe+
30 ff+
31 ff1++
32 48*
33 b3*
34 f2+2*
35 57*
36 66*
37 66*1+
38 f4+2*
39 d3*
40 a4*
41 a4*1+
42 67*
43 67*1+
44 b4*
45 59*
46 59*1+
47 59*2+
48 68*
49 77*
50 a5*
51 f2+3*
52 d4*
53 d4*1+
54 69*
55 b5*
56 78*
57 78*1+
58 78*2+
59 78*3+
60 a6*
61 a6*1+
62 a6*2+
63 79*
64 88*
65 d5*
66 6b*
67 6b*1+
68 6b*2+
69 6b*3+
70 a7*
71 a7*1+
72 89*
73 89*1+
74 89*2+
75 5f*
76 5f*1+
77 b7*
78 6d*
79 6d*1+
80 8a*
81 99*
82 99*1+
83 99*2+
84 7c*
85 7c*1+
86 7c*2+
87 7c*3+
88 8b*
89 8b*1+
90 9a*
91 7d*
92 7d*1+
93 7d*2+
94 7d*3+
95 7d*4+
96 c8*
97 c8*1+
98 e7*
99 b9*
100 aa*
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

General comments (1 comment)
+2
−0

Bitwise operations

(WIP)

Befunge, rather pointedly, lacks bitwise ops. No shifts, no and, no or, no xor.

Shifts

Shifts can be implemented as multiplication and division by powers of two. Shifts by arbitrary amounts can be done with successive multiplication/division by two. Rendered tricky by negatives, all shifts below are only functional with 31 bits and leave 32nd untouched.

Shift by n

Left shift

v
v
>1-\2*v
^_v#:\<
  $
  v
  v

Right shift

v
v
>1-\2/v
^_v#:\<
  $
  v
  v

Bidirectional shift (negative is right)

Note: not particularly golfed.

v
v
>:0`#v_0-v
v    < v <
>1-\2*v>1-\2\v
^_v#:\<^_v#:\<
  v      <
  $
  v
  v
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »