summaryrefslogtreecommitdiffstats
path: root/2021/day1
diff options
context:
space:
mode:
Diffstat (limited to '2021/day1')
-rw-r--r--2021/day1/.clang-format563
-rw-r--r--2021/day1/Makefile11
-rw-r--r--2021/day1/depth.c73
-rw-r--r--2021/day1/input2000
-rw-r--r--2021/day1/input.example10
5 files changed, 2657 insertions, 0 deletions
diff --git a/2021/day1/.clang-format b/2021/day1/.clang-format
new file mode 100644
index 0000000..ee17a69
--- /dev/null
+++ b/2021/day1/.clang-format
@@ -0,0 +1,563 @@
1# SPDX-License-Identifier: GPL-2.0
2#
3# clang-format configuration file. Intended for clang-format >= 4.
4#
5# For more information, see:
6#
7# Documentation/process/clang-format.rst
8# https://clang.llvm.org/docs/ClangFormat.html
9# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
10#
11---
12BasedOnStyle: LLVM
13IndentWidth: 8
14UseTab: Always
15BreakBeforeBraces: Linux
16AllowShortIfStatementsOnASingleLine: false
17IndentCaseLabels: false
18AccessModifierOffset: -4
19AlignAfterOpenBracket: Align
20AlignConsecutiveAssignments: None
21AlignConsecutiveDeclarations: false
22
23#AlignEscapedNewlines: Left # Unknown to clang-format-4.0
24AlignOperands: true
25AlignTrailingComments: false
26AllowAllParametersOfDeclarationOnNextLine: false
27AllowShortBlocksOnASingleLine: false
28AllowShortCaseLabelsOnASingleLine: false
29AllowShortFunctionsOnASingleLine: None
30AllowShortLoopsOnASingleLine: false
31AlwaysBreakAfterDefinitionReturnType: None
32AlwaysBreakAfterReturnType: None
33AlwaysBreakBeforeMultilineStrings: false
34AlwaysBreakTemplateDeclarations: false
35BinPackArguments: true
36BinPackParameters: true
37BraceWrapping:
38 AfterClass: false
39 AfterControlStatement: false
40 AfterEnum: false
41 AfterFunction: true
42 AfterNamespace: true
43 AfterObjCDeclaration: false
44 AfterStruct: false
45 AfterUnion: false
46 #AfterExternBlock: false # Unknown to clang-format-5.0
47 BeforeCatch: false
48 BeforeElse: false
49 IndentBraces: false
50 #SplitEmptyFunction: true # Unknown to clang-format-4.0
51 #SplitEmptyRecord: true # Unknown to clang-format-4.0
52 #SplitEmptyNamespace: true # Unknown to clang-format-4.0
53BreakBeforeBinaryOperators: true
54#BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0
55BreakBeforeTernaryOperators: false
56BreakConstructorInitializersBeforeComma: false
57#BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0
58BreakAfterJavaFieldAnnotations: false
59BreakStringLiterals: false
60ColumnLimit: 80
61CommentPragmas: '^ IWYU pragma:'
62#CompactNamespaces: false # Unknown to clang-format-4.0
63ConstructorInitializerAllOnOneLineOrOnePerLine: false
64ConstructorInitializerIndentWidth: 8
65ContinuationIndentWidth: 8
66Cpp11BracedListStyle: false
67DerivePointerAlignment: false
68DisableFormat: false
69ExperimentalAutoDetectBinPacking: false
70#FixNamespaceComments: false # Unknown to clang-format-4.0
71
72# Taken from:
73# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ \
74# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \
75# | sort | uniq
76ForEachMacros:
77 - 'apei_estatus_for_each_section'
78 - 'ata_for_each_dev'
79 - 'ata_for_each_link'
80 - '__ata_qc_for_each'
81 - 'ata_qc_for_each'
82 - 'ata_qc_for_each_raw'
83 - 'ata_qc_for_each_with_internal'
84 - 'ax25_for_each'
85 - 'ax25_uid_for_each'
86 - '__bio_for_each_bvec'
87 - 'bio_for_each_bvec'
88 - 'bio_for_each_bvec_all'
89 - 'bio_for_each_integrity_vec'
90 - '__bio_for_each_segment'
91 - 'bio_for_each_segment'
92 - 'bio_for_each_segment_all'
93 - 'bio_list_for_each'
94 - 'bip_for_each_vec'
95 - 'bitmap_for_each_clear_region'
96 - 'bitmap_for_each_set_region'
97 - 'blkg_for_each_descendant_post'
98 - 'blkg_for_each_descendant_pre'
99 - 'blk_queue_for_each_rl'
100 - 'bond_for_each_slave'
101 - 'bond_for_each_slave_rcu'
102 - 'bpf_for_each_spilled_reg'
103 - 'btree_for_each_safe128'
104 - 'btree_for_each_safe32'
105 - 'btree_for_each_safe64'
106 - 'btree_for_each_safel'
107 - 'card_for_each_dev'
108 - 'cgroup_taskset_for_each'
109 - 'cgroup_taskset_for_each_leader'
110 - 'cpufreq_for_each_entry'
111 - 'cpufreq_for_each_entry_idx'
112 - 'cpufreq_for_each_valid_entry'
113 - 'cpufreq_for_each_valid_entry_idx'
114 - 'css_for_each_child'
115 - 'css_for_each_descendant_post'
116 - 'css_for_each_descendant_pre'
117 - 'device_for_each_child_node'
118 - 'displayid_iter_for_each'
119 - 'dma_fence_chain_for_each'
120 - 'do_for_each_ftrace_op'
121 - 'drm_atomic_crtc_for_each_plane'
122 - 'drm_atomic_crtc_state_for_each_plane'
123 - 'drm_atomic_crtc_state_for_each_plane_state'
124 - 'drm_atomic_for_each_plane_damage'
125 - 'drm_client_for_each_connector_iter'
126 - 'drm_client_for_each_modeset'
127 - 'drm_connector_for_each_possible_encoder'
128 - 'drm_for_each_bridge_in_chain'
129 - 'drm_for_each_connector_iter'
130 - 'drm_for_each_crtc'
131 - 'drm_for_each_crtc_reverse'
132 - 'drm_for_each_encoder'
133 - 'drm_for_each_encoder_mask'
134 - 'drm_for_each_fb'
135 - 'drm_for_each_legacy_plane'
136 - 'drm_for_each_plane'
137 - 'drm_for_each_plane_mask'
138 - 'drm_for_each_privobj'
139 - 'drm_mm_for_each_hole'
140 - 'drm_mm_for_each_node'
141 - 'drm_mm_for_each_node_in_range'
142 - 'drm_mm_for_each_node_safe'
143 - 'flow_action_for_each'
144 - 'for_each_acpi_dev_match'
145 - 'for_each_active_dev_scope'
146 - 'for_each_active_drhd_unit'
147 - 'for_each_active_iommu'
148 - 'for_each_aggr_pgid'
149 - 'for_each_available_child_of_node'
150 - 'for_each_bio'
151 - 'for_each_board_func_rsrc'
152 - 'for_each_bvec'
153 - 'for_each_card_auxs'
154 - 'for_each_card_auxs_safe'
155 - 'for_each_card_components'
156 - 'for_each_card_dapms'
157 - 'for_each_card_pre_auxs'
158 - 'for_each_card_prelinks'
159 - 'for_each_card_rtds'
160 - 'for_each_card_rtds_safe'
161 - 'for_each_card_widgets'
162 - 'for_each_card_widgets_safe'
163 - 'for_each_cgroup_storage_type'
164 - 'for_each_child_of_node'
165 - 'for_each_clear_bit'
166 - 'for_each_clear_bit_from'
167 - 'for_each_cmsghdr'
168 - 'for_each_compatible_node'
169 - 'for_each_component_dais'
170 - 'for_each_component_dais_safe'
171 - 'for_each_comp_order'
172 - 'for_each_console'
173 - 'for_each_cpu'
174 - 'for_each_cpu_and'
175 - 'for_each_cpu_not'
176 - 'for_each_cpu_wrap'
177 - 'for_each_dapm_widgets'
178 - 'for_each_dev_addr'
179 - 'for_each_dev_scope'
180 - 'for_each_dma_cap_mask'
181 - 'for_each_dpcm_be'
182 - 'for_each_dpcm_be_rollback'
183 - 'for_each_dpcm_be_safe'
184 - 'for_each_dpcm_fe'
185 - 'for_each_drhd_unit'
186 - 'for_each_dss_dev'
187 - 'for_each_dtpm_table'
188 - 'for_each_efi_memory_desc'
189 - 'for_each_efi_memory_desc_in_map'
190 - 'for_each_element'
191 - 'for_each_element_extid'
192 - 'for_each_element_id'
193 - 'for_each_endpoint_of_node'
194 - 'for_each_evictable_lru'
195 - 'for_each_fib6_node_rt_rcu'
196 - 'for_each_fib6_walker_rt'
197 - 'for_each_free_mem_pfn_range_in_zone'
198 - 'for_each_free_mem_pfn_range_in_zone_from'
199 - 'for_each_free_mem_range'
200 - 'for_each_free_mem_range_reverse'
201 - 'for_each_func_rsrc'
202 - 'for_each_hstate'
203 - 'for_each_if'
204 - 'for_each_iommu'
205 - 'for_each_ip_tunnel_rcu'
206 - 'for_each_irq_nr'
207 - 'for_each_link_codecs'
208 - 'for_each_link_cpus'
209 - 'for_each_link_platforms'
210 - 'for_each_lru'
211 - 'for_each_matching_node'
212 - 'for_each_matching_node_and_match'
213 - 'for_each_member'
214 - 'for_each_memcg_cache_index'
215 - 'for_each_mem_pfn_range'
216 - '__for_each_mem_range'
217 - 'for_each_mem_range'
218 - '__for_each_mem_range_rev'
219 - 'for_each_mem_range_rev'
220 - 'for_each_mem_region'
221 - 'for_each_migratetype_order'
222 - 'for_each_msi_entry'
223 - 'for_each_msi_entry_safe'
224 - 'for_each_msi_vector'
225 - 'for_each_net'
226 - 'for_each_net_continue_reverse'
227 - 'for_each_netdev'
228 - 'for_each_netdev_continue'
229 - 'for_each_netdev_continue_rcu'
230 - 'for_each_netdev_continue_reverse'
231 - 'for_each_netdev_feature'
232 - 'for_each_netdev_in_bond_rcu'
233 - 'for_each_netdev_rcu'
234 - 'for_each_netdev_reverse'
235 - 'for_each_netdev_safe'
236 - 'for_each_net_rcu'
237 - 'for_each_new_connector_in_state'
238 - 'for_each_new_crtc_in_state'
239 - 'for_each_new_mst_mgr_in_state'
240 - 'for_each_new_plane_in_state'
241 - 'for_each_new_private_obj_in_state'
242 - 'for_each_node'
243 - 'for_each_node_by_name'
244 - 'for_each_node_by_type'
245 - 'for_each_node_mask'
246 - 'for_each_node_state'
247 - 'for_each_node_with_cpus'
248 - 'for_each_node_with_property'
249 - 'for_each_nonreserved_multicast_dest_pgid'
250 - 'for_each_of_allnodes'
251 - 'for_each_of_allnodes_from'
252 - 'for_each_of_cpu_node'
253 - 'for_each_of_pci_range'
254 - 'for_each_old_connector_in_state'
255 - 'for_each_old_crtc_in_state'
256 - 'for_each_old_mst_mgr_in_state'
257 - 'for_each_oldnew_connector_in_state'
258 - 'for_each_oldnew_crtc_in_state'
259 - 'for_each_oldnew_mst_mgr_in_state'
260 - 'for_each_oldnew_plane_in_state'
261 - 'for_each_oldnew_plane_in_state_reverse'
262 - 'for_each_oldnew_private_obj_in_state'
263 - 'for_each_old_plane_in_state'
264 - 'for_each_old_private_obj_in_state'
265 - 'for_each_online_cpu'
266 - 'for_each_online_node'
267 - 'for_each_online_pgdat'
268 - 'for_each_pci_bridge'
269 - 'for_each_pci_dev'
270 - 'for_each_pci_msi_entry'
271 - 'for_each_pcm_streams'
272 - 'for_each_physmem_range'
273 - 'for_each_populated_zone'
274 - 'for_each_possible_cpu'
275 - 'for_each_present_cpu'
276 - 'for_each_prime_number'
277 - 'for_each_prime_number_from'
278 - 'for_each_process'
279 - 'for_each_process_thread'
280 - 'for_each_prop_codec_conf'
281 - 'for_each_prop_dai_codec'
282 - 'for_each_prop_dai_cpu'
283 - 'for_each_prop_dlc_codecs'
284 - 'for_each_prop_dlc_cpus'
285 - 'for_each_prop_dlc_platforms'
286 - 'for_each_property_of_node'
287 - 'for_each_registered_fb'
288 - 'for_each_requested_gpio'
289 - 'for_each_requested_gpio_in_range'
290 - 'for_each_reserved_mem_range'
291 - 'for_each_reserved_mem_region'
292 - 'for_each_rtd_codec_dais'
293 - 'for_each_rtd_components'
294 - 'for_each_rtd_cpu_dais'
295 - 'for_each_rtd_dais'
296 - 'for_each_set_bit'
297 - 'for_each_set_bit_from'
298 - 'for_each_set_clump8'
299 - 'for_each_sg'
300 - 'for_each_sg_dma_page'
301 - 'for_each_sg_page'
302 - 'for_each_sgtable_dma_page'
303 - 'for_each_sgtable_dma_sg'
304 - 'for_each_sgtable_page'
305 - 'for_each_sgtable_sg'
306 - 'for_each_sibling_event'
307 - 'for_each_subelement'
308 - 'for_each_subelement_extid'
309 - 'for_each_subelement_id'
310 - '__for_each_thread'
311 - 'for_each_thread'
312 - 'for_each_unicast_dest_pgid'
313 - 'for_each_vsi'
314 - 'for_each_wakeup_source'
315 - 'for_each_zone'
316 - 'for_each_zone_zonelist'
317 - 'for_each_zone_zonelist_nodemask'
318 - 'fwnode_for_each_available_child_node'
319 - 'fwnode_for_each_child_node'
320 - 'fwnode_graph_for_each_endpoint'
321 - 'gadget_for_each_ep'
322 - 'genradix_for_each'
323 - 'genradix_for_each_from'
324 - 'hash_for_each'
325 - 'hash_for_each_possible'
326 - 'hash_for_each_possible_rcu'
327 - 'hash_for_each_possible_rcu_notrace'
328 - 'hash_for_each_possible_safe'
329 - 'hash_for_each_rcu'
330 - 'hash_for_each_safe'
331 - 'hctx_for_each_ctx'
332 - 'hlist_bl_for_each_entry'
333 - 'hlist_bl_for_each_entry_rcu'
334 - 'hlist_bl_for_each_entry_safe'
335 - 'hlist_for_each'
336 - 'hlist_for_each_entry'
337 - 'hlist_for_each_entry_continue'
338 - 'hlist_for_each_entry_continue_rcu'
339 - 'hlist_for_each_entry_continue_rcu_bh'
340 - 'hlist_for_each_entry_from'
341 - 'hlist_for_each_entry_from_rcu'
342 - 'hlist_for_each_entry_rcu'
343 - 'hlist_for_each_entry_rcu_bh'
344 - 'hlist_for_each_entry_rcu_notrace'
345 - 'hlist_for_each_entry_safe'
346 - 'hlist_for_each_entry_srcu'
347 - '__hlist_for_each_rcu'
348 - 'hlist_for_each_safe'
349 - 'hlist_nulls_for_each_entry'
350 - 'hlist_nulls_for_each_entry_from'
351 - 'hlist_nulls_for_each_entry_rcu'
352 - 'hlist_nulls_for_each_entry_safe'
353 - 'i3c_bus_for_each_i2cdev'
354 - 'i3c_bus_for_each_i3cdev'
355 - 'ide_host_for_each_port'
356 - 'ide_port_for_each_dev'
357 - 'ide_port_for_each_present_dev'
358 - 'idr_for_each_entry'
359 - 'idr_for_each_entry_continue'
360 - 'idr_for_each_entry_continue_ul'
361 - 'idr_for_each_entry_ul'
362 - 'in_dev_for_each_ifa_rcu'
363 - 'in_dev_for_each_ifa_rtnl'
364 - 'inet_bind_bucket_for_each'
365 - 'inet_lhash2_for_each_icsk_rcu'
366 - 'key_for_each'
367 - 'key_for_each_safe'
368 - 'klp_for_each_func'
369 - 'klp_for_each_func_safe'
370 - 'klp_for_each_func_static'
371 - 'klp_for_each_object'
372 - 'klp_for_each_object_safe'
373 - 'klp_for_each_object_static'
374 - 'kunit_suite_for_each_test_case'
375 - 'kvm_for_each_memslot'
376 - 'kvm_for_each_vcpu'
377 - 'list_for_each'
378 - 'list_for_each_codec'
379 - 'list_for_each_codec_safe'
380 - 'list_for_each_continue'
381 - 'list_for_each_entry'
382 - 'list_for_each_entry_continue'
383 - 'list_for_each_entry_continue_rcu'
384 - 'list_for_each_entry_continue_reverse'
385 - 'list_for_each_entry_from'
386 - 'list_for_each_entry_from_rcu'
387 - 'list_for_each_entry_from_reverse'
388 - 'list_for_each_entry_lockless'
389 - 'list_for_each_entry_rcu'
390 - 'list_for_each_entry_reverse'
391 - 'list_for_each_entry_safe'
392 - 'list_for_each_entry_safe_continue'
393 - 'list_for_each_entry_safe_from'
394 - 'list_for_each_entry_safe_reverse'
395 - 'list_for_each_entry_srcu'
396 - 'list_for_each_prev'
397 - 'list_for_each_prev_safe'
398 - 'list_for_each_safe'
399 - 'llist_for_each'
400 - 'llist_for_each_entry'
401 - 'llist_for_each_entry_safe'
402 - 'llist_for_each_safe'
403 - 'mci_for_each_dimm'
404 - 'media_device_for_each_entity'
405 - 'media_device_for_each_intf'
406 - 'media_device_for_each_link'
407 - 'media_device_for_each_pad'
408 - 'nanddev_io_for_each_page'
409 - 'netdev_for_each_lower_dev'
410 - 'netdev_for_each_lower_private'
411 - 'netdev_for_each_lower_private_rcu'
412 - 'netdev_for_each_mc_addr'
413 - 'netdev_for_each_uc_addr'
414 - 'netdev_for_each_upper_dev_rcu'
415 - 'netdev_hw_addr_list_for_each'
416 - 'nft_rule_for_each_expr'
417 - 'nla_for_each_attr'
418 - 'nla_for_each_nested'
419 - 'nlmsg_for_each_attr'
420 - 'nlmsg_for_each_msg'
421 - 'nr_neigh_for_each'
422 - 'nr_neigh_for_each_safe'
423 - 'nr_node_for_each'
424 - 'nr_node_for_each_safe'
425 - 'of_for_each_phandle'
426 - 'of_property_for_each_string'
427 - 'of_property_for_each_u32'
428 - 'pci_bus_for_each_resource'
429 - 'pcl_for_each_chunk'
430 - 'pcl_for_each_segment'
431 - 'pcm_for_each_format'
432 - 'ping_portaddr_for_each_entry'
433 - 'plist_for_each'
434 - 'plist_for_each_continue'
435 - 'plist_for_each_entry'
436 - 'plist_for_each_entry_continue'
437 - 'plist_for_each_entry_safe'
438 - 'plist_for_each_safe'
439 - 'pnp_for_each_card'
440 - 'pnp_for_each_dev'
441 - 'protocol_for_each_card'
442 - 'protocol_for_each_dev'
443 - 'queue_for_each_hw_ctx'
444 - 'radix_tree_for_each_slot'
445 - 'radix_tree_for_each_tagged'
446 - 'rb_for_each'
447 - 'rbtree_postorder_for_each_entry_safe'
448 - 'rdma_for_each_block'
449 - 'rdma_for_each_port'
450 - 'rdma_umem_for_each_dma_block'
451 - 'resource_list_for_each_entry'
452 - 'resource_list_for_each_entry_safe'
453 - 'rhl_for_each_entry_rcu'
454 - 'rhl_for_each_rcu'
455 - 'rht_for_each'
456 - 'rht_for_each_entry'
457 - 'rht_for_each_entry_from'
458 - 'rht_for_each_entry_rcu'
459 - 'rht_for_each_entry_rcu_from'
460 - 'rht_for_each_entry_safe'
461 - 'rht_for_each_from'
462 - 'rht_for_each_rcu'
463 - 'rht_for_each_rcu_from'
464 - '__rq_for_each_bio'
465 - 'rq_for_each_bvec'
466 - 'rq_for_each_segment'
467 - 'scsi_for_each_prot_sg'
468 - 'scsi_for_each_sg'
469 - 'sctp_for_each_hentry'
470 - 'sctp_skb_for_each'
471 - 'shdma_for_each_chan'
472 - '__shost_for_each_device'
473 - 'shost_for_each_device'
474 - 'sk_for_each'
475 - 'sk_for_each_bound'
476 - 'sk_for_each_entry_offset_rcu'
477 - 'sk_for_each_from'
478 - 'sk_for_each_rcu'
479 - 'sk_for_each_safe'
480 - 'sk_nulls_for_each'
481 - 'sk_nulls_for_each_from'
482 - 'sk_nulls_for_each_rcu'
483 - 'snd_array_for_each'
484 - 'snd_pcm_group_for_each_entry'
485 - 'snd_soc_dapm_widget_for_each_path'
486 - 'snd_soc_dapm_widget_for_each_path_safe'
487 - 'snd_soc_dapm_widget_for_each_sink_path'
488 - 'snd_soc_dapm_widget_for_each_source_path'
489 - 'tb_property_for_each'
490 - 'tcf_exts_for_each_action'
491 - 'udp_portaddr_for_each_entry'
492 - 'udp_portaddr_for_each_entry_rcu'
493 - 'usb_hub_for_each_child'
494 - 'v4l2_device_for_each_subdev'
495 - 'v4l2_m2m_for_each_dst_buf'
496 - 'v4l2_m2m_for_each_dst_buf_safe'
497 - 'v4l2_m2m_for_each_src_buf'
498 - 'v4l2_m2m_for_each_src_buf_safe'
499 - 'virtio_device_for_each_vq'
500 - 'while_for_each_ftrace_op'
501 - 'xa_for_each'
502 - 'xa_for_each_marked'
503 - 'xa_for_each_range'
504 - 'xa_for_each_start'
505 - 'xas_for_each'
506 - 'xas_for_each_conflict'
507 - 'xas_for_each_marked'
508 - 'xbc_array_for_each_value'
509 - 'xbc_for_each_key_value'
510 - 'xbc_node_for_each_array_value'
511 - 'xbc_node_for_each_child'
512 - 'xbc_node_for_each_key_value'
513 - 'zorro_for_each_dev'
514
515#IncludeBlocks: Preserve # Unknown to clang-format-5.0
516IncludeCategories:
517 - Regex: '.*'
518 Priority: 1
519IncludeIsMainRegex: '(Test)?$'
520#IndentPPDirectives: None # Unknown to clang-format-5.0
521IndentWrappedFunctionNames: false
522JavaScriptQuotes: Leave
523JavaScriptWrapImports: true
524KeepEmptyLinesAtTheStartOfBlocks: false
525MacroBlockBegin: ''
526MacroBlockEnd: ''
527MaxEmptyLinesToKeep: 1
528NamespaceIndentation: None
529#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0
530ObjCBlockIndentWidth: 8
531ObjCSpaceAfterProperty: true
532ObjCSpaceBeforeProtocolList: true
533
534# Taken from git's rules
535#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
536PenaltyBreakBeforeFirstCallParameter: 30
537PenaltyBreakComment: 10
538PenaltyBreakFirstLessLess: 0
539PenaltyBreakString: 10
540PenaltyExcessCharacter: 100
541PenaltyReturnTypeOnItsOwnLine: 60
542
543PointerAlignment: Right
544ReflowComments: true
545SortIncludes: false
546#SortUsingDeclarations: false # Unknown to clang-format-4.0
547SpaceAfterCStyleCast: false
548SpaceAfterTemplateKeyword: true
549SpaceBeforeAssignmentOperators: true
550#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
551#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
552SpaceBeforeParens: ControlStatements
553#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
554SpaceInEmptyParentheses: false
555SpacesBeforeTrailingComments: 1
556SpacesInAngles: false
557SpacesInContainerLiterals: false
558SpacesInCStyleCastParentheses: false
559SpacesInParentheses: false
560SpacesInSquareBrackets: false
561Standard: Cpp03
562TabWidth: 8
563...
diff --git a/2021/day1/Makefile b/2021/day1/Makefile
new file mode 100644
index 0000000..0255573
--- /dev/null
+++ b/2021/day1/Makefile
@@ -0,0 +1,11 @@
1src = $(wildcard *.c)
2obj = $(src:.c=.o)
3
4LDFLAGS = -Wall -g
5
6depth: $(obj)
7 $(CC) -o $@ $^ $(LDFLAGS)
8
9.PHONY: clean
10clean:
11 rm -f $(obj) depth
diff --git a/2021/day1/depth.c b/2021/day1/depth.c
new file mode 100644
index 0000000..eff19b4
--- /dev/null
+++ b/2021/day1/depth.c
@@ -0,0 +1,73 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <stdint.h>
5
6int main(int argc, char *argv[])
7{
8 if (argc != 2) {
9 printf("Usage: ./depth <input-file>\n");
10 exit(EXIT_FAILURE);
11 }
12
13 FILE *fp;
14 char *buffer;
15 ssize_t read;
16 size_t len = 0;
17
18 fp = fopen(argv[1], "r");
19 if (fp == NULL) {
20 perror("fopen");
21 exit(EXIT_FAILURE);
22 }
23
24 int inc = 0;
25 int curr = 0;
26 uint8_t idx = 0;
27 int side = 0;
28 int depth[3] = { 0, 0, 0 };
29
30 read = getline(&buffer, &len, fp);
31 if (read != -1) {
32 depth[0] = atoi(buffer);
33 }
34
35 read = getline(&buffer, &len, fp);
36 if (read != -1) {
37 curr = atoi(buffer);
38 depth[0] += curr;
39 depth[1] = curr;
40 }
41
42 read = getline(&buffer, &len, fp);
43 if (read != -1) {
44 curr = atoi(buffer);
45 depth[0] += curr;
46 depth[1] += curr;
47 depth[2] = curr;
48 }
49
50 while ((read = getline(&buffer, &len, fp)) != -1) {
51 side = depth[idx];
52 depth[idx] = 0;
53 idx = (idx + 1) % 3;
54
55 curr = atoi(buffer);
56 depth[0] += curr;
57 depth[1] += curr;
58 depth[2] += curr;
59
60 if (depth[idx] > side) {
61 inc++;
62 }
63 }
64
65 fclose(fp);
66 if (buffer) {
67 free(buffer);
68 }
69
70 printf("%d", inc);
71
72 return 0;
73}
diff --git a/2021/day1/input b/2021/day1/input
new file mode 100644
index 0000000..97c1adf
--- /dev/null
+++ b/2021/day1/input
@@ -0,0 +1,2000 @@
1155
2157
3156
4172
5170
6186
7198
8189
9207
10213
11222
12228
13229
14227
15220
16226
17241
18243
19244
20246
21256
22255
23260
24266
25268
26270
27269
28271
29272
30275
31276
32277
33272
34273
35278
36286
37293
38298
39304
40305
41317
42330
43342
44341
45371
46374
47376
48377
49381
50385
51398
52409
53433
54434
55435
56436
57437
58443
59445
60455
61450
62447
63462
64465
65466
66468
67474
68493
69494
70523
71532
72539
73538
74539
75542
76547
77545
78557
79558
80561
81581
82582
83583
84580
85584
86603
87617
88618
89605
90616
91618
92620
93636
94637
95639
96640
97641
98642
99641
100642
101644
102645
103664
104668
105678
106679
107681
108686
109687
110688
111689
112706
113709
114724
115727
116735
117737
118749
119753
120754
121760
122766
123770
124765
125766
126773
127775
128777
129785
130786
131787
132797
133798
134818
135835
136836
137838
138859
139856
140860
141867
142868
143870
144871
145892
146896
147897
148898
149919
150928
151944
152943
153965
154980
155982
156988
157994
158997
159998
160997
161998
162982
163990
164986
165985
166986
167987
168997
1691003
170998
1711005
1721006
1731009
1741008
1751015
1761021
1771023
1781024
1791021
1801041
1811042
1821044
1831052
1841053
1851056
1861053
1871056
1881057
1891058
1901060
1911053
1921054
1931059
1941056
1951057
1961068
1971081
1981093
1991094
2001099
2011103
2021101
2031103
2041125
2051127
2061128
2071134
2081130
2091133
2101137
2111141
2121142
2131144
2141164
2151166
2161180
2171178
2181177
2191182
2201183
2211180
2221182
2231197
2241198
2251203
2261204
2271206
2281207
2291208
2301217
2311241
2321250
2331249
2341250
2351252
2361253
2371257
2381285
2391286
2401290
2411302
2421330
2431332
2441333
2451334
2461336
2471334
2481331
2491332
2501344
2511345
2521354
2531358
2541357
2551360
2561362
2571376
2581378
2591379
2601381
2611379
2621381
2631380
2641379
2651383
2661393
2671403
2681407
2691397
2701403
2711408
2721413
2731415
2741419
2751427
2761430
2771438
2781441
2791446
2801476
2811502
2821495
2831497
2841498
2851499
2861500
2871502
2881503
2891505
2901526
2911552
2921570
2931572
2941577
2951579
2961574
2971575
2981585
2991605
3001624
3011626
3021631
3031646
3041647
3051649
3061681
3071682
3081684
3091687
3101690
3111691
3121694
3131718
3141719
3151723
3161731
3171721
3181723
3191724
3201742
3211743
3221748
3231753
3241761
3251762
3261765
3271772
3281774
3291773
3301781
3311784
3321789
3331794
3341795
3351803
3361807
3371813
3381829
3391828
3401830
3411844
3421847
3431850
3441854
3451855
3461850
3471848
3481853
3491878
3501909
3511910
3521912
3531917
3541937
3551939
3561943
3571941
3581952
3591959
3601963
3611971
3621974
3631989
3642007
3652009
3662005
3672006
3682010
3692013
3702016
3712027
3722044
3732030
3742031
3752032
3762035
3772036
3782047
3792050
3802052
3812061
3822071
3832077
3842080
3852082
3862094
3872098
3882119
3892111
3902112
3912127
3922139
3932140
3942141
3952149
3962151
3972156
3982157
3992171
4002186
4012202
4022206
4032221
4042239
4052247
4062252
4072262
4082264
4092271
4102281
4112291
4122293
4132333
4142335
4152339
4162343
4172338
4182342
4192337
4202343
4212344
4222347
4232353
4242358
4252363
4262364
4272377
4282403
4292402
4302405
4312418
4322408
4332406
4342422
4352424
4362422
4372435
4382437
4392439
4402446
4412458
4422459
4432484
4442486
4452487
4462484
4472486
4482485
4492508
4502509
4512507
4522508
4532509
4542521
4552531
4562541
4572542
4582545
4592556
4602566
4612579
4622582
4632583
4642584
4652585
4662591
4672593
4682594
4692598
4702599
4712600
4722601
4732604
4742609
4752616
4762638
4772647
4782646
4792645
4802642
4812643
4822644
4832645
4842624
4852635
4862634
4872639
4882643
4892645
4902658
4912659
4922662
4932666
4942654
4952655
4962666
4972663
4982673
4992684
5002702
5012707
5022708
5032734
5042742
5052745
5062748
5072751
5082754
5092753
5102751
5112758
5122757
5132775
5142761
5152772
5162773
5172796
5182807
5192808
5202809
5212810
5222817
5232819
5242823
5252824
5262847
5272850
5282851
5292859
5302861
5312862
5322854
5332860
5342877
5352880
5362881
5372880
5382913
5392916
5402917
5412918
5422938
5432954
5442957
5452965
5462971
5472976
5482984
5492985
5502986
5513002
5523003
5533004
5543005
5552990
5563004
5572997
5582995
5593011
5603005
5613009
5623018
5633019
5643021
5653015
5663016
5673017
5683024
5693026
5703041
5713042
5723052
5733064
5743063
5753068
5763087
5773088
5783084
5793110
5803109
5813121
5823131
5833130
5843134
5853139
5863145
5873153
5883159
5893162
5903179
5913219
5923224
5933220
5943221
5953230
5963232
5973256
5983236
5993235
6003237
6013245
6023250
6033265
6043222
6053238
6063273
6073287
6083288
6093293
6103297
6113307
6123292
6133306
6143311
6153312
6163324
6173315
6183316
6193318
6203316
6213317
6223318
6233320
6243321
6253328
6263330
6273331
6283333
6293337
6303342
6313323
6323332
6333330
6343337
6353338
6363347
6373343
6383345
6393347
6403353
6413361
6423362
6433363
6443366
6453351
6463353
6473365
6483368
6493389
6503400
6513410
6523420
6533438
6543439
6553445
6563444
6573472
6583486
6593484
6603494
6613503
6623504
6633505
6643513
6653524
6663526
6673527
6683535
6693536
6703529
6713530
6723531
6733533
6743547
6753549
6763562
6773553
6783560
6793561
6803562
6813566
6823567
6833568
6843578
6853579
6863581
6873611
6883613
6893615
6903618
6913639
6923655
6933657
6943676
6953680
6963700
6973709
6983710
6993717
7003720
7013727
7023735
7033736
7043746
7053768
7063772
7073777
7083780
7093790
7103799
7113802
7123804
7133812
7143814
7153815
7163823
7173824
7183827
7193853
7203861
7213854
7223846
7233849
7243868
7253879
7263883
7273880
7283881
7293889
7303891
7313890
7323899
7333891
7343885
7353917
7363918
7373919
7383920
7393926
7403921
7413931
7423938
7433939
7443950
7453951
7463955
7473966
7483965
7493970
7503982
7513996
7523997
7534000
7544002
7554003
7564005
7574010
7584015
7594023
7604027
7614019
7624025
7634034
7644035
7654037
7664053
7674075
7684084
7694089
7704093
7714083
7724089
7734090
7744129
7754141
7764158
7774185
7784189
7794191
7804201
7814202
7824212
7834222
7844223
7854238
7864244
7874243
7884245
7894252
7904270
7914275
7924278
7934279
7944283
7954285
7964289
7974290
7984293
7994294
8004302
8014306
8024290
8034292
8044310
8054317
8064318
8074321
8084322
8094325
8104303
8114304
8124306
8134307
8144310
8154330
8164328
8174329
8184330
8194332
8204335
8214337
8224336
8234344
8244347
8254342
8264361
8274362
8284361
8294359
8304379
8314385
8324390
8334389
8344392
8354395
8364397
8374412
8384415
8394416
8404418
8414441
8424442
8434443
8444441
8454435
8464437
8474450
8484471
8494472
8504473
8514469
8524470
8534490
8544492
8554511
8564516
8574517
8584530
8594524
8604522
8614523
8624522
8634531
8644532
8654543
8664549
8674548
8684546
8694537
8704533
8714542
8724551
8734552
8744562
8754570
8764571
8774576
8784585
8794597
8804599
8814600
8824605
8834606
8844607
8854630
8864642
8874643
8884639
8894675
8904661
8914684
8924685
8934697
8944699
8954730
8964731
8974732
8984734
8994737
9004744
9014761
9024771
9034775
9044776
9054784
9064789
9074790
9084767
9094768
9104770
9114771
9124772
9134792
9144801
9154808
9164811
9174818
9184811
9194813
9204814
9214815
9224824
9234823
9244824
9254827
9264830
9274832
9284821
9294809
9304812
9314841
9324842
9334844
9344801
9354805
9364820
9374832
9384823
9394824
9404816
9414818
9424817
9434816
9444822
9454858
9464861
9474880
9484879
9494886
9504893
9514902
9524906
9534901
9544913
9554919
9564928
9574926
9584927
9594935
9604937
9614938
9624939
9634941
9644942
9654947
9664949
9674963
9684955
9694958
9704960
9714956
9724958
9734957
9744961
9754971
9764972
9774975
9784978
9794979
9804985
9814972
9825019
9835023
9845022
9855014
9865016
9875024
9885026
9895049
9905054
9915055
9925051
9935052
9945055
9955062
9965065
9975067
9985065
9995067
10005047
10015060
10025061
10035074
10045101
10055103
10065104
10075108
10085110
10095113
10105124
10115122
10125109
10135110
10145093
10155103
10165099
10175101
10185102
10195108
10205106
10215139
10225160
10235164
10245165
10255170
10265164
10275166
10285168
10295178
10305199
10315200
10325202
10335206
10345214
10355217
10365222
10375223
10385263
10395268
10405288
10415289
10425301
10435324
10445301
10455302
10465304
10475318
10485321
10495329
10505337
10515340
10525346
10535369
10545386
10555377
10565392
10575383
10585385
10595403
10605402
10615404
10625434
10635440
10645442
10655434
10665442
10675452
10685453
10695495
10705499
10715503
10725509
10735508
10745513
10755515
10765521
10775527
10785532
10795543
10805544
10815549
10825550
10835551
10845537
10855508
10865509
10875514
10885517
10895521
10905538
10915546
10925561
10935563
10945566
10955569
10965581
10975592
10985608
10995607
11005612
11015618
11025630
11035636
11045652
11055662
11065663
11075672
11085681
11095682
11105680
11115671
11125678
11135692
11145701
11155707
11165709
11175710
11185711
11195713
11205702
11215713
11225700
11235701
11245702
11255699
11265678
11275679
11285684
11295688
11305720
11315722
11325726
11335731
11345732
11355731
11365735
11375741
11385742
11395747
11405748
11415773
11425792
11435795
11445797
11455820
11465819
11475825
11485827
11495829
11505852
11515853
11525856
11535868
11545875
11555883
11565907
11575872
11585882
11595893
11605929
11615942
11625943
11635946
11645948
11655949
11665950
11675959
11685961
11695965
11705971
11715972
11725973
11735964
11745957
11755977
11765978
11775976
11785980
11795984
11806009
11816023
11826035
11836037
11846039
11856040
11866041
11876048
11886061
11896081
11906080
11916088
11926086
11936089
11946113
11956118
11966124
11976139
11986140
11996142
12006134
12016125
12026130
12036134
12046139
12056145
12066169
12076170
12086173
12096174
12106184
12116155
12126169
12136184
12146190
12156199
12166204
12176205
12186221
12196220
12206229
12216206
12226207
12236209
12246219
12256222
12266220
12276221
12286223
12296225
12306226
12316245
12326246
12336251
12346257
12356258
12366269
12376280
12386282
12396283
12406287
12416296
12426298
12436303
12446304
12456312
12466301
12476304
12486302
12496314
12506317
12516336
12526348
12536357
12546355
12556356
12566364
12576368
12586366
12596374
12606372
12616351
12626358
12636356
12646364
12656365
12666381
12676406
12686420
12696424
12706420
12716432
12726447
12736454
12746456
12756498
12766497
12776498
12786500
12796508
12806544
12816546
12826548
12836557
12846564
12856566
12866567
12876570
12886599
12896602
12906600
12916606
12926608
12936605
12946608
12956610
12966624
12976601
12986604
12996603
13006619
13016647
13026661
13036660
13046663
13056664
13066679
13076682
13086686
13096701
13106702
13116710
13126719
13136720
13146715
13156716
13166718
13176728
13186729
13196712
13206711
13216718
13226730
13236731
13246757
13256760
13266765
13276748
13286747
13296746
13306775
13316776
13326775
13336785
13346786
13356788
13366791
13376792
13386800
13396802
13406803
13416806
13426809
13436806
13446818
13456821
13466823
13476824
13486832
13496835
13506834
13516838
13526840
13536844
13546845
13556854
13566857
13576863
13586885
13596893
13606908
13616922
13626914
13636915
13646922
13656923
13666924
13676926
13686930
13696938
13706970
13716971
13726972
13736971
13746978
13756975
13766978
13776958
13786971
13796977
13806978
13816979
13826982
13836986
13846985
13856988
13867000
13877002
13887007
13897017
13907019
13917040
13927043
13937045
13947046
13957047
13967057
13977061
13987073
13997093
14007095
14017096
14027121
14037129
14047130
14057135
14067139
14077141
14087143
14097145
14107147
14117148
14127149
14137152
14147160
14157170
14167171
14177174
14187175
14197170
14207171
14217198
14227201
14237203
14247204
14257211
14267214
14277215
14287246
14297233
14307238
14317240
14327253
14337254
14347249
14357252
14367256
14377267
14387268
14397274
14407277
14417279
14427285
14437290
14447296
14457298
14467313
14477326
14487332
14497335
14507338
14517345
14527346
14537353
14547356
14557360
14567367
14577392
14587395
14597404
14607416
14617418
14627438
14637451
14647452
14657449
14667453
14677469
14687471
14697473
14707503
14717504
14727517
14737520
14747532
14757533
14767544
14777553
14787565
14797575
14807576
14817575
14827581
14837597
14847633
14857634
14867632
14877633
14887637
14897638
14907644
14917634
14927643
14937644
14947645
14957646
14967649
14977629
14987630
14997632
15007635
15017636
15027642
15037643
15047645
15057644
15067660
15077663
15087672
15097675
15107677
15117680
15127701
15137702
15147709
15157720
15167726
15177734
15187735
15197773
15207774
15217779
15227782
15237787
15247783
15257785
15267787
15277788
15287791
15297793
15307797
15317802
15327803
15337805
15347809
15357805
15367815
15377826
15387832
15397851
15407852
15417853
15427874
15437854
15447858
15457866
15467867
15477850
15487858
15497876
15507892
15517897
15527898
15537900
15547908
15557909
15567911
15577917
15587918
15597919
15607920
15617914
15627911
15637914
15647929
15657942
15667943
15677944
15687945
15697944
15707945
15717976
15727988
15737998
15748001
15758002
15768008
15778010
15788006
15798011
15808006
15818016
15828018
15838019
15848020
15858024
15868027
15878031
15888022
15898025
15908039
15918040
15928049
15938069
15948070
15958071
15968080
15978081
15988093
15998096
16008107
16018110
16028115
16038124
16048126
16058115
16068118
16078121
16088142
16098143
16108147
16118148
16128152
16138156
16148158
16158159
16168160
16178163
16188166
16198179
16208202
16218203
16228205
16238214
16248215
16258211
16268218
16278228
16288229
16298230
16308252
16318255
16328258
16338266
16348267
16358268
16368270
16378275
16388276
16398278
16408283
16418292
16428303
16438305
16448293
16458297
16468313
16478317
16488308
16498307
16508308
16518323
16528326
16538331
16548328
16558329
16568332
16578335
16588337
16598336
16608337
16618338
16628362
16638363
16648364
16658366
16668369
16678379
16688384
16698385
16708392
16718400
16728424
16738429
16748432
16758434
16768433
16778434
16788437
16798438
16808442
16818437
16828438
16838450
16848451
16858445
16868449
16878452
16888478
16898480
16908498
16918490
16928492
16938493
16948494
16958495
16968503
16978504
16988507
16998516
17008517
17018543
17028544
17038555
17048571
17058572
17068574
17078575
17088580
17098590
17108593
17118601
17128603
17138610
17148616
17158617
17168619
17178644
17188645
17198646
17208652
17218653
17228654
17238655
17248656
17258659
17268660
17278666
17288668
17298669
17308672
17318690
17328682
17338685
17348686
17358665
17368674
17378672
17388677
17398678
17408679
17418684
17428695
17438704
17448725
17458745
17468747
17478739
17488755
17498757
17508734
17518738
17528737
17538730
17548735
17558739
17568747
17578750
17588777
17598778
17608780
17618782
17628783
17638785
17648786
17658777
17668778
17678779
17688783
17698788
17708789
17718795
17728811
17738829
17748834
17758862
17768871
17778875
17788878
17798879
17808872
17818867
17828881
17838892
17848893
17858896
17868897
17878896
17888897
17898898
17908907
17918908
17928910
17938937
17948943
17958950
17968951
17978953
17988964
17998985
18008982
18018987
18028994
18039021
18049023
18059024
18069019
18079024
18089029
18099008
18109020
18119026
18129027
18139044
18149061
18159058
18169061
18179065
18189066
18199067
18209077
18219078
18229077
18239075
18249076
18259078
18269087
18279082
18289083
18299085
18309086
18319101
18329112
18339122
18349123
18359128
18369129
18379131
18389134
18399138
18409147
18419153
18429171
18439165
18449155
18459159
18469185
18479183
18489186
18499190
18509193
18519194
18529197
18539203
18549204
18559214
18569213
18579218
18589227
18599231
18609247
18619262
18629266
18639268
18649269
18659259
18669260
18679268
18689278
18699279
18709299
18719300
18729301
18739302
18749312
18759313
18769314
18779346
18789347
18799348
18809337
18819342
18829338
18839337
18849357
18859360
18869364
18879367
18889382
18899410
18909411
18919422
18929429
18939431
18949430
18959437
18969438
18979442
18989441
18999443
19009455
19019462
19029464
19039472
19049497
19059528
19069551
19079553
19089555
19099556
19109569
19119580
19129584
19139586
19149575
19159578
19169579
19179587
19189590
19199619
19209622
19219628
19229616
19239614
19249625
19259626
19269631
19279641
19289648
19299658
19309663
19319664
19329665
19339649
19349650
19359647
19369657
19379661
19389663
19399668
19409673
19419678
19429681
19439682
19449687
19459688
19469705
19479706
19489710
19499716
19509728
19519730
19529733
19539726
19549727
19559728
19569729
19579730
19589727
19599729
19609731
19619732
19629735
19639746
19649748
19659753
19669752
19679739
19689738
19699760
19709765
19719768
19729767
19739771
19749762
19759765
19769766
19779759
19789765
19799766
19809797
19819802
19829803
19839805
19849807
19859813
19869814
19879818
19889819
19899825
19909826
19919827
19929828
19939829
19949833
19959849
19969855
19979856
19989875
19999893
20009899
diff --git a/2021/day1/input.example b/2021/day1/input.example
new file mode 100644
index 0000000..167e291
--- /dev/null
+++ b/2021/day1/input.example
@@ -0,0 +1,10 @@
1199
2200
3208
4210
5200
6207
7240
8269
9260
10263