One of the main reasons I don't like a if b else c style is that it separates the branches (making multi-line especially messy). With a ? b : c you have your condition up front, with two branches following. Branch-conditional-branch is just bad.
The dangling else is a problem in computer programming in which an optional else clause in an if–then(–else) statement results in nested conditionals being ambiguous. Formally, the reference context-free grammar of the language is ambiguous, meaning there is more than one correct parse tree.
In many programming languages one may write conditionally executed code in two forms: the if-then form, and the if-then-else form – the else clause is optional:
if a then s
if b then s1 else s2
This gives rise to an ambiguity in interpretation when there are nested statements, specifically whenever an if...
Using Ruby on Rails and Materialize CSS, the Roboto font is not rendering.
My layout:
application.html.erb
<!DOCTYPE html>
<html>
<head>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-t...
Python, 69 bytes
Apparently shorter than the other python entries, save one that uses sympy numpy (misremembered)
from random import*
print(eval(('+(1>('+2*'+random()**2)')*2000)/500)
Wow, it's been a while since I posted a multiline answer on this site... I've been using Turtlèd too much for...
The Multiplication Fibonacci sequence starts with 1 and 2, then each term is the product of the last two terms:
Fn = Fn-1 × Fn-2; F1 = 1; F2 = 2
The sequence starts out like this:
1
2
2
4
8
32
256
8192
2097152
17179869184
36028797018963968
618970019642690137449562112
Given a positive int...
Turtlèd, 28 26 bytes
Oh my, I appear to be beating a language specifically designed for golfing. this is a great day.
!_4[*.[ rd+.]ul[ ul]r;_+]_
Try it online!
note trailing space.
Input also needs trailing space. seeing as python can take a list, this is a lot like taking a list in Turtlèd
Magic mirror madness
code-golf string
Introduction
I have a room full of magic mirrors.
They are mysterious artifacts that can duplicate any item, except another magic mirror.
More explicitly, a duplicate version of the item will appear on the other side of the mirror, at the same distance.
...
No need for <pre>, just have all the code in a text box and hit the "fixed font" button
(or Ctrl+K or whatever the shortcut was)
Anonymous
If a new tag is created, do mods have tools to add it to a bunch of questions without bumping them, or will it have to be done in waves (to prevent flooding the front page)?
Briefing:
You are a bot, in a 2D grid that extends infinitely in all four directions, north, south, east and west. When given a number, you must move the bot so that you get to the target number.
Here's how the grid works:
You can move in 4 directions: north, south, east or west. Once you move...
Haskell, 116 bytes
d=8^9
g[a,b]=0^(fromEnum$a+b+d^2<a^2+b^2+div d 2)
p n=4*(sum.take(floor n)$g<$>iterate((\x->mod(9*x+1)d)<$>)[1,5])/n
Because dealing with import System.Random; r=randoms(mkStdGen 2) would take too many precious bytes, I generate an infinite list of random numbers with the al...
"almost cryptographically strong linear congruential generator" <-- er... am I missing something or is this a contradiction? And also how are you thinking of snipping the numbers?
Personally it seems to me like the period's too short for any reasonable approximation to pi, but then again the challenge doesn't exactly specify anything about that... :/
And arguably any LCG is bad for that challenge because two consecutive random numbers aren't independent so the point on the square has a bad distribution.
Anonymous
(diameter of Earth) * 3.144 is ~12 miles off of the actual circumference of the equator
@Sp3000 and 8^9=134217728, so the square can be thought of as a 134217728×134217728 grid that the samples will cover in a uniform lattice if enough are taken.
Maybe it's technically more correct but it really doesn't matter in an oral conversation (and even on paper, I would probably write either without second thoughts)
@Fatalize "aussi" at the end end sounds less formal... and I like to sound not too formal! But you're right, it's grammatically more accurate on the middle